Skip to content

Commit

Permalink
fix deprecated warnings of when-let, if-let and and-let
Browse files Browse the repository at this point in the history
  • Loading branch information
liuyinz committed Nov 12, 2024
1 parent 649931a commit 62c6ca6
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion acm/acm-backend-capf.el
Original file line number Diff line number Diff line change
Expand Up @@ -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'.
Expand Down
2 changes: 1 addition & 1 deletion acm/acm-quick-access.el
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
4 changes: 2 additions & 2 deletions acm/acm.el
Original file line number Diff line number Diff line change
Expand Up @@ -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))))
Expand Down Expand Up @@ -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)))))
Expand Down
2 changes: 1 addition & 1 deletion lsp-bridge-code-action.el
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions lsp-bridge-diagnostic.el
Original file line number Diff line number Diff line change
Expand Up @@ -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))))
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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)))))
Expand Down
2 changes: 1 addition & 1 deletion lsp-bridge-ref.el
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lsp-bridge-semantic-tokens.el
Original file line number Diff line number Diff line change
Expand Up @@ -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))))

Expand Down
6 changes: 3 additions & 3 deletions lsp-bridge.el
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))

Expand Down

0 comments on commit 62c6ca6

Please sign in to comment.