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

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

[elpa] externals/vertico 180f54d 5/5: Ensure that vertico-quick and vert


From: ELPA Syncer
Subject: [elpa] externals/vertico 180f54d 5/5: Ensure that vertico-quick and vertico-flat are compatible
Date: Sat, 10 Jul 2021 16:57:17 -0400 (EDT)

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

    Ensure that vertico-quick and vertico-flat are compatible
---
 extensions/vertico-quick.el | 46 +++++++++++++++++++++++----------------------
 1 file changed, 24 insertions(+), 22 deletions(-)

diff --git a/extensions/vertico-quick.el b/extensions/vertico-quick.el
index 69dce8b..e75e1fe 100644
--- a/extensions/vertico-quick.el
+++ b/extensions/vertico-quick.el
@@ -64,28 +64,30 @@
   (let* ((fst (length vertico-quick1))
          (snd (length vertico-quick2))
          (len (+ fst snd))
-         (idx (- index start)))
-    (funcall orig cand
-             (concat
-              (if (>= idx fst)
-                  (let ((first (elt vertico-quick2 (mod (/ (- idx fst) len) 
snd)))
-                        (second (elt (concat vertico-quick1 vertico-quick2) 
(mod (- idx fst) len))))
-                    (push (cons first t) vertico-quick--list)
-                    (push (cons (+ first (lsh second 16)) index) 
vertico-quick--list)
-                    (cond
-                     ((eq first vertico-quick--first)
-                      (concat " " (propertize (char-to-string second) 'face 
'vertico-quick1)))
-                     (vertico-quick--first "  ")
-                     (t
-                      (concat (propertize (char-to-string first) 'face 
'vertico-quick1)
-                              (propertize (char-to-string second) 'face 
'vertico-quick2)))))
-                (let ((first (elt vertico-quick1 (mod idx fst))))
-                  (push (cons first index) vertico-quick--list)
-                  (if vertico-quick--first
-                      "  "
-                    (concat (propertize (char-to-string first) 'face 
'vertico-quick1) " "))))
-              (make-string (max 1 (- (length prefix) 2)) ?\s))
-             suffix index start)))
+         (idx (- index start))
+         (keys (if (>= idx fst)
+                   (let ((first (elt vertico-quick2 (mod (/ (- idx fst) len) 
snd)))
+                         (second (elt (concat vertico-quick1 vertico-quick2) 
(mod (- idx fst) len))))
+                     (push (cons first t) vertico-quick--list)
+                     (push (cons (+ first (lsh second 16)) index) 
vertico-quick--list)
+                     (cond
+                      ((eq first vertico-quick--first)
+                       (concat " " (propertize (char-to-string second) 'face 
'vertico-quick1)))
+                      (vertico-quick--first "  ")
+                      (t
+                       (concat (propertize (char-to-string first) 'face 
'vertico-quick1)
+                               (propertize (char-to-string second) 'face 
'vertico-quick2)))))
+                 (let ((first (elt vertico-quick1 (mod idx fst))))
+                   (push (cons first index) vertico-quick--list)
+                   (if vertico-quick--first
+                       "  "
+                     (concat (propertize (char-to-string first) 'face 
'vertico-quick1) " "))))))
+    (if (bound-and-true-p vertico-flat-mode)
+        (setq keys (replace-regexp-in-string " " "" keys)
+              cand (string-trim cand)
+              cand (substring cand (min (length cand) (length keys))))
+      (setq keys (concat keys (make-string (max 1 (- (length prefix) 2)) 
?\s))))
+    (funcall orig cand keys suffix index start)))
 
 ;;;###autoload
 (defun vertico-quick-jump ()



reply via email to

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