emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/corfu 085eb192da: Use the cycle-sort-function when cycl


From: ELPA Syncer
Subject: [elpa] externals/corfu 085eb192da: Use the cycle-sort-function when cycling (Fix #113)
Date: Sun, 30 Jan 2022 17:57:30 -0500 (EST)

branch: externals/corfu
commit 085eb192da194f90ebfa6b9e405fe8f459bd2205
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>

    Use the cycle-sort-function when cycling (Fix #113)
---
 corfu.el | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/corfu.el b/corfu.el
index 871b06f2a6..51f718666a 100644
--- a/corfu.el
+++ b/corfu.el
@@ -562,12 +562,14 @@ A scroll bar is displayed from LO to LO+BAR."
                     "\\)\\'")))
     (or (seq-remove (lambda (x) (string-match-p re x)) files) files)))
 
-(defun corfu--sort-function ()
-  "Return the sorting function."
-  (or (corfu--metadata-get 'display-sort-function) corfu-sort-function))
-
-(defun corfu--recompute-candidates (str pt table pred)
-  "Recompute candidates from STR, PT, TABLE and PRED."
+(defun corfu--sort-function (cycle)
+  "Return the (CYCLE or display) sort function."
+  (or (corfu--metadata-get (if cycle 'cycle-sort-function 
'display-sort-function))
+      corfu-sort-function))
+
+(defun corfu--recompute-candidates (str pt table pred cycle)
+  "Recompute candidates from STR, PT, TABLE and PRED.
+Either use the CYCLE or the display sort function."
   (pcase-let* ((before (substring str 0 pt))
                (after (substring str pt))
                (corfu--metadata (completion-metadata before table pred))
@@ -585,8 +587,9 @@ A scroll bar is displayed from LO to LO+BAR."
     ;; since this breaks the special casing in the 
`completion-file-name-table' for `file-exists-p'
     ;; and `file-directory-p'.
     (when completing-file (setq all (corfu--filter-files all)))
-    (setq all (delete-consecutive-dups (funcall (or (corfu--sort-function) 
#'identity) all)))
-    (setq all (corfu--move-prefix-candidates-to-front field all))
+    (setq all (funcall (or (corfu--sort-function cycle) #'identity) all)
+          all (delete-consecutive-dups all)
+          all (corfu--move-prefix-candidates-to-front field all))
     (when (and completing-file (not (string-suffix-p "/" field)))
       (setq all (corfu--move-to-front (concat field "/") all)))
     (setq all (corfu--move-to-front field all))
@@ -605,7 +608,7 @@ A scroll bar is displayed from LO to LO+BAR."
   ;; expensive candidate recomputation is performed (Issue #48). See also
   ;; corresponding vertico#89.
   (redisplay)
-  (pcase (while-no-input (corfu--recompute-candidates str pt table pred))
+  (pcase (while-no-input (corfu--recompute-candidates str pt table pred nil))
     ('nil (keyboard-quit))
     (`(,base ,candidates ,total ,hl ,metadata ,preselect)
      (setq corfu--input (cons str pt)
@@ -1072,7 +1075,7 @@ See `completion-in-region' for the arguments BEG, END, 
TABLE, PRED."
          t)
         (`(,newstr . ,newpt)
          (pcase-let ((`(,base ,candidates ,total . ,_)
-                      (corfu--recompute-candidates str pt table pred)))
+                      (corfu--recompute-candidates str pt table pred 'cycle)))
            (setq beg (copy-marker beg)
                  end (copy-marker end t)
                  completion-in-region--data (list beg end table pred))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]