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

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

[elpa] externals/vertico 819adf8: Add vertico-cycle (Fix #26)


From: Protesilaos Stavrou
Subject: [elpa] externals/vertico 819adf8: Add vertico-cycle (Fix #26)
Date: Wed, 5 May 2021 15:17:12 -0400 (EDT)

branch: externals/vertico
commit 819adf8ab99644ac59e4f6e03a2361602b8dbc02
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>

    Add vertico-cycle (Fix #26)
    
    * Enables cycling for vertico-previous/next
    * This aligns Vertico with Corfu
---
 vertico.el | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/vertico.el b/vertico.el
index 9126455..2e27c1f 100644
--- a/vertico.el
+++ b/vertico.el
@@ -60,6 +60,10 @@
   "Maximal number of candidates to show."
   :type 'integer)
 
+(defcustom vertico-cycle nil
+  "Enable cycling for `vertico-next' and `vertico-previous'."
+  :type 'boolean)
+
 (defcustom vertico-multiline
   (cons #("⤶" 0 1 (face vertico-multiline))
         #("…" 0 1 (face vertico-multiline)))
@@ -497,12 +501,18 @@
 (defun vertico-next ()
   "Go to next candidate."
   (interactive)
-  (vertico--goto (1+ vertico--index)))
+  (vertico--goto
+   (if (and vertico-cycle (= (1+ vertico--index) vertico--total))
+       -1
+     (1+ vertico--index))))
 
 (defun vertico-previous ()
   "Go to previous candidate."
   (interactive)
-  (vertico--goto (- vertico--index 1)))
+  (vertico--goto
+   (if (and vertico-cycle (= vertico--index (if 
(vertico--allow-prompt-selection-p) -1 0)))
+       (- vertico--total 1)
+     (- vertico--index 1))))
 
 (defun vertico-exit (&optional arg)
   "Exit minibuffer with current candidate or input if prefix ARG is given."



reply via email to

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