branch: externals/corfu
commit 4f25ebef82698e2c3506910901935aa91a0d7c80
Author: Daniel Mendler <[email protected]>
Commit: Daniel Mendler <[email protected]>
Use when-let*
---
corfu.el | 14 +++++++-------
extensions/corfu-echo.el | 16 ++++++++--------
extensions/corfu-history.el | 2 +-
extensions/corfu-info.el | 14 +++++++-------
extensions/corfu-popupinfo.el | 40 ++++++++++++++++++++--------------------
5 files changed, 43 insertions(+), 43 deletions(-)
diff --git a/corfu.el b/corfu.el
index 3a2d80ec6b..814ae39fc5 100644
--- a/corfu.el
+++ b/corfu.el
@@ -473,8 +473,8 @@ is a prefix length override, which is t for manual
completion."
(defun corfu--make-frame (frame x y width height)
"Show current buffer in child frame at X/Y with WIDTH/HEIGHT.
FRAME is the existing frame."
- (when-let (((frame-live-p frame))
- (timer (frame-parameter frame 'corfu--hide-timer)))
+ (when-let* (((frame-live-p frame))
+ (timer (frame-parameter frame 'corfu--hide-timer)))
(cancel-timer timer)
(set-frame-parameter frame 'corfu--hide-timer nil))
(let* ((window-min-height 1)
@@ -690,7 +690,7 @@ FRAME is the existing frame."
(field (substring str (car bounds) (+ pt (cdr bounds))))
(completing-file (eq (corfu--metadata-get 'category) 'file))
(`(,all . ,hl) (corfu--filter-completions str table pred pt
corfu--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))
(corfu--base (substring str 0 base))
(pre nil))
;; Filter the ignored file extensions. We cannot use modified predicate for
@@ -934,7 +934,7 @@ the stack trace is shown in the *Messages* buffer."
(defun corfu--exit-function (str status cands)
"Call the `:exit-function' with STR and STATUS.
Lookup STR in CANDS to restore text properties."
- (when-let ((exit (plist-get completion-extra-properties :exit-function)))
+ (when-let* ((exit (plist-get completion-extra-properties :exit-function)))
(funcall exit (or (car (member str cands)) str) status)))
(defun corfu--done (str status cands)
@@ -1064,7 +1064,7 @@ See `completion-in-region' for the arguments BEG, END,
TABLE, PRED."
(`(,fun ,beg ,end ,table . ,plist)
(let ((completion-in-region-mode-predicate
(lambda ()
- (when-let ((newbeg (car-safe (funcall fun))))
+ (when-let* ((newbeg (car-safe (funcall fun))))
(= newbeg beg))))
(completion-extra-properties plist))
(corfu--setup beg end table (plist-get plist :predicate))
@@ -1201,9 +1201,9 @@ A scroll bar is displayed from LO to LO+BAR."
(mf (let ((completion-extra-properties (nth 4
completion-in-region--data)))
(run-hook-with-args-until-success 'corfu-margin-formatters
corfu--metadata))))
(setq cands
- (if-let ((aff (corfu--metadata-get 'affixation-function)))
+ (if-let* ((aff (corfu--metadata-get 'affixation-function)))
(funcall aff cands)
- (if-let ((ann (corfu--metadata-get 'annotation-function)))
+ (if-let* ((ann (corfu--metadata-get 'annotation-function)))
(cl-loop for cand in cands collect
(let ((suff (or (funcall ann cand) "")))
;; The default completion UI adds the
diff --git a/extensions/corfu-echo.el b/extensions/corfu-echo.el
index 1da0155ee6..184b1c0d79 100644
--- a/extensions/corfu-echo.el
+++ b/extensions/corfu-echo.el
@@ -81,14 +81,14 @@ subsequent delay."
:global t :group 'corfu)
(cl-defmethod corfu--exhibit :after (&context (corfu-echo-mode (eql t))
&optional _auto)
- (if-let (((not (minibufferp)))
- (delay (if (consp corfu-echo-delay)
- (funcall (if corfu-echo--message #'cdr #'car)
- corfu-echo-delay)
- corfu-echo-delay))
- (fun (corfu--metadata-get 'company-docsig))
- (cand (and (>= corfu--index 0)
- (nth corfu--index corfu--candidates))))
+ (if-let* (((not (minibufferp)))
+ (delay (if (consp corfu-echo-delay)
+ (funcall (if corfu-echo--message #'cdr #'car)
+ corfu-echo-delay)
+ corfu-echo-delay))
+ (fun (corfu--metadata-get 'company-docsig))
+ (cand (and (>= corfu--index 0)
+ (nth corfu--index corfu--candidates))))
(if (<= delay 0)
(corfu-echo--show (funcall fun cand))
(corfu-echo--cancel)
diff --git a/extensions/corfu-history.el b/extensions/corfu-history.el
index 39f33335ed..23df137094 100644
--- a/extensions/corfu-history.el
+++ b/extensions/corfu-history.el
@@ -77,7 +77,7 @@ The shift will decay away after `corfu-history-duplicate'
times
(let ((ht (make-hash-table :test #'equal :size (length corfu-history)))
(decay (/ -1.0 (* corfu-history-duplicate corfu-history-decay))))
(cl-loop for elem in corfu-history for idx from 0
- for r = (if-let ((r (gethash elem ht)))
+ for r = (if-let* ((r (gethash elem ht)))
;; Reduce duplicate rank with exponential decay.
(- r (round (* corfu-history-duplicate (exp (*
decay idx)))))
;; Never outrank the most recent element.
diff --git a/extensions/corfu-info.el b/extensions/corfu-info.el
index f2dba3a647..8aafdb9a7a 100644
--- a/extensions/corfu-info.el
+++ b/extensions/corfu-info.el
@@ -58,7 +58,7 @@
Make the buffer persistent with NAME if non-nil."
(if name
(unless (buffer-local-value 'buffer-file-name buffer)
- (if-let ((old (get-buffer name)))
+ (if-let* ((old (get-buffer name)))
(setq buffer (prog1 old (kill-buffer buffer)))
(with-current-buffer buffer
(rename-buffer name))))
@@ -78,8 +78,8 @@ If called with a prefix ARG, the buffer is persistent."
(cand-str (substring-no-properties cand))
((symbol-function #'help-buffer) ;; Work around bug#79792
(lambda () (get-buffer-create " *corfu-info*"))))
- (if-let ((fun (corfu--metadata-get 'company-doc-buffer))
- (res (funcall fun cand)))
+ (if-let* ((fun (corfu--metadata-get 'company-doc-buffer))
+ (res (funcall fun cand)))
(set-window-start (corfu-info--display-buffer
(get-buffer (or (car-safe res) res))
(and arg (format "*corfu info: %s*" cand-str)))
@@ -96,9 +96,9 @@ If called with a prefix ARG, the buffer is persistent."
(user-error "No candidate selected"))
(let* ((cand (nth corfu--index corfu--candidates))
(cand-str (substring-no-properties cand)))
- (if-let ((fun (corfu--metadata-get 'company-location))
- ;; BUG: company-location may throw errors if location is not found
- (loc (ignore-errors (funcall fun cand))))
+ (if-let* ((fun (corfu--metadata-get 'company-location))
+ ;; BUG: company-location may throw errors if location is not
found
+ (loc (ignore-errors (funcall fun cand))))
(with-selected-window
(corfu-info--display-buffer
(or (and (bufferp (car loc)) (car loc))
@@ -106,7 +106,7 @@ If called with a prefix ARG, the buffer is persistent."
(and arg (format "*corfu loc: %s*" cand-str)))
(without-restriction
(goto-char (point-min))
- (when-let ((pos (cdr loc)))
+ (when-let* ((pos (cdr loc)))
(if (bufferp (car loc))
(goto-char pos)
(forward-line (1- pos))))
diff --git a/extensions/corfu-popupinfo.el b/extensions/corfu-popupinfo.el
index 7b3b2f2c42..c45e24c07f 100644
--- a/extensions/corfu-popupinfo.el
+++ b/extensions/corfu-popupinfo.el
@@ -211,7 +211,7 @@ all values are in pixels relative to the origin. See
(save-excursion
(without-restriction
(goto-char (point-min))
- (when-let ((pos (cdr loc)))
+ (when-let* ((pos (cdr loc)))
(if (bufferp (car loc))
(goto-char pos)
(forward-line (1- pos))))
@@ -227,18 +227,18 @@ all values are in pixels relative to the origin. See
(defun corfu-popupinfo--get-documentation (candidate)
"Get the documentation for CANDIDATE."
- (when-let ((fun (corfu--metadata-get 'company-doc-buffer))
- (res (save-excursion
- (cl-letf (((symbol-function #'help-buffer) ;; Work around
bug#79792
- (lambda () (get-buffer-create " *corfu-info*")))
- (inhibit-message t)
- (message-log-max nil)
- (inhibit-redisplay t)
- ;; Reduce print length for elisp backend (#249)
- (print-level 3)
- (print-length (* corfu-popupinfo-max-width
- corfu-popupinfo-max-height)))
- (funcall fun candidate)))))
+ (when-let* ((fun (corfu--metadata-get 'company-doc-buffer))
+ (res (save-excursion
+ (cl-letf (((symbol-function #'help-buffer) ;; Work around
bug#79792
+ (lambda () (get-buffer-create "
*corfu-info*")))
+ (inhibit-message t)
+ (message-log-max nil)
+ (inhibit-redisplay t)
+ ;; Reduce print length for elisp backend (#249)
+ (print-level 3)
+ (print-length (* corfu-popupinfo-max-width
+ corfu-popupinfo-max-height)))
+ (funcall fun candidate)))))
(with-current-buffer (or (car-safe res) res)
(setq res (string-trim
(replace-regexp-in-string
@@ -366,7 +366,7 @@ form (X Y WIDTH HEIGHT DIR)."
(new-coords (frame-edges corfu--frame 'inner-edges))
(coords-changed (not (equal new-coords
corfu-popupinfo--coordinates))))
(when cand-changed
- (if-let ((content (funcall corfu-popupinfo--function candidate)))
+ (if-let* ((content (funcall corfu-popupinfo--function candidate)))
(with-current-buffer (corfu--make-buffer corfu-popupinfo--buffer)
(with-silent-modifications
(erase-buffer)
@@ -376,7 +376,7 @@ form (X Y WIDTH HEIGHT DIR)."
(set (make-local-variable (car var)) (cdr var)))
(setq left-margin-width corfu-popupinfo-margin-width
right-margin-width corfu-popupinfo-margin-width)
- (when-let ((m (memq 'corfu-default (alist-get 'default
face-remapping-alist))))
+ (when-let* ((m (memq 'corfu-default (alist-get 'default
face-remapping-alist))))
(setcar m 'corfu-popupinfo)))
(corfu-popupinfo--hide)
(setq cand-changed nil coords-changed nil)))
@@ -502,11 +502,11 @@ not be displayed until this command is called again, even
if
(setq corfu-popupinfo--timer nil))
(if (and (>= corfu--index 0) (corfu-popupinfo--visible-p corfu--frame))
(let ((cand (nth corfu--index corfu--candidates)))
- (if-let ((delay (if (consp corfu-popupinfo-delay)
- (funcall (if (eq corfu-popupinfo--toggle 'init)
#'car #'cdr)
- corfu-popupinfo-delay)
- corfu-popupinfo-delay))
- (corfu-popupinfo--toggle))
+ (if-let* ((delay (if (consp corfu-popupinfo-delay)
+ (funcall (if (eq corfu-popupinfo--toggle 'init)
#'car #'cdr)
+ corfu-popupinfo-delay)
+ corfu-popupinfo-delay))
+ (corfu-popupinfo--toggle))
(progn
(when (and (corfu-popupinfo--visible-p) (> delay 0))
(cond