[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/git-commit 9f403b68e8 4/7: Use when-let instead of --when-
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/git-commit 9f403b68e8 4/7: Use when-let instead of --when-let |
Date: |
Mon, 31 Jul 2023 13:00:11 -0400 (EDT) |
branch: elpa/git-commit
commit 9f403b68e87982da16253d3308cda194c11133f2
Author: Jonas Bernoulli <jonas@bernoul.li>
Commit: Jonas Bernoulli <jonas@bernoul.li>
Use when-let instead of --when-let
In a few cases use `when-let*' or `and-let*' instead.
I haven't done a full 180 on anaphoric conditionals; if a builtin
equivalent existed, I would use that in some instances.
However, having looked at all the existing uses of `when-let', it
turns out there are way fewer such cases than I had anticipated.
---
lisp/git-rebase.el | 10 ++++----
lisp/magit-apply.el | 62 ++++++++++++++++++++++++------------------------
lisp/magit-autorevert.el | 4 ++--
lisp/magit-blame.el | 12 ++++++----
lisp/magit-branch.el | 31 ++++++++++++------------
lisp/magit-commit.el | 4 ++--
lisp/magit-diff.el | 31 ++++++++++++------------
lisp/magit-files.el | 5 ++--
lisp/magit-git.el | 24 +++++++++----------
lisp/magit-log.el | 25 ++++++++++---------
lisp/magit-mode.el | 13 +++++-----
lisp/magit-process.el | 20 ++++++++--------
lisp/magit-section.el | 4 ++--
lisp/magit-sequence.el | 4 ++--
lisp/magit-submodule.el | 4 ++--
lisp/magit.el | 4 ++--
16 files changed, 133 insertions(+), 124 deletions(-)
diff --git a/lisp/git-rebase.el b/lisp/git-rebase.el
index 40d5a32652..ed52d2fa30 100644
--- a/lisp/git-rebase.el
+++ b/lisp/git-rebase.el
@@ -734,13 +734,13 @@ running \"man git-rebase\" at the command line) for
details."
(magit-confirm 'abort-rebase "Abort this rebase" nil 'noabort)))
(defun git-rebase-autostash-save ()
- (--when-let (magit-file-line
- (expand-file-name "rebase-merge/autostash" (magit-gitdir)))
- (push (cons 'stash it) with-editor-cancel-alist)))
+ (when-let ((rev (magit-file-line
+ (expand-file-name "rebase-merge/autostash"
(magit-gitdir)))))
+ (push (cons 'stash rev) with-editor-cancel-alist)))
(defun git-rebase-autostash-apply ()
- (--when-let (cdr (assq 'stash with-editor-cancel-alist))
- (magit-stash-apply it)))
+ (when-let ((rev (cdr (assq 'stash with-editor-cancel-alist))))
+ (magit-stash-apply rev)))
(defun git-rebase-match-comment-line (limit)
(re-search-forward (concat git-rebase-comment-re ".*") limit t))
diff --git a/lisp/magit-apply.el b/lisp/magit-apply.el
index 82f064e93b..2654ad92b7 100644
--- a/lisp/magit-apply.el
+++ b/lisp/magit-apply.el
@@ -119,19 +119,19 @@ is a member of `magit-post-unstage-hook-commands'."
With a prefix argument fallback to a 3-way merge. Doing
so causes the change to be applied to the index as well."
(interactive (and current-prefix-arg (list "--3way")))
- (--when-let (magit-apply--get-selection)
+ (when-let ((s (magit-apply--get-selection)))
(pcase (list (magit-diff-type) (magit-diff-scope))
(`(,(or 'unstaged 'staged) ,_)
(user-error "Change is already in the working tree"))
(`(untracked ,(or 'file 'files))
(call-interactively #'magit-am))
- (`(,_ region) (magit-apply-region it args))
- (`(,_ hunk) (magit-apply-hunk it args))
- (`(,_ hunks) (magit-apply-hunks it args))
+ (`(,_ region) (magit-apply-region s args))
+ (`(,_ hunk) (magit-apply-hunk s args))
+ (`(,_ hunks) (magit-apply-hunks s args))
(`(rebase-sequence file)
(call-interactively #'magit-patch-apply))
- (`(,_ file) (magit-apply-diff it args))
- (`(,_ files) (magit-apply-diffs it args)))))
+ (`(,_ file) (magit-apply-diff s args))
+ (`(,_ files) (magit-apply-diffs s args)))))
(defun magit-apply--section-content (section)
(buffer-substring-no-properties (if (magit-hunk-section-p section)
@@ -411,21 +411,21 @@ ignored) files."
(defun magit-unstage ()
"Remove the change at point from the staging area."
(interactive)
- (--when-let (magit-apply--get-selection)
+ (when-let ((s (magit-apply--get-selection)))
(pcase (list (magit-diff-type)
(magit-diff-scope)
(magit-apply--diff-ignores-whitespace-p))
(`(untracked ,_ ,_) (user-error "Cannot unstage untracked changes"))
- (`(unstaged file ,_) (magit-unstage-intent (list (oref it value))))
+ (`(unstaged file ,_) (magit-unstage-intent (list (oref s value))))
(`(unstaged files ,_) (magit-unstage-intent (magit-region-values nil
t)))
(`(unstaged ,_ ,_) (user-error "Already unstaged"))
- (`(staged region ,_) (magit-apply-region it "--reverse" "--cached"))
- (`(staged hunk ,_) (magit-apply-hunk it "--reverse" "--cached"))
- (`(staged hunks ,_) (magit-apply-hunks it "--reverse" "--cached"))
- ('(staged file t) (magit-apply-diff it "--reverse" "--cached"))
- ('(staged files t) (magit-apply-diffs it "--reverse" "--cached"))
- ('(staged list t) (magit-apply-diffs it "--reverse" "--cached"))
- ('(staged file nil) (magit-unstage-1 (list (oref it value))))
+ (`(staged region ,_) (magit-apply-region s "--reverse" "--cached"))
+ (`(staged hunk ,_) (magit-apply-hunk s "--reverse" "--cached"))
+ (`(staged hunks ,_) (magit-apply-hunks s "--reverse" "--cached"))
+ ('(staged file t) (magit-apply-diff s "--reverse" "--cached"))
+ ('(staged files t) (magit-apply-diffs s "--reverse" "--cached"))
+ ('(staged list t) (magit-apply-diffs s "--reverse" "--cached"))
+ ('(staged file nil) (magit-unstage-1 (list (oref s value))))
('(staged files nil) (magit-unstage-1 (magit-region-values nil t)))
('(staged list nil) (magit-unstage-all))
(`(committed ,_ ,_) (if magit-unstage-committed
@@ -502,16 +502,16 @@ On a hunk or file with unresolved conflicts prompt which
side to
keep (while discarding the other). If point is within the text
of a side, then keep that side without prompting."
(interactive)
- (--when-let (magit-apply--get-selection)
+ (when-let ((s (magit-apply--get-selection)))
(pcase (list (magit-diff-type) (magit-diff-scope))
(`(committed ,_) (user-error "Cannot discard committed changes"))
(`(undefined ,_) (user-error "Cannot discard this change"))
- (`(,_ region) (magit-discard-region it))
- (`(,_ hunk) (magit-discard-hunk it))
- (`(,_ hunks) (magit-discard-hunks it))
- (`(,_ file) (magit-discard-file it))
- (`(,_ files) (magit-discard-files it))
- (`(,_ list) (magit-discard-files it)))))
+ (`(,_ region) (magit-discard-region s))
+ (`(,_ hunk) (magit-discard-hunk s))
+ (`(,_ hunks) (magit-discard-hunks s))
+ (`(,_ file) (magit-discard-file s))
+ (`(,_ files) (magit-discard-files s))
+ (`(,_ list) (magit-discard-files s)))))
(defun magit-discard-region (section)
(magit-confirm 'discard "Discard region")
@@ -665,8 +665,8 @@ of a side, then keep that side without prompting."
(let ((orig (cadr (assoc file status))))
(if (file-exists-p file)
(progn
- (--when-let (file-name-directory orig)
- (make-directory it t))
+ (when-let ((path (file-name-directory orig)))
+ (make-directory path t))
(magit-call-git "mv" file orig))
(magit-call-git "rm" "--cached" "--" file)
(magit-call-git "reset" "--" orig)))))
@@ -707,16 +707,16 @@ of a side, then keep that side without prompting."
With a prefix argument fallback to a 3-way merge. Doing
so causes the change to be applied to the index as well."
(interactive (and current-prefix-arg (list "--3way")))
- (--when-let (magit-apply--get-selection)
+ (when-let ((s (magit-apply--get-selection)))
(pcase (list (magit-diff-type) (magit-diff-scope))
(`(untracked ,_) (user-error "Cannot reverse untracked changes"))
(`(unstaged ,_) (user-error "Cannot reverse unstaged changes"))
- (`(,_ region) (magit-reverse-region it args))
- (`(,_ hunk) (magit-reverse-hunk it args))
- (`(,_ hunks) (magit-reverse-hunks it args))
- (`(,_ file) (magit-reverse-file it args))
- (`(,_ files) (magit-reverse-files it args))
- (`(,_ list) (magit-reverse-files it args)))))
+ (`(,_ region) (magit-reverse-region s args))
+ (`(,_ hunk) (magit-reverse-hunk s args))
+ (`(,_ hunks) (magit-reverse-hunks s args))
+ (`(,_ file) (magit-reverse-file s args))
+ (`(,_ files) (magit-reverse-files s args))
+ (`(,_ list) (magit-reverse-files s args)))))
(defun magit-reverse-region (section args)
(magit-confirm 'reverse "Reverse region")
diff --git a/lisp/magit-autorevert.el b/lisp/magit-autorevert.el
index 68da18fcc7..7099cd62bf 100644
--- a/lisp/magit-autorevert.el
+++ b/lisp/magit-autorevert.el
@@ -99,8 +99,8 @@ seconds of user inactivity. That is not desirable."
(defun magit-turn-on-auto-revert-mode-if-desired (&optional file)
(if file
- (--when-let (find-buffer-visiting file)
- (with-current-buffer it
+ (when-let ((buffer (find-buffer-visiting file)))
+ (with-current-buffer buffer
(magit-turn-on-auto-revert-mode-if-desired)))
(when (and (not auto-revert-mode) ; see #3014
(not global-auto-revert-mode) ; see #3460
diff --git a/lisp/magit-blame.el b/lisp/magit-blame.el
index 65bb9e416e..b0c832d25c 100644
--- a/lisp/magit-blame.el
+++ b/lisp/magit-blame.el
@@ -400,10 +400,12 @@ modes is toggled, then this mode also gets toggled
automatically.
(defun magit-blame-put-keymap-before-view-mode ()
"Put `magit-blame-read-only-mode' ahead of `view-mode' in
`minor-mode-map-alist'."
- (--when-let (assq 'magit-blame-read-only-mode
- (cl-member 'view-mode minor-mode-map-alist :key #'car))
+ (when-let ((entry (assq 'magit-blame-read-only-mode
+ (cl-member 'view-mode minor-mode-map-alist
+ :key #'car))))
(setq minor-mode-map-alist
- (cons it (delq it minor-mode-map-alist))))
+ (cons entry
+ (delq entry minor-mode-map-alist))))
(remove-hook 'view-mode-hook #'magit-blame-put-keymap-before-view-mode))
(add-hook 'view-mode-hook #'magit-blame-put-keymap-before-view-mode)
@@ -885,9 +887,9 @@ then also kill the buffer."
#'previous-single-char-property-change
#'next-single-char-property-change)
pos 'magit-blame-chunk)))
- (--when-let (magit-blame--overlay-at pos)
+ (when-let ((o (magit-blame--overlay-at pos)))
(when (equal (oref (magit-blame-chunk-at pos) orig-rev) rev)
- (setq ov it)))))
+ (setq ov o)))))
(if ov
(goto-char (overlay-start ov))
(user-error "No more chunks from same commit")))
diff --git a/lisp/magit-branch.el b/lisp/magit-branch.el
index 57b52fa15b..48a7762335 100644
--- a/lisp/magit-branch.el
+++ b/lisp/magit-branch.el
@@ -394,19 +394,20 @@ when using `magit-branch-and-checkout'."
(magit-process-sentinel process event)))))))
(defun magit-branch-maybe-adjust-upstream (branch start-point)
- (--when-let
- (or (and (magit-get-upstream-branch branch)
- (magit-get-indirect-upstream-branch start-point))
- (and (magit-remote-branch-p start-point)
- (let ((name (cdr (magit-split-branch-name start-point))))
- (seq-some (pcase-lambda (`(,upstream . ,rule))
- (and (magit-branch-p upstream)
- (if (listp rule)
- (not (member name rule))
- (string-match-p rule name))
- upstream))
- magit-branch-adjust-remote-upstream-alist))))
- (magit-call-git "branch" (concat "--set-upstream-to=" it) branch)))
+ (when-let ((upstream
+ (or (and (magit-get-upstream-branch branch)
+ (magit-get-indirect-upstream-branch start-point))
+ (and (magit-remote-branch-p start-point)
+ (let ((name (cdr (magit-split-branch-name
start-point))))
+ (seq-some
+ (pcase-lambda (`(,upstream . ,rule))
+ (and (magit-branch-p upstream)
+ (if (listp rule)
+ (not (member name rule))
+ (string-match-p rule name))
+ upstream))
+ magit-branch-adjust-remote-upstream-alist))))))
+ (magit-call-git "branch" (concat "--set-upstream-to=" upstream) branch)))
;;;###autoload
(defun magit-branch-orphan (branch start-point)
@@ -506,8 +507,8 @@ from the source branch's upstream, then an error is raised."
(if checkout
(magit-call-git "checkout" "-b" branch current)
(magit-call-git "branch" branch current)))
- (--when-let (magit-get-indirect-upstream-branch current)
- (magit-call-git "branch" "--set-upstream-to" it branch))
+ (when-let ((upstream (magit-get-indirect-upstream-branch current)))
+ (magit-call-git "branch" "--set-upstream-to" upstream branch))
(when (and tracked
(setq base
(if from
diff --git a/lisp/magit-commit.el b/lisp/magit-commit.el
index 842a87dfb6..f6ee9ad5ae 100644
--- a/lisp/magit-commit.el
+++ b/lisp/magit-commit.el
@@ -339,13 +339,13 @@ depending on the value of option
`magit-commit-squash-confirm'."
(apply #'magit-diff-staged nil (magit-diff-arguments)))))))
(defun magit-commit-amend-assert (&optional commit)
- (--when-let (magit-list-publishing-branches commit)
+ (when-let ((branches (magit-list-publishing-branches commit)))
(let ((m1 "This commit has already been published to ")
(m2 ".\nDo you really want to modify it"))
(magit-confirm 'amend-published
(concat m1 "%s" m2)
(concat m1 "%d public branches" m2)
- nil it))))
+ nil branches))))
(defun magit-commit-assert (args &optional strict)
(cond
diff --git a/lisp/magit-diff.el b/lisp/magit-diff.el
index 25d1cb8fe6..fe07b0f5f3 100644
--- a/lisp/magit-diff.el
+++ b/lisp/magit-diff.el
@@ -2747,8 +2747,9 @@ or a ref which is not a branch, then it inserts nothing."
(defun magit-insert-revision-headers ()
"Insert headers about the commit into a revision buffer."
(magit-insert-section (headers)
- (--when-let (magit-rev-format "%D" magit-buffer-revision "--decorate=full")
- (insert (magit-format-ref-labels it) ?\s))
+ (when-let ((string (magit-rev-format "%D" magit-buffer-revision
+ "--decorate=full")))
+ (insert (magit-format-ref-labels string) ?\s))
(insert (propertize
(magit-rev-parse (magit--rev-dereference magit-buffer-revision))
'font-lock-face 'magit-hash))
@@ -2828,10 +2829,10 @@ Refer to user option
`magit-revision-insert-related-refs-display-alist'."
('author '("^Author: " . nil))
('committer '(nil . "^Commit: "))
(_ magit-revision-show-gravatars))))
- (--when-let (and author (magit-rev-format "%aE" rev))
- (magit-insert-revision-gravatar beg rev it author))
- (--when-let (and committer (magit-rev-format "%cE" rev))
- (magit-insert-revision-gravatar beg rev it committer)))))
+ (when-let ((email (and author (magit-rev-format "%aE" rev))))
+ (magit-insert-revision-gravatar beg rev email author))
+ (when-let ((email (and committer (magit-rev-format "%cE" rev))))
+ (magit-insert-revision-gravatar beg rev email committer)))))
(defun magit-insert-revision-gravatar (beg rev email regexp)
(save-excursion
@@ -3036,7 +3037,7 @@ is determined using other means. In `magit-revision-mode'
buffers the type is always `committed'.
Do not confuse this with `magit-diff-scope' (which see)."
- (--when-let (or section (magit-current-section))
+ (when-let ((section (or section (magit-current-section))))
(cond ((derived-mode-p 'magit-revision-mode 'magit-stash-mode) 'committed)
((derived-mode-p 'magit-diff-mode)
(let ((range magit-buffer-range)
@@ -3056,24 +3057,24 @@ Do not confuse this with `magit-diff-scope' (which
see)."
'undefined)) ; i.e., committed and staged
(t 'committed))))
((derived-mode-p 'magit-status-mode)
- (let ((stype (oref it type)))
+ (let ((stype (oref section type)))
(if (memq stype '(staged unstaged tracked untracked))
stype
(pcase stype
((or 'file 'module)
- (let* ((parent (oref it parent))
+ (let* ((parent (oref section parent))
(type (oref parent type)))
(if (memq type '(file module))
(magit-diff-type parent)
type)))
- ('hunk (thread-first it
+ ('hunk (thread-first section
(oref parent)
(oref parent)
(oref type)))))))
((derived-mode-p 'magit-log-mode)
- (if (or (and (magit-section-match 'commit it)
- (oref it children))
- (magit-section-match [* file commit] it))
+ (if (or (and (magit-section-match 'commit section)
+ (oref section children))
+ (magit-section-match [* file commit] section))
'committed
'undefined))
(t 'undefined))))
@@ -3104,8 +3105,8 @@ actually a `diff' but a `diffstat' section."
(when (and section
(or (not strict)
(and (not (eq (magit-diff-type section) 'untracked))
- (not (eq (--when-let (oref section parent)
- (oref it type))
+ (not (eq (and-let* ((parent (oref section parent)))
+ (oref parent type))
'diffstat)))))
(pcase (list (oref section type)
(and siblings t)
diff --git a/lisp/magit-files.el b/lisp/magit-files.el
index 47cb516252..47c6d30258 100644
--- a/lisp/magit-files.el
+++ b/lisp/magit-files.el
@@ -227,8 +227,9 @@ is done using `magit-find-index-noselect'."
(when magit-wip-after-apply-mode
(magit-wip-commit-after-apply (list file) " after un-/stage")))
(message "Abort")))
- (--when-let (magit-get-mode-buffer 'magit-status-mode)
- (with-current-buffer it (magit-refresh)))
+ (when-let ((buffer (magit-get-mode-buffer 'magit-status-mode)))
+ (with-current-buffer buffer
+ (magit-refresh)))
t)
;;; Find Config File
diff --git a/lisp/magit-git.el b/lisp/magit-git.el
index db75252077..a6b8eb347a 100644
--- a/lisp/magit-git.el
+++ b/lisp/magit-git.el
@@ -728,12 +728,12 @@ See info node `(magit)Debugging Tools' for more
information."
(format " [%S]" (executable-find magit-git-executable)))
(format " (%s)\n" (magit--safe-git-version))))
(insert (format "exec-path: %S\n" exec-path))
- (--when-let (cl-set-difference
- (seq-filter #'file-exists-p (remq nil (parse-colon-path
- (getenv "PATH"))))
- (seq-filter #'file-exists-p (remq nil exec-path))
- :test #'file-equal-p)
- (insert (format " entries in PATH, but not in exec-path: %S\n" it)))
+ (when-let ((diff (cl-set-difference
+ (seq-filter #'file-exists-p (remq nil (parse-colon-path
+ (getenv "PATH"))))
+ (seq-filter #'file-exists-p (remq nil exec-path))
+ :test #'file-equal-p)))
+ (insert (format " entries in PATH, but not in exec-path: %S\n" diff)))
(dolist (execdir exec-path)
(insert (format " %s (%s)\n" execdir (car (file-attributes execdir))))
(when (file-directory-p execdir)
@@ -2448,10 +2448,10 @@ and this option only controls what face is used.")
(expand-file-name "index.magit." (magit-gitdir))))))
(unwind-protect
(magit-with-toplevel
- (--when-let ,tree
- (or (magit-git-success "read-tree" ,arg it
- (concat "--index-output=" ,file))
- (error "Cannot read tree %s" it)))
+ (when-let ((tree ,tree))
+ (unless (magit-git-success "read-tree" ,arg tree
+ (concat "--index-output=" ,file))
+ (error "Cannot read tree %s" tree)))
(if (file-remote-p default-directory)
(let ((magit-tramp-process-environment
(cons (concat "GIT_INDEX_FILE=" ,file)
@@ -2593,9 +2593,9 @@ and this option only controls what face is used.")
(defun magit-read-range-or-commit (prompt &optional secondary-default)
(magit-read-range
prompt
- (or (--when-let (magit-region-values '(commit branch) t)
+ (or (when-let ((revs (magit-region-values '(commit branch) t)))
(deactivate-mark)
- (concat (car (last it)) ".." (car it)))
+ (concat (car (last revs)) ".." (car revs)))
(magit-branch-or-commit-at-point)
secondary-default
(magit-get-current-branch))))
diff --git a/lisp/magit-log.el b/lisp/magit-log.el
index 130fa4015d..cf5a0db3c8 100644
--- a/lisp/magit-log.el
+++ b/lisp/magit-log.el
@@ -1136,9 +1136,10 @@ Do not add this to a hook variable."
(concat "\n" magit-log-revision-headers-format "\n"))
""))
(progn
- (--when-let (--first (string-match "^\\+\\+order=\\(.+\\)$" it) args)
- (setq args (cons (format "--%s-order" (match-string 1 it))
- (remove it args))))
+ (when-let ((order (--first (string-match "^\\+\\+order=\\(.+\\)$" it)
+ args)))
+ (setq args (cons (format "--%s-order" (match-string 1 order))
+ (remove order args))))
(when (member "--decorate" args)
(setq args (cons "--decorate=full" (remove "--decorate" args))))
(when (member "--reverse" args)
@@ -1796,14 +1797,15 @@ in the pushremote case."
(defun magit-insert-unpulled-from-pushremote ()
"Insert commits that haven't been pulled from the push-remote yet."
- (--when-let (magit-get-push-branch)
+ (when-let* ((target (magit-get-push-branch))
+ (range (concat ".." target)))
(when (magit--insert-pushremote-log-p)
- (magit-insert-section (unpulled (concat ".." it) t)
+ (magit-insert-section (unpulled range t)
(magit-insert-heading
(format (propertize "Unpulled from %s."
'font-lock-face 'magit-section-heading)
- (propertize it 'font-lock-face 'magit-branch-remote)))
- (magit--insert-log nil (concat ".." it) magit-buffer-log-args)
+ (propertize target 'font-lock-face 'magit-branch-remote)))
+ (magit--insert-log nil range magit-buffer-log-args)
(magit-log-insert-child-count)))))
(defvar-keymap magit-unpushed-section-map
@@ -1867,14 +1869,15 @@ Show the last `magit-log-section-commit-count' commits."
(defun magit-insert-unpushed-to-pushremote ()
"Insert commits that haven't been pushed to the push-remote yet."
- (--when-let (magit-get-push-branch)
+ (when-let* ((target (magit-get-push-branch))
+ (range (concat target "..")))
(when (magit--insert-pushremote-log-p)
- (magit-insert-section (unpushed (concat it "..") t)
+ (magit-insert-section (unpushed range t)
(magit-insert-heading
(format (propertize "Unpushed to %s."
'font-lock-face 'magit-section-heading)
- (propertize it 'font-lock-face 'magit-branch-remote)))
- (magit--insert-log nil (concat it "..") magit-buffer-log-args)
+ (propertize target 'font-lock-face 'magit-branch-remote)))
+ (magit--insert-log nil range magit-buffer-log-args)
(magit-log-insert-child-count)))))
(defun magit--insert-pushremote-log-p ()
diff --git a/lisp/magit-mode.el b/lisp/magit-mode.el
index c5d63ba34c..007c4be470 100644
--- a/lisp/magit-mode.el
+++ b/lisp/magit-mode.el
@@ -963,10 +963,10 @@ Run hooks `magit-pre-refresh-hook' and
`magit-post-refresh-hook'."
(magit-refresh-buffer))
((derived-mode-p 'tabulated-list-mode)
(revert-buffer)))
- (--when-let (and magit-refresh-status-buffer
- (not (derived-mode-p 'magit-status-mode))
- (magit-get-mode-buffer 'magit-status-mode))
- (with-current-buffer it
+ (when-let ((buffer (and magit-refresh-status-buffer
+ (not (derived-mode-p 'magit-status-mode))
+ (magit-get-mode-buffer 'magit-status-mode))))
+ (with-current-buffer buffer
(magit-refresh-buffer)))
(magit-run-hook-with-benchmark 'magit-post-refresh-hook)
(when magit-refresh-verbose
@@ -1075,8 +1075,9 @@ If you are not satisfied with Magit's performance, then
you
should obviously not add this function to that hook."
(when (and (not magit--disable-save-buffers)
(magit-inside-worktree-p t))
- (--when-let (ignore-errors (magit-get-mode-buffer 'magit-status-mode))
- (add-to-list 'magit-after-save-refresh-buffers it)
+ (when-let ((buffer (ignore-errors
+ (magit-get-mode-buffer 'magit-status-mode))))
+ (add-to-list 'magit-after-save-refresh-buffers buffer)
(add-hook 'post-command-hook #'magit-after-save-refresh-buffers))))
(defun magit-maybe-save-repository-buffers ()
diff --git a/lisp/magit-process.el b/lisp/magit-process.el
index b766140606..1826a08313 100644
--- a/lisp/magit-process.el
+++ b/lisp/magit-process.el
@@ -743,16 +743,16 @@ Magit status buffer."
(status-buf (with-current-buffer process-buf
(magit-get-mode-buffer 'magit-status-mode))))
(with-current-buffer status-buf
- (--when-let
- (magit-get-section
- `((commit . ,(magit-rev-parse "HEAD"))
- (,(pcase (car (seq-drop
- (process-command process)
- (1+ (length magit-git-global-arguments))))
- ((or "rebase" "am") 'rebase-sequence)
- ((or "cherry-pick" "revert") 'sequence)))
- (status)))
- (goto-char (oref it start))
+ (when-let ((section
+ (magit-get-section
+ `((commit . ,(magit-rev-parse "HEAD"))
+ (,(pcase (car (seq-drop
+ (process-command process)
+ (1+ (length
magit-git-global-arguments))))
+ ((or "rebase" "am") 'rebase-sequence)
+ ((or "cherry-pick" "revert") 'sequence)))
+ (status)))))
+ (goto-char (oref section start))
(magit-section-update-highlight))))))
(defun magit-process-filter (proc string)
diff --git a/lisp/magit-section.el b/lisp/magit-section.el
index fd2fd5c0e1..243beb5ca5 100644
--- a/lisp/magit-section.el
+++ b/lisp/magit-section.el
@@ -2049,11 +2049,11 @@ Configuration'."
(let ((entries (symbol-value hook)))
(unless (listp entries)
(setq entries (list entries)))
- (--when-let (seq-remove #'functionp entries)
+ (when-let ((invalid (seq-remove #'functionp entries)))
(message "`%s' contains entries that are no longer valid.
%s\nUsing standard value instead. Please re-configure hook variable."
hook
- (mapconcat (lambda (sym) (format " `%s'" sym)) it "\n"))
+ (mapconcat (lambda (sym) (format " `%s'" sym)) invalid "\n"))
(sit-for 5)
(setq entries (eval (car (get hook 'standard-value)))))
(dolist (entry entries)
diff --git a/lisp/magit-sequence.el b/lisp/magit-sequence.el
index 69b1b41d6e..f3793e5b62 100644
--- a/lisp/magit-sequence.el
+++ b/lisp/magit-sequence.el
@@ -281,8 +281,8 @@ the process manually."
(unless (magit-branch-p dst)
(let ((magit-process-raise-error t))
(magit-call-git "branch" dst start-point))
- (--when-let (magit-get-indirect-upstream-branch start-point)
- (magit-call-git "branch" "--set-upstream-to" it dst)))
+ (when-let ((upstream (magit-get-indirect-upstream-branch start-point)))
+ (magit-call-git "branch" "--set-upstream-to" upstream dst)))
(unless (equal dst current)
(let ((magit-process-raise-error t))
(magit-call-git "checkout" dst)))
diff --git a/lisp/magit-submodule.el b/lisp/magit-submodule.el
index 13288040fd..66c5f3b5c6 100644
--- a/lisp/magit-submodule.el
+++ b/lisp/magit-submodule.el
@@ -503,8 +503,8 @@ or, failing that, the abbreviated HEAD commit hash."
(string-match-p "\\`[0-9]" it))
(insert ?\s))
(insert (propertize it 'font-lock-face 'magit-tag)))
- (--when-let (magit-rev-format "%h")
- (insert (propertize it 'font-lock-face 'magit-hash)))))
+ (when-let ((abbrev (magit-rev-format "%h")))
+ (insert (propertize abbrev 'font-lock-face 'magit-hash)))))
(insert ?\n))))))
(insert ?\n))
diff --git a/lisp/magit.el b/lisp/magit.el
index a8842259ba..fee8b00cc3 100644
--- a/lisp/magit.el
+++ b/lisp/magit.el
@@ -629,12 +629,12 @@ the output in the kill ring.
(when (featurep 'package)
(push 'elpa debug)
(ignore-errors
- (--when-let (assq 'magit package-alist)
+ (when-let ((version (cadr (assq 'magit package-alist))))
(push t debug)
(setq magit-version
(and (fboundp 'package-desc-version)
(package-version-join
- (package-desc-version (cadr it))))))))
+ (package-desc-version version)))))))
(progn
(push 'dirname debug)
(let ((dirname (file-name-nondirectory
- [nongnu] elpa/git-commit updated (95d5be9ac3 -> 6d300bfe36), ELPA Syncer, 2023/07/31
- [nongnu] elpa/git-commit 4ca7b95f28 3/7: magit-diff-type: Fix in logs when section isn't provided as argument, ELPA Syncer, 2023/07/31
- [nongnu] elpa/git-commit e8152c76bf 5/7: Use if-let instead of --if-let, ELPA Syncer, 2023/07/31
- [nongnu] elpa/git-commit 9f403b68e8 4/7: Use when-let instead of --when-let,
ELPA Syncer <=
- [nongnu] elpa/git-commit 9e95c23813 1/7: Use `and' instead of `when' or `unless' if value matters, ELPA Syncer, 2023/07/31
- [nongnu] elpa/git-commit 41a0f6ed30 2/7: Use and-let* instead of when-let* if value matters, ELPA Syncer, 2023/07/31
- [nongnu] elpa/git-commit 70843f133c 6/7: Fix switch from -replace to cl-substitute, ELPA Syncer, 2023/07/31
- [nongnu] elpa/git-commit 6d300bfe36 7/7: Explicitly depend on latest Seq release for older Emacs releases, ELPA Syncer, 2023/07/31