Skip to content

Commit

Permalink
Make selectrum-move-default-candidate public
Browse files Browse the repository at this point in the history
  • Loading branch information
clemera committed Feb 15, 2021
1 parent b3eb993 commit a8b6617
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions selectrum.el
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,11 @@ function and BODY opens the minibuffer."
map)
"Keymap used by Selectrum in the minibuffer.")

(defvar-local selectrum-move-default-candidate nil
"Non-nil means move default candidate to start of list.
Nil means select the default candidate initially even if it's not
at the start of the list.")

(defvar selectrum--candidates-buffer " *selectrum*"
"Buffer to display candidates using `selectrum-display-action'.")

Expand Down Expand Up @@ -560,11 +565,6 @@ input that does not match any of the displayed candidates.")
(defvar-local selectrum--crm-p nil
"Non-nil for `selectrum-completing-read-multiple' sessions.")

(defvar-local selectrum--move-default-candidate-p nil
"Non-nil means move default candidate to start of list.
Nil means select the default candidate initially even if it's not
at the start of the list.")

(defvar-local selectrum--default-candidate nil
"Default candidate, or nil if none given.")

Expand Down Expand Up @@ -1157,7 +1157,8 @@ the update."
'face 'shadow)
selectrum--refined-candidates))
(setq-local selectrum--virtual-default-file nil))
(when (and selectrum--move-default-candidate-p
(when (and (or selectrum-move-default-candidate
(bound-and-true-p selectrum--move-default-candidate-p))
selectrum--default-candidate)
(setq-local selectrum--refined-candidates
(selectrum--move-to-front-destructive
Expand Down Expand Up @@ -1216,7 +1217,9 @@ the update."
(or (not selectrum--match-required-p)
(selectrum--at-existing-prompt-path-p))))
-1)
(selectrum--move-default-candidate-p
((or selectrum-move-default-candidate
(bound-and-true-p
selectrum--move-default-candidate-p))
0)
(t
(or (cl-position selectrum--default-candidate
Expand Down Expand Up @@ -2138,7 +2141,7 @@ semantics of `cl-defun'."
(cl-list* prompt candidates args))
(setq-local selectrum--match-required-p
require-match)
(setq-local selectrum--move-default-candidate-p
(setq-local selectrum-move-default-candidate
(not no-move-default-candidate))
(selectrum--minibuffer-setup-hook
candidates
Expand Down

0 comments on commit a8b6617

Please sign in to comment.