From 62c6ca696a5fef23c928fdc889cf3789090dc9be Mon Sep 17 00:00:00 2001 From: liuyinz Date: Tue, 12 Nov 2024 17:48:14 +0800 Subject: [PATCH] fix deprecated warnings of when-let, if-let and and-let --- acm/acm-backend-capf.el | 2 +- acm/acm-quick-access.el | 2 +- acm/acm.el | 4 ++-- lsp-bridge-code-action.el | 2 +- lsp-bridge-diagnostic.el | 8 ++++---- lsp-bridge-ref.el | 2 +- lsp-bridge-semantic-tokens.el | 2 +- lsp-bridge.el | 6 +++--- 8 files changed, 14 insertions(+), 14 deletions(-) diff --git a/acm/acm-backend-capf.el b/acm/acm-backend-capf.el index fac893f65a..45d54a7a04 100644 --- a/acm/acm-backend-capf.el +++ b/acm/acm-backend-capf.el @@ -151,7 +151,7 @@ (initial (buffer-substring-no-properties start end)) (candidates (completion-all-completions initial collection nil (length initial))) prefix) - (when-let ((z (last candidates))) + (when-let* ((z (last candidates))) (setcdr z nil)) ;; Sometime CAPF excludes the prefix from the candidates. ;; Adding it back based on the `keyword' and `initial'. diff --git a/acm/acm-quick-access.el b/acm/acm-quick-access.el index 641c2eebe5..4a77e4bb94 100644 --- a/acm/acm-quick-access.el +++ b/acm/acm-quick-access.el @@ -34,7 +34,7 @@ Enable this option will cause interfering digital insertion sometimes." (defun acm-keymap--quick-access-modifier () "Return string representation of the `acm-quick-access-modifier'." - (if-let ((modifier (assoc-default acm-quick-access-modifier + (if-let* ((modifier (assoc-default acm-quick-access-modifier '((meta . "M") (super . "s") (hyper . "H") diff --git a/acm/acm.el b/acm/acm.el index 22978a1333..68337b66f8 100644 --- a/acm/acm.el +++ b/acm/acm.el @@ -397,7 +397,7 @@ So we use `minor-mode-overriding-map-alist' to override key, make sure all keys (cons (match-beginning 2) (match-end 2)))) ((equal "ascii" acm-input-bound-style) - (when-let ((bound (bounds-of-thing-at-point 'symbol))) + (when-let* ((bound (bounds-of-thing-at-point 'symbol))) (let* ((keyword (buffer-substring-no-properties (car bound) (cdr bound))) (offset (or (string-match "[[:nonascii:]]+" (reverse keyword)) (length keyword)))) @@ -827,7 +827,7 @@ The key of candidate will change between two LSP results." (setq acm-preview-overlay (funcall candidate-expand candidate-info beg t))) (setq acm-preview-overlay (acm-preview-create-overlay beg (point) cand))) ;; adjust pos of menu frame. - (when-let ((popup-pos (acm-frame-get-popup-position + (when-let* ((popup-pos (acm-frame-get-popup-position acm-menu-frame-popup-point (1- (length (split-string (overlay-get acm-preview-overlay 'display) "\n"))))) ((not (eq (cdr popup-pos) (cdr acm-menu-frame-popup-position))))) diff --git a/lsp-bridge-code-action.el b/lsp-bridge-code-action.el index aff76ce8b8..f14151dab6 100644 --- a/lsp-bridge-code-action.el +++ b/lsp-bridge-code-action.el @@ -264,7 +264,7 @@ Please read https://microsoft.github.io/language-server-protocol/specifications/ (diff-no-select lsp-bridge-code-action--current-buffer (current-buffer) nil nil (get-buffer-create "*lsp-bridge-code-action-preview*"))) - (if-let ((proc (get-buffer-process "*lsp-bridge-code-action-preview*"))) + (if-let* ((proc (get-buffer-process "*lsp-bridge-code-action-preview*"))) (set-process-sentinel proc (lambda (proc _msg) (with-current-buffer (process-buffer proc) diff --git a/lsp-bridge-diagnostic.el b/lsp-bridge-diagnostic.el index de78491fc5..f24662467d 100644 --- a/lsp-bridge-diagnostic.el +++ b/lsp-bridge-diagnostic.el @@ -287,7 +287,7 @@ You can set this value with `(2 3 4) if you just need render error diagnostic." (defun lsp-bridge-diagnostic-maybe-display-error-at-point () "Display error message at point with a delay, unless already displayed." (acm-cancel-timer lsp-bridge-diagnostic-display-error-at-point-timer) - (when-let ((ol (lsp-bridge-diagnostic-overlay-at-point))) + (when-let* ((ol (lsp-bridge-diagnostic-overlay-at-point))) (setq lsp-bridge-diagnostic-display-error-at-point-timer (run-at-time lsp-bridge-diagnostic-display-errors-delay nil 'lsp-bridge-diagnostic-show-tooltip ol)))) @@ -303,7 +303,7 @@ You can set this value with `(2 3 4) if you just need render error diagnostic." (interactive) (if (zerop (length lsp-bridge-diagnostic-overlays)) (message "[LSP-Bridge] No diagnostics.") - (if-let ((diagnostic-overlay (cl-find-if + (if-let* ((diagnostic-overlay (cl-find-if (lambda (overlay) (or (< (point) (overlay-start overlay)) ;; Show diagnostic information around cursor if diagnostic frame is not visiable. @@ -316,7 +316,7 @@ You can set this value with `(2 3 4) if you just need render error diagnostic." (interactive) (if (zerop (length lsp-bridge-diagnostic-overlays)) (message "[LSP-Bridge] No diagnostics.") - (if-let ((diagnostic-overlay (cl-find-if + (if-let* ((diagnostic-overlay (cl-find-if (lambda (overlay) (or (> (point) (overlay-end overlay)) ;; Show diagnostic information around cursor if diagnostic frame is not visiable. @@ -336,7 +336,7 @@ You can set this value with `(2 3 4) if you just need render error diagnostic." (interactive) (if (zerop (length lsp-bridge-diagnostic-overlays)) (message "[LSP-Bridge] No diagnostics.") - (when-let ((overlay (lsp-bridge-diagnostic-overlay-at-point))) + (when-let* ((overlay (lsp-bridge-diagnostic-overlay-at-point))) (let ((diagnostic-message (overlay-get overlay 'message))) (kill-new diagnostic-message) (message "Copy diagnostics: '%s'" diagnostic-message))))) diff --git a/lsp-bridge-ref.el b/lsp-bridge-ref.el index c28f61505d..75d6a9b60c 100644 --- a/lsp-bridge-ref.el +++ b/lsp-bridge-ref.el @@ -896,7 +896,7 @@ user more freedom to use rg with special arguments." ;; View the function name when navigate in match line. (when lsp-bridge-ref-show-function-name-p (require 'which-func) - (when-let ((function-name (which-function))) + (when-let* ((function-name (which-function))) (message "[LSP-Bridge] Located in function: %s" (propertize function-name diff --git a/lsp-bridge-semantic-tokens.el b/lsp-bridge-semantic-tokens.el index a16883ee63..4ca66abd78 100644 --- a/lsp-bridge-semantic-tokens.el +++ b/lsp-bridge-semantic-tokens.el @@ -213,7 +213,7 @@ Faces to use for semantic token modifiers.") (defun lsp-bridge-semantic-tokens--delete-overlays (keys) "Delete semantic tokens overlays." (dolist (key keys) - (when-let ((ov (gethash key lsp-bridge-semantic-tokens--overlays))) + (when-let* ((ov (gethash key lsp-bridge-semantic-tokens--overlays))) (delete-overlay ov) (remhash key lsp-bridge-semantic-tokens--overlays)))) diff --git a/lsp-bridge.el b/lsp-bridge.el index 105f59e223..9da4b8aea0 100644 --- a/lsp-bridge.el +++ b/lsp-bridge.el @@ -912,7 +912,7 @@ you can customize `lsp-bridge-get-workspace-folder' to return workspace folder p (cl-defmacro lsp-bridge--with-file-buffer (filename filehost &rest body) "Evaluate BODY in buffer with FILEPATH." (declare (indent 1)) - `(when-let ((buffer (pcase ,filehost + `(when-let* ((buffer (pcase ,filehost ("" (lsp-bridge-get-match-buffer-by-filepath ,filename)) (_ (lsp-bridge-get-match-buffer-by-remote-file ,filehost ,filename))))) (with-current-buffer buffer @@ -2666,9 +2666,9 @@ SymbolKind (defined in the LSP)." filename filehost ;; When lsp-bridge running in server, `acm-backend-lsp-items' maybe nil when receive `lsp-bridge-completion-item--update' response. ;; So we need check `acm-backend-lsp-items' value before update item documentation. - (when-let ((server-lsp-items (gethash server-name acm-backend-lsp-items))) + (when-let* ((server-lsp-items (gethash server-name acm-backend-lsp-items))) ;; Update `documentation' and `additionalTextEdits' - (when-let (item (gethash key server-lsp-items)) + (when-let* ((item (gethash key server-lsp-items))) (when additional-text-edits (plist-put item :additionalTextEdits additional-text-edits))