branch: elpa/magit
commit 8b6ac3253f68a01aadd2871832c51e6d294ae808
Author: Jonas Bernoulli <[email protected]>
Commit: Jonas Bernoulli <[email protected]>
Use _ in all non-binding entries in the varlist of COND-let forms
This was not done until now because doing so resulted in a warning
because the macro expansion did not actually leave any variables
unused. This was fixed in Emacs 30.1 and I've added a backport to
Transient, which this package can also take advantage of.
Without consistently using `_' one would always have to count parens
to be sure whether a member of the varlist does or does not bind a
variable. It is very easy to make mistake when writing or reading
such forms, if `_' is not consistently used in the non-binding cases.
---
lisp/git-commit.el | 4 ++--
lisp/magit-base.el | 4 ++--
lisp/magit-blame.el | 5 +++--
lisp/magit-branch.el | 2 +-
lisp/magit-diff.el | 12 ++++++------
lisp/magit-git.el | 14 +++++++-------
lisp/magit-log.el | 12 ++++++------
lisp/magit-mode.el | 4 ++--
lisp/magit-process.el | 2 +-
lisp/magit-refs.el | 6 +++---
lisp/magit-section.el | 4 ++--
lisp/magit-sequence.el | 2 +-
lisp/magit-status.el | 4 ++--
lisp/magit-submodule.el | 6 +++---
lisp/magit-wip.el | 2 +-
15 files changed, 42 insertions(+), 41 deletions(-)
diff --git a/lisp/git-commit.el b/lisp/git-commit.el
index 140e058d572..6494e413327 100644
--- a/lisp/git-commit.el
+++ b/lisp/git-commit.el
@@ -502,7 +502,7 @@ the redundant bindings, then set this to nil, before loading
(not (file-accessible-directory-p
(file-name-directory buffer-file-name)))
(magit-expand-git-file-name (substring buffer-file-name 2))))
- ((file-accessible-directory-p (file-name-directory file)))
+ (_(file-accessible-directory-p (file-name-directory file)))
(inhibit-read-only t))
(insert-file-contents file t)
t))
@@ -748,7 +748,7 @@ With a numeric prefix ARG, go back ARG messages."
;; non-empty and newly written comment, because otherwise
;; it would be irreversibly lost.
(when-let* ((message (git-commit-buffer-message))
- ((not (ring-member log-edit-comment-ring message))))
+ (_(not (ring-member log-edit-comment-ring message))))
(ring-insert log-edit-comment-ring message)
(cl-incf arg)
(setq len (ring-length log-edit-comment-ring)))
diff --git a/lisp/magit-base.el b/lisp/magit-base.el
index f14b8f9c038..cce9ded1422 100644
--- a/lisp/magit-base.el
+++ b/lisp/magit-base.el
@@ -595,7 +595,7 @@ acts similarly to `completing-read', except for the
following:
`minibuffer-default-prompt-format' and depending on
`magit-completing-read-default-prompt-predicate'."
(setq magit-completing-read--silent-default nil)
- (if-let ((def)
+ (if-let ((_ def)
(dwim (seq-some (pcase-lambda (`(,cmd ,re ,dwim))
(and (eq cmd this-command)
(or (not re)
@@ -1109,7 +1109,7 @@ See <https://github.com/raxod502/straight.el/issues/520>."
(build (pcase manager
('straight (bound-and-true-p straight-build-dir))
('elpaca (bound-and-true-p elpaca-builds-directory))))
- ((string-prefix-p build filename))
+ (_(string-prefix-p build filename))
(repo (pcase manager
('straight
(and (bound-and-true-p straight-base-dir)
diff --git a/lisp/magit-blame.el b/lisp/magit-blame.el
index aa0af7c46b6..8b58bf019b5 100644
--- a/lisp/magit-blame.el
+++ b/lisp/magit-blame.el
@@ -901,8 +901,9 @@ then also kill the buffer."
#'previous-single-char-property-change
#'next-single-char-property-change)
pos 'magit-blame-chunk)))
- (when-let ((o (magit-blame--overlay-at pos))
- ((equal (oref (magit-blame-chunk-at pos) orig-rev)
rev)))
+ (when-let
+ ((o (magit-blame--overlay-at pos))
+ (_(equal (oref (magit-blame-chunk-at pos) orig-rev) rev)))
(setq ov o))))
(if ov
(goto-char (overlay-start ov))
diff --git a/lisp/magit-branch.el b/lisp/magit-branch.el
index ae4779a0407..4a4aa013b26 100644
--- a/lisp/magit-branch.el
+++ b/lisp/magit-branch.el
@@ -595,7 +595,7 @@ prompt is confusing."
(setq branches
(list (magit-read-branch-prefer-other
(if force "Force delete branch" "Delete branch")))))
- (when-let (((not force))
+ (when-let ((_(not force))
(unmerged (seq-remove #'magit-branch-merged-p branches)))
(if (magit-confirm 'delete-unmerged-branch
"Delete unmerged branch %s"
diff --git a/lisp/magit-diff.el b/lisp/magit-diff.el
index 6dc19ac7096..f502f1507a6 100644
--- a/lisp/magit-diff.el
+++ b/lisp/magit-diff.el
@@ -812,7 +812,7 @@ and `:slant'."
(cl-defmethod transient-init-value ((obj magit-diff-prefix))
(pcase-let ((`(,args ,files)
(magit-diff--get-value 'magit-diff-mode 'prefix)))
- (when-let (((not (eq transient-current-command 'magit-dispatch)))
+ (when-let ((_(not (eq transient-current-command 'magit-dispatch)))
(file (magit-file-relative-name)))
(setq files (list file)))
(oset obj value (if files `(("--" ,@files) ,@args) args))))
@@ -852,7 +852,7 @@ and `:slant'."
(eq major-mode mode))
(setq args magit-buffer-diff-args)
(setq files magit-buffer-diff-files))
- ((when-let (((memq use-buffer-args '(always selected)))
+ ((when-let ((_(memq use-buffer-args '(always selected)))
(buffer (magit-get-mode-buffer
mode nil
(eq use-buffer-args 'selected))))
@@ -2915,7 +2915,7 @@ or a ref which is not a branch, then it inserts nothing."
(magit--insert-related-refs
magit-buffer-revision "--contains" "Contained"
(memq magit-revision-insert-related-refs '(all mixed))))
- (when-let (((magit-revision-insert-related-refs-display-p 'follows))
+ (when-let ((_(magit-revision-insert-related-refs-display-p 'follows))
(follows (magit-get-current-tag magit-buffer-revision t)))
(let ((tag (car follows))
(cnt (cadr follows)))
@@ -2925,7 +2925,7 @@ or a ref which is not a branch, then it inserts nothing."
(propertize tag 'font-lock-face 'magit-tag)
(propertize (number-to-string cnt)
'font-lock-face 'magit-branch-local))))))
- (when-let (((magit-revision-insert-related-refs-display-p 'precedes))
+ (when-let ((_(magit-revision-insert-related-refs-display-p 'precedes))
(precedes (magit-get-next-tag magit-buffer-revision t)))
(let ((tag (car precedes))
(cnt (cadr precedes)))
@@ -2976,7 +2976,7 @@ Refer to user option
`magit-revision-insert-related-refs-display-alist'."
(defun magit-insert-revision-gravatar (beg rev email regexp)
(save-excursion
(goto-char beg)
- (when-let (((re-search-forward regexp nil t))
+ (when-let ((_(re-search-forward regexp nil t))
(window (get-buffer-window)))
(let* ((column (length (match-str 0)))
(font-obj (query-font (font-at (point) window)))
@@ -3575,7 +3575,7 @@ last (visual) lines of the region."
(defun magit-diff-inside-hunk-body-p ()
"Return t if point is inside the body of a hunk."
(and-let* ((section (magit-current-section))
- ((cl-typep section 'magit-hunk-section))
+ (_(cl-typep section 'magit-hunk-section))
(content (oref section content)))
(> (magit-point) content)))
diff --git a/lisp/magit-git.el b/lisp/magit-git.el
index 1c71b781d69..4284042cea8 100644
--- a/lisp/magit-git.el
+++ b/lisp/magit-git.el
@@ -1053,8 +1053,8 @@ tracked file."
buffer-file-name
(and (derived-mode-p 'dired-mode)
default-directory)))
- ((or (not tracked)
- (magit-file-tracked-p (file-relative-name file))))
+ (_(or (not tracked)
+ (magit-file-tracked-p (file-relative-name file))))
(dir (magit-toplevel
(magit--safe-default-directory
(directory-file-name (file-name-directory file))))))
@@ -1103,7 +1103,7 @@ See also `magit-untracked-files'."
((or "yes" "on" "true" "1") t)
("all" 'all))
magit-status-show-untracked-files))
- ((not (eq value 'no))))
+ (_(not (eq value 'no))))
(mapcan (##and (eq (aref % 0) ??)
(list (substring % 3)))
(apply #'magit-git-items "status" "-z" "--porcelain"
@@ -1691,7 +1691,7 @@ The amount of time spent searching is limited by
"for-each-ref" "refs/heads"
"--format=%(refname:short)\t%(upstream:short)"))))
(when-let ((old (assoc oldname branches))
- ((not (assoc newname branches))))
+ (_(not (assoc newname branches))))
(magit-call-git "branch" "-m" oldname newname)
(setcar old newname))
(let ((new (if (magit-branch-p newname)
@@ -2476,9 +2476,9 @@ and this option only controls what face is used.")
(unwind-protect
(magit-with-toplevel
(when-let* ((tree ,tree)
- ((not (magit-git-success
- "read-tree" ,arg tree
- (concat "--index-output=" ,file)))))
+ (_(not (magit-git-success
+ "read-tree" ,arg tree
+ (concat "--index-output=" ,file)))))
(error "Cannot read tree %s" tree))
(with-environment-variables (("GIT_INDEX_FILE" ,file))
,@body))
diff --git a/lisp/magit-log.el b/lisp/magit-log.el
index c82cc95c02b..c2c565a4a44 100644
--- a/lisp/magit-log.el
+++ b/lisp/magit-log.el
@@ -374,7 +374,7 @@ commits before and half after."
(cl-defmethod transient-init-value ((obj magit-log-prefix))
(pcase-let ((`(,args ,files)
(magit-log--get-value 'magit-log-mode 'prefix)))
- (when-let (((not (eq transient-current-command 'magit-dispatch)))
+ (when-let ((_(not (eq transient-current-command 'magit-dispatch)))
(file (magit-file-relative-name)))
(setq files (list file)))
(oset obj value (if files `(("--" ,@files) ,@args) args))))
@@ -414,7 +414,7 @@ commits before and half after."
(eq major-mode mode))
(setq args magit-buffer-log-args)
(setq files magit-buffer-log-files))
- ((when-let (((memq use-buffer-args '(always selected)))
+ ((when-let ((_(memq use-buffer-args '(always selected)))
(buffer (magit-get-mode-buffer
mode nil
(eq use-buffer-args 'selected))))
@@ -1754,8 +1754,8 @@ Type \\[magit-log-select-quit] to abort without selecting
a commit."
(if initial
(magit-log-goto-commit-section initial)
(while-let ((rev (magit-section-value-if 'commit))
- ((string-match-p "\\`\\(squash!\\|fixup!\\|amend!\\)"
- (magit-rev-format "%s" rev)))
+ (_(string-match-p "\\`\\(squash!\\|fixup!\\|amend!\\)"
+ (magit-rev-format "%s" rev)))
(section (magit-current-section))
(next (car (magit-section-siblings section 'next))))
(magit-section-goto next)))
@@ -1915,7 +1915,7 @@ need an unique value, so we use that string in the
pushremote case."
"Insert commits that haven't been pulled from the push-remote yet."
(when-let* ((target (magit-get-push-branch))
(range (concat ".." target))
- ((magit--insert-pushremote-log-p)))
+ (_(magit--insert-pushremote-log-p)))
(magit-insert-section (unpulled range t)
(magit-insert-heading
(format (propertize "Unpulled from %s."
@@ -1995,7 +1995,7 @@ Show the last `magit-log-section-commit-count' commits."
"Insert commits that haven't been pushed to the push-remote yet."
(when-let* ((target (magit-get-push-branch))
(range (concat target ".."))
- ((magit--insert-pushremote-log-p)))
+ (_(magit--insert-pushremote-log-p)))
(magit-insert-section (unpushed range t)
(magit-insert-heading
(format (propertize "Unpushed to %s."
diff --git a/lisp/magit-mode.el b/lisp/magit-mode.el
index b48dcb74758..0ce82337f8b 100644
--- a/lisp/magit-mode.el
+++ b/lisp/magit-mode.el
@@ -1238,8 +1238,8 @@ Note that refreshing a Magit buffer is done by
re-creating its
contents from scratch, which can be slow in large repositories.
If you are not satisfied with Magit's performance, then you
should obviously not add this function to that hook."
- (when-let (((and (not magit-inhibit-refresh)
- (magit-inside-worktree-p t)))
+ (when-let ((_(not magit-inhibit-refresh))
+ (_(magit-inside-worktree-p t))
(buf (ignore-errors (magit-get-mode-buffer 'magit-status-mode))))
(cl-pushnew buf magit-after-save-refresh-buffers)
(add-hook 'post-command-hook #'magit-after-save-refresh-buffers)))
diff --git a/lisp/magit-process.el b/lisp/magit-process.el
index 637db3a86ab..ccdd98dbef9 100644
--- a/lisp/magit-process.el
+++ b/lisp/magit-process.el
@@ -861,7 +861,7 @@ Magit status buffer."
(when (memq (process-status process) '(exit signal))
(magit-process-sentinel process event)
(when-let* ((process-buf (process-buffer process))
- ((buffer-live-p process-buf))
+ (_(buffer-live-p process-buf))
(status-buf (with-current-buffer process-buf
(magit-get-mode-buffer 'magit-status-mode))))
(with-current-buffer status-buf
diff --git a/lisp/magit-refs.el b/lisp/magit-refs.el
index 2ffa12e7d54..47bcf1e09d4 100644
--- a/lisp/magit-refs.el
+++ b/lisp/magit-refs.el
@@ -508,8 +508,8 @@ Branch %s already exists.
"<1>" (magit-menu-item "Visit %s" #'magit-visit-ref))
(defun magit--painted-branch-as-menu-section (section)
- (and-let* ((branch (and (magit-section-match 'commit)
- (magit--painted-branch-at-point))))
+ (and-let* ((_(magit-section-match 'commit))
+ (branch (magit--painted-branch-at-point)))
(let ((dummy (magit-section :type 'branch :value branch)))
(oset dummy keymap magit-branch-section-map)
(dolist (slot '(start content hidden parent children))
@@ -747,7 +747,7 @@ line is inserted at all."
(magit--propertize-face
push 'magit-branch-remote)
" "))
- (if-let ((magit-refs-show-branch-descriptions)
+ (if-let ((_ magit-refs-show-branch-descriptions)
(desc (magit-get "branch" branch "description")))
(magit--propertize-face desc 'bold)
(and msg (magit-log--wash-summary msg))))))))
diff --git a/lisp/magit-section.el b/lisp/magit-section.el
index a574d916516..209bc68bc05 100644
--- a/lisp/magit-section.el
+++ b/lisp/magit-section.el
@@ -613,9 +613,9 @@ with SECTION, otherwise return a list of section types."
`(menu-item
,(if (oref section hidden) "Expand section" "Collapse section")
magit-section-toggle))
- (when-let (((not (oref section hidden)))
+ (when-let ((_(not (oref section hidden)))
(children (oref section children))
- ((seq-some #'magit-section-content-p children)))
+ (_(seq-some #'magit-section-content-p children)))
(when (seq-some (##oref % hidden) children)
(keymap-set-after menu "<magit-section-show-children>"
`(menu-item "Expand children"
diff --git a/lisp/magit-sequence.el b/lisp/magit-sequence.el
index 6bf99e3e52d..78c29987108 100644
--- a/lisp/magit-sequence.el
+++ b/lisp/magit-sequence.el
@@ -764,7 +764,7 @@ argument, prompt for the first commit to potentially squash
into."
(interactive (list current-prefix-arg
(magit-rebase-arguments)))
(magit-rebase-interactive-1
- (and-let* (((not select))
+ (and-let* ((_(not select))
(upstream (magit-get-upstream-branch)))
(magit-git-string "merge-base" upstream "HEAD"))
(nconc (list "--autosquash" "--keep-empty") args)
diff --git a/lisp/magit-status.el b/lisp/magit-status.el
index 9f84e95e612..39274352065 100644
--- a/lisp/magit-status.el
+++ b/lisp/magit-status.el
@@ -467,7 +467,7 @@ Type \\[magit-commit] to create a commit.
(magit-run-section-hook 'magit-status-sections-hook)))
(defun magit-status--get-file-position ()
- (and-let* ((magit-status-goto-file-position)
+ (and-let* ((_ magit-status-goto-file-position)
(file (magit-file-relative-name)))
(save-excursion
(widen)
@@ -553,7 +553,7 @@ the status buffer causes this section to disappear again."
(insert (propertize (format "%-10s" "GitError! ")
'font-lock-face 'magit-section-heading))
(insert (propertize magit-this-error 'font-lock-face 'error))
- (when-let ((magit-show-process-buffer-hint)
+ (when-let ((_ magit-show-process-buffer-hint)
(key (car (where-is-internal 'magit-process-buffer))))
(insert (format " [Type `%s' for details]" (key-description key))))
(insert ?\n))
diff --git a/lisp/magit-submodule.el b/lisp/magit-submodule.el
index 503a1f4bffd..2702d22b5ec 100644
--- a/lisp/magit-submodule.el
+++ b/lisp/magit-submodule.el
@@ -587,7 +587,7 @@ These sections can be expanded to show the respective
commits."
(defun magit--insert-modules-logs (heading type range)
"For internal use, don't add to a hook."
- (when-let (((not (magit-ignore-submodules-p)))
+ (when-let ((_(not (magit-ignore-submodules-p)))
(modules (magit-list-module-paths)))
(magit-insert-section ((eval type) nil t)
(string-match "\\`\\(.+\\) \\([^ ]+\\)\\'" heading)
@@ -600,11 +600,11 @@ These sections can be expanded to show the respective
commits."
":")
(dolist (module modules)
(when-let* ((default-directory (expand-file-name module))
- ((file-exists-p (expand-file-name ".git")))
+ (_(file-exists-p (expand-file-name ".git")))
(lines (magit-git-lines "-c" "push.default=current"
"log" "--oneline" range))
(count (length lines))
- ((> count 0)))
+ (_(> count 0)))
(magit-insert-section
( module module t
:range range)
diff --git a/lisp/magit-wip.el b/lisp/magit-wip.el
index 117d79e2b79..758b1c8890b 100644
--- a/lisp/magit-wip.el
+++ b/lisp/magit-wip.el
@@ -155,7 +155,7 @@ variant `magit-wip-after-save-mode'."
Also see `magit-wip-after-save-mode' which calls this function
automatically whenever a buffer visiting a tracked file is saved."
(interactive (list "wip-save %s after save"))
- (when-let (((not magit--wip-inhibit-autosave))
+ (when-let ((_(not magit--wip-inhibit-autosave))
(ref (magit-wip-get-ref)))
(magit-with-toplevel
(let ((file (file-relative-name buffer-file-name)))