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

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

[elpa] externals/vertico 49a1eb5f36: Uniform use of when-let/if-let


From: ELPA Syncer
Subject: [elpa] externals/vertico 49a1eb5f36: Uniform use of when-let/if-let
Date: Sun, 12 Nov 2023 03:58:49 -0500 (EST)

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

    Uniform use of when-let/if-let
---
 extensions/vertico-buffer.el  |  2 +-
 extensions/vertico-flat.el    |  4 ++--
 extensions/vertico-grid.el    |  4 ++--
 extensions/vertico-reverse.el |  2 +-
 vertico.el                    | 44 +++++++++++++++++++++----------------------
 5 files changed, 27 insertions(+), 29 deletions(-)

diff --git a/extensions/vertico-buffer.el b/extensions/vertico-buffer.el
index 0029eab4c8..1497ce2cd2 100644
--- a/extensions/vertico-buffer.el
+++ b/extensions/vertico-buffer.el
@@ -87,7 +87,7 @@
 
 (defun vertico-buffer--redisplay (win)
   "Redisplay window WIN."
-  (when-let (mbwin (active-minibuffer-window))
+  (when-let ((mbwin (active-minibuffer-window)))
     (when (eq (window-buffer mbwin) (current-buffer))
       (unless (eq win mbwin)
         (setq-local truncate-lines (< (window-point win)
diff --git a/extensions/vertico-flat.el b/extensions/vertico-flat.el
index 6c7d18eee8..940e46a2b6 100644
--- a/extensions/vertico-flat.el
+++ b/extensions/vertico-flat.el
@@ -75,7 +75,7 @@
   "Flat, horizontal display for Vertico."
   :global t :group 'vertico
   ;; Shrink current minibuffer window
-  (when-let (win (active-minibuffer-window))
+  (when-let ((win (active-minibuffer-window)))
     (unless (frame-root-window-p win)
       (window-resize win (- (window-pixel-height win)) nil nil 'pixelwise)))
   (setq minor-mode-map-alist (rassq-delete-all vertico-flat-map 
minor-mode-map-alist))
@@ -92,7 +92,7 @@
            (cond
             ((and (not candidates) (plist-get vertico-flat-format :no-match)))
             ((and (= vertico--total 1) (= vertico--index 0)
-                  (when-let (fmt (plist-get vertico-flat-format :single))
+                  (when-let ((fmt (plist-get vertico-flat-format :single)))
                     (format fmt (substring-no-properties (car candidates))))))
             (t (format (plist-get vertico-flat-format (if (< vertico--index 0) 
:prompt :multiple))
                        (string-join candidates (plist-get vertico-flat-format 
:separator))))))))
diff --git a/extensions/vertico-grid.el b/extensions/vertico-grid.el
index 300486fe81..e1e3b49875 100644
--- a/extensions/vertico-grid.el
+++ b/extensions/vertico-grid.el
@@ -109,7 +109,7 @@ When scrolling beyond this limit, candidates may be 
truncated."
   "Grid display for Vertico."
   :global t :group 'vertico
   ;; Shrink current minibuffer window
-  (when-let (win (active-minibuffer-window))
+  (when-let ((win (active-minibuffer-window)))
     (unless (frame-root-window-p win)
       (window-resize win (- (window-pixel-height win)) nil nil 'pixelwise)))
   (setq minor-mode-map-alist (rassq-delete-all vertico-grid-map 
minor-mode-map-alist))
@@ -157,7 +157,7 @@ When scrolling beyond this limit, candidates may be 
truncated."
     (cl-loop for row from 0 to (1- (min vertico-count vertico--total)) collect
              (let ((line (list "\n")))
                (cl-loop for col from (1- vertico-grid--columns) downto 0 do
-                        (when-let (cand (nth (+ row (* col vertico-count)) 
cands))
+                        (when-let ((cand (nth (+ row (* col vertico-count)) 
cands)))
                           (push cand line)
                           (when (> col 0)
                             (push vertico-grid-separator line)
diff --git a/extensions/vertico-reverse.el b/extensions/vertico-reverse.el
index c3aa0fd5cd..35a10e0b2d 100644
--- a/extensions/vertico-reverse.el
+++ b/extensions/vertico-reverse.el
@@ -58,7 +58,7 @@
   :global t :group 'vertico
   ;; Reset overlays
   (dolist (buf (buffer-list))
-    (when-let (ov (buffer-local-value 'vertico--candidates-ov buf))
+    (when-let ((ov (buffer-local-value 'vertico--candidates-ov buf)))
       (overlay-put ov 'before-string nil)))
   (setq minor-mode-map-alist (rassq-delete-all vertico-reverse-map 
minor-mode-map-alist))
   (when vertico-reverse-mode
diff --git a/vertico.el b/vertico.el
index a89d73d37c..2e73ebf2f2 100644
--- a/vertico.el
+++ b/vertico.el
@@ -6,7 +6,7 @@
 ;; Maintainer: Daniel Mendler <mail@daniel-mendler.de>
 ;; Created: 2021
 ;; Version: 1.4
-;; Package-Requires: ((emacs "27.1") (compat "29.1.4.0"))
+;; Package-Requires: ((emacs "27.1") (compat "29.1.4.3"))
 ;; Homepage: https://github.com/minad/vertico
 ;; Keywords: convenience, files, matching, completion
 
@@ -233,7 +233,7 @@ The function is configured by BY, BSIZE, BINDEX, BPRED and 
PRED."
        (dolist (% candidates)
          ;; Find recent candidate in history or fill bucket
          (,@(if (not (eq (car by) 'history)) `(progn)
-              `(if-let (idx (gethash % hhash)) (push (cons idx %) hcands)))
+              `(if-let ((idx (gethash % hhash))) (push (cons idx %) hcands)))
           (let ((idx (min ,(1- bsize) ,bindex)))
             (aset buckets idx (cons % (aref buckets idx))))))
        (nconc ,@(and (eq (car by) 'history) '((vertico--sort-decorated 
hcands)))
@@ -249,11 +249,11 @@ The function is configured by BY, BSIZE, BINDEX, BPRED 
and PRED."
 
 (defun vertico--affixate (cands)
   "Annotate CANDS with annotation function."
-  (if-let (aff (or (vertico--metadata-get 'affixation-function)
-                   (plist-get completion-extra-properties 
:affixation-function)))
+  (if-let ((aff (or (vertico--metadata-get 'affixation-function)
+                    (plist-get completion-extra-properties 
:affixation-function))))
       (funcall aff cands)
-    (if-let (ann (or (vertico--metadata-get 'annotation-function)
-                     (plist-get completion-extra-properties 
:annotation-function)))
+    (if-let ((ann (or (vertico--metadata-get 'annotation-function)
+                      (plist-get completion-extra-properties 
:annotation-function))))
         (cl-loop for cand in cands collect
                  (let ((suffix (or (funcall ann cand) "")))
                    ;; The default completion UI adds the 
`completions-annotations'
@@ -265,7 +265,7 @@ The function is configured by BY, BSIZE, BINDEX, BPRED and 
PRED."
 
 (defun vertico--move-to-front (elem list)
   "Move ELEM to front of LIST."
-  (if-let (found (member elem list))
+  (if-let ((found (member elem list)))
       (nconc (list (car found)) (delq (setcar found nil) list))
     list))
 
@@ -328,7 +328,7 @@ The function is configured by BY, BSIZE, BINDEX, BPRED and 
PRED."
                ;; `minibuffer-completing-file-name' has been obsoleted by the 
completion category
                (completing-file (eq 'file (vertico--metadata-get 'category)))
                (`(,all . ,hl) (vertico--filter-completions content table pred 
pt vertico--metadata))
-               (base (or (when-let (z (last all)) (prog1 (cdr z) (setcdr z 
nil))) 0))
+               (base (or (when-let ((z (last all))) (prog1 (cdr z) (setcdr z 
nil))) 0))
                (vertico--base (substring content 0 base))
                (def (or (car-safe minibuffer-default) minibuffer-default))
                (groups) (def-missing) (lock))
@@ -344,8 +344,8 @@ The function is configured by BY, BSIZE, BINDEX, BPRED and 
PRED."
     (when (and completing-file (not (string-suffix-p "/" field)))
       (setq all (vertico--move-to-front (concat field "/") all)))
     (setq all (vertico--move-to-front field all))
-    (when-let (group-fun (and all (vertico--metadata-get 'group-function)))
-      (setq groups (vertico--group-by group-fun all) all (car groups)))
+    (when-let ((fun (and all (vertico--metadata-get 'group-function))))
+      (setq groups (vertico--group-by fun all) all (car groups)))
     (setq def-missing (and def (equal content "") (not (member def all)))
           lock (and vertico--lock-candidate ;; Locked position of old 
candidate.
                     (if (< vertico--index 0) -1
@@ -376,19 +376,17 @@ The function is configured by BY, BSIZE, BINDEX, BPRED 
and PRED."
   "Group ELEMS by FUN."
   (let ((ht (make-hash-table :test #'equal)) titles groups)
     ;; Build hash table of groups
-    (while elems
-      (let* ((title (funcall fun (car elems) nil))
-             (group (gethash title ht)))
-        (if group
-            (setcdr group (setcdr (cdr group) elems)) ;; Append to tail of 
group
-          (puthash title (cons elems elems) ht) ;; New group element (head . 
tail)
-          (push title titles))
-        (pop elems)))
+    (cl-loop for elem on elems
+             for title = (funcall fun (car elem) nil) do
+             (if-let ((group (gethash title ht)))
+                 (setcdr group (setcdr (cdr group) elem)) ;; Append to tail of 
group
+               (puthash title (cons elem elem) ht) ;; New group element (head 
. tail)
+               (push title titles)))
     (setq titles (nreverse titles))
     ;; Cycle groups if `vertico--lock-groups' is set
-    (when-let (group (and vertico--lock-groups
-                          (seq-find (lambda (group) (gethash group ht))
-                                    vertico--all-groups)))
+    (when-let ((vertico--lock-groups)
+               (group (seq-find (lambda (group) (gethash group ht))
+                                vertico--all-groups)))
       (setq titles (vertico--cycle titles (seq-position titles group))))
     ;; Build group list
     (dolist (title titles)
@@ -515,7 +513,7 @@ The function is configured by BY, BSIZE, BINDEX, BPRED and 
PRED."
   "Remove FACE between BEG and END from OBJ."
   (while (< beg end)
     (let ((next (next-single-property-change beg 'face obj end)))
-      (when-let (val (get-text-property beg 'face obj))
+      (when-let ((val (get-text-property beg 'face obj)))
         (put-text-property beg next 'face (remq face (ensure-list val)) obj))
       (setq beg next))))
 
@@ -577,7 +575,7 @@ The function is configured by BY, BSIZE, BINDEX, BPRED and 
PRED."
              (cl-loop repeat vertico-count for c in (nthcdr index 
vertico--candidates)
                       collect (funcall vertico--hilit (substring c))))))
       (pcase-dolist ((and cand `(,str . ,_)) candidates)
-        (when-let (new-title (and group-fun (funcall group-fun str nil)))
+        (when-let ((new-title (and group-fun (funcall group-fun str nil))))
           (unless (equal title new-title)
             (setq title new-title)
             (push (vertico--format-group-title title str) lines))



reply via email to

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