[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/corfu d524a0c738: Add generalized corfu-preselect user
From: |
ELPA Syncer |
Subject: |
[elpa] externals/corfu d524a0c738: Add generalized corfu-preselect user option |
Date: |
Thu, 22 Dec 2022 10:57:27 -0500 (EST) |
branch: externals/corfu
commit d524a0c738f6c5dcc4234d5779035965b1bdf28c
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>
Add generalized corfu-preselect user option
This replaces the old corfu-preselect-first option.
---
CHANGELOG.org | 1 +
README.org | 6 +++---
corfu.el | 25 ++++++++++++++++---------
3 files changed, 20 insertions(+), 12 deletions(-)
diff --git a/CHANGELOG.org b/CHANGELOG.org
index b0026d3178..96ee5fbcf6 100644
--- a/CHANGELOG.org
+++ b/CHANGELOG.org
@@ -6,6 +6,7 @@
- =corfu-popupinfo=: Add commands =corfu-popupinfo-beginning/end=
- =corfu-popupinfo=: Improve popup placement
+- Add =corfu-preselect= option, deprecate =corfu-preselect-first=.
* Version 0.34 (2022-12-03)
diff --git a/README.org b/README.org
index dfa754239f..7dd6feb234 100644
--- a/README.org
+++ b/README.org
@@ -85,7 +85,7 @@ Here is an example configuration:
;; (corfu-quit-at-boundary nil) ;; Never quit at completion boundary
;; (corfu-quit-no-match nil) ;; Never quit, even if there is no match
;; (corfu-preview-current nil) ;; Disable current candidate preview
- ;; (corfu-preselect-first nil) ;; Disable candidate preselection
+ ;; (corfu-preselect 'prompt) ;; Preselect the prompt
;; (corfu-on-exact-match nil) ;; Configure handling of exact matches
;; (corfu-scroll-margin 5) ;; Use scroll margin
@@ -385,8 +385,8 @@ force snippet expansion, confirm a candidate explicitly
with ~RET~.
(use-package corfu
;; TAB-and-Go customizations
:custom
- (corfu-cycle t) ;; Enable cycling for `corfu-next/previous'
- (corfu-preselect-first nil) ;; Disable candidate preselection
+ (corfu-cycle t) ;; Enable cycling for `corfu-next/previous'
+ (corfu-preselect 'prompt) ;; Always preselect the prompt
;; Use TAB for cycling, default is `corfu-complete'.
:bind
diff --git a/corfu.el b/corfu.el
index 1670113173..bde82e47cf 100644
--- a/corfu.el
+++ b/corfu.el
@@ -81,9 +81,16 @@ If the variable has the value `insert', the candidate is
automatically
inserted on further input."
:type '(choice boolean (const insert)))
-(defcustom corfu-preselect-first t
- "Preselect first candidate."
- :type 'boolean)
+(defcustom corfu-preselect 'valid
+ "Configure if the prompt or first candidate is preselected.
+- prompt: Always select the prompt.
+- first: Always select the first candidate.
+- valid: Only select the prompt if valid and not equal to the first candidate.
+- directory: Like first, but select the prompt if it is a directory."
+ :type '(choice (const prompt) (const valid) (const first) (const directory)))
+
+(defvar corfu-preselect-first t)
+(make-obsolete-variable 'corfu-preselect-first "Use `corfu-preselect'
instead." "0.34")
(defcustom corfu-separator ?\s
"Component separator character.
@@ -640,12 +647,12 @@ A scroll bar is displayed from LO to LO+BAR."
(corfu--candidates . ,all)
(corfu--total . ,(length all))
(corfu--highlight . ,hl)
- ;; Select the prompt when the input is a valid completion and if it is
not
- ;; equal to the first candidate. This condition prevents jumping to
prompt
- ;; during completion for the full candidate when the incomplete candidate
- ;; is invalid.
- (corfu--preselect . ,(if (or (not corfu-preselect-first) (not all)
- (and (not (equal field (car all)))
+ (corfu--preselect . ,(if (or (eq corfu-preselect 'prompt) (not all)
+ (and completing-file (eq corfu-preselect
'directory)
+ (= (length corfu--base) (length str))
+ (test-completion str table pred))
+ (and (eq corfu-preselect 'valid)
+ (not (equal field (car all)))
(not (and completing-file (equal
(concat field "/") (car all))))
(test-completion str table pred)))
-1 0)))))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [elpa] externals/corfu d524a0c738: Add generalized corfu-preselect user option,
ELPA Syncer <=