branch: elpa/git-commit
commit 9ce3859dd2e78c7fe57411a780eccbf4ec18d0f4
Author: Jonas Bernoulli <jo...@bernoul.li>
Commit: Jonas Bernoulli <jo...@bernoul.li>

    Use when-let* for multiple bindings
---
 lisp/magit-bisect.el  |  8 ++++----
 lisp/magit-blame.el   |  6 +++---
 lisp/magit-branch.el  |  6 +++---
 lisp/magit-extras.el  |  4 ++--
 lisp/magit-log.el     | 41 +++++++++++++++++++++--------------------
 lisp/magit-process.el | 32 ++++++++++++++++----------------
 lisp/magit-refs.el    |  6 +++---
 lisp/magit-stash.el   |  4 ++--
 lisp/magit-status.el  | 12 ++++++------
 9 files changed, 60 insertions(+), 59 deletions(-)

diff --git a/lisp/magit-bisect.el b/lisp/magit-bisect.el
index 64ccc612cc..6801c8514c 100644
--- a/lisp/magit-bisect.el
+++ b/lisp/magit-bisect.el
@@ -224,10 +224,10 @@ bisect run'."
          (magit-process-sentinel process event)
          (when (buffer-live-p (process-buffer process))
            (with-current-buffer (process-buffer process)
-             (when-let ((section (magit-section-at))
-                        (output (buffer-substring-no-properties
-                                 (oref section content)
-                                 (oref section end))))
+             (when-let* ((section (magit-section-at))
+                         (output (buffer-substring-no-properties
+                                  (oref section content)
+                                  (oref section end))))
                (with-temp-file (magit-git-dir "BISECT_CMD_OUTPUT")
                  (insert output)))))
          (magit-refresh))
diff --git a/lisp/magit-blame.el b/lisp/magit-blame.el
index 24f2080542..8c0d8551f4 100644
--- a/lisp/magit-blame.el
+++ b/lisp/magit-blame.el
@@ -963,9 +963,9 @@ instead of the hash, like `kill-ring-save' would."
 ;;; Utilities
 
 (defun magit-blame-maybe-update-revision-buffer ()
-  (when-let ((chunk  (magit-current-blame-chunk))
-             (commit (oref chunk orig-rev))
-             (buffer (magit-get-mode-buffer 'magit-revision-mode nil t)))
+  (when-let* ((chunk  (magit-current-blame-chunk))
+              (commit (oref chunk orig-rev))
+              (buffer (magit-get-mode-buffer 'magit-revision-mode nil t)))
     (if magit--update-revision-buffer
         (setq magit--update-revision-buffer (list commit buffer))
       (setq magit--update-revision-buffer (list commit buffer))
diff --git a/lisp/magit-branch.el b/lisp/magit-branch.el
index a81890ca55..80f52bb2c8 100644
--- a/lisp/magit-branch.el
+++ b/lisp/magit-branch.el
@@ -860,9 +860,9 @@ and also rename the respective reflog file."
   :class 'magit--git-branch:upstream)
 
 (cl-defmethod transient-init-value ((obj magit--git-branch:upstream))
-  (when-let ((branch (oref transient--prefix scope))
-             (remote (magit-get "branch" branch "remote"))
-             (merge  (magit-get "branch" branch "merge")))
+  (when-let* ((branch (oref transient--prefix scope))
+              (remote (magit-get "branch" branch "remote"))
+              (merge  (magit-get "branch" branch "merge")))
     (oset obj value (list remote merge))))
 
 (cl-defmethod transient-infix-read ((obj magit--git-branch:upstream))
diff --git a/lisp/magit-extras.el b/lisp/magit-extras.el
index 5b584a56fd..ea8f8e1655 100644
--- a/lisp/magit-extras.el
+++ b/lisp/magit-extras.el
@@ -787,8 +787,8 @@ argument."
    ((use-region-p)
     (call-interactively #'copy-region-as-kill))
    (t
-    (when-let ((section (magit-current-section))
-               (value (oref section value)))
+    (when-let* ((section (magit-current-section))
+                (value (oref section value)))
       (magit-section-case
         ((branch commit module-commit tag)
          (let ((default-directory default-directory) ref)
diff --git a/lisp/magit-log.el b/lisp/magit-log.el
index 97db32c590..88ddec7424 100644
--- a/lisp/magit-log.el
+++ b/lisp/magit-log.el
@@ -1060,19 +1060,20 @@ Type \\[magit-reset] to reset `HEAD' to the commit at 
point.
       (setq args (remove "--graph" args)))
     (unless (member "--graph" args)
       (setq args (remove "--color" args)))
-    (when-let ((limit (magit-log-get-commit-limit))
-               (limit (* 2 limit)) ; increase odds for complete graph
-               (count (and (= (length revs) 1)
-                           (> limit 1024) ; otherwise it's fast enough
-                           (setq revs (car revs))
-                           (not (string-search ".." revs))
-                           (not (member revs '("--all" "--branches")))
-                           (-none-p (lambda (arg)
-                                      (--any-p (string-prefix-p it arg)
-                                               
magit-log-disable-graph-hack-args))
-                                    args)
-                           (magit-git-string "rev-list" "--count"
-                                             "--first-parent" args revs))))
+    (when-let* ((limit (magit-log-get-commit-limit))
+                (limit (* 2 limit)) ; increase odds for complete graph
+                (count (and (= (length revs) 1)
+                            (> limit 1024) ; otherwise it's fast enough
+                            (setq revs (car revs))
+                            (not (string-search ".." revs))
+                            (not (member revs '("--all" "--branches")))
+                            (-none-p (lambda (arg)
+                                       (--any-p
+                                        (string-prefix-p it arg)
+                                        magit-log-disable-graph-hack-args))
+                                     args)
+                            (magit-git-string "rev-list" "--count"
+                                              "--first-parent" args revs))))
       (setq revs (if (< (string-to-number count) limit)
                      revs
                    (format "%s~%s..%s" revs limit revs))))
@@ -1438,8 +1439,8 @@ If there is no revision buffer in the same frame, then do 
nothing."
 (add-hook 'magit-section-movement-hook 
#'magit-log-maybe-update-revision-buffer)
 
 (defun magit--maybe-update-revision-buffer ()
-  (when-let ((commit (magit-section-value-if 'commit))
-             (buffer (magit-get-mode-buffer 'magit-revision-mode nil t)))
+  (when-let* ((commit (magit-section-value-if 'commit))
+              (buffer (magit-get-mode-buffer 'magit-revision-mode nil t)))
     (if magit--update-revision-buffer
         (setq magit--update-revision-buffer (list commit buffer))
       (setq magit--update-revision-buffer (list commit buffer))
@@ -1464,11 +1465,11 @@ If there is no blob buffer in the same frame, then do 
nothing."
     (magit--maybe-update-blob-buffer)))
 
 (defun magit--maybe-update-blob-buffer ()
-  (when-let ((commit (magit-section-value-if 'commit))
-             (buffer (--first (with-current-buffer it
-                                (eq revert-buffer-function
-                                    'magit-revert-rev-file-buffer))
-                              (mapcar #'window-buffer (window-list)))))
+  (when-let* ((commit (magit-section-value-if 'commit))
+              (buffer (--first (with-current-buffer it
+                                 (eq revert-buffer-function
+                                     'magit-revert-rev-file-buffer))
+                               (mapcar #'window-buffer (window-list)))))
     (if magit--update-blob-buffer
         (setq magit--update-blob-buffer (list commit buffer))
       (setq magit--update-blob-buffer (list commit buffer))
diff --git a/lisp/magit-process.el b/lisp/magit-process.el
index 6945a4b1db..ef9a8ce79f 100644
--- a/lisp/magit-process.el
+++ b/lisp/magit-process.el
@@ -729,22 +729,22 @@ Magit status buffer."
   "Special sentinel used by `magit-run-git-sequencer'."
   (when (memq (process-status process) '(exit signal))
     (magit-process-sentinel process event)
-    (when-let ((process-buf (process-buffer process)))
-      (when (buffer-live-p process-buf)
-        (when-let ((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 (cadr (-split-at
-                                        (1+ (length 
magit-git-global-arguments))
-                                        (process-command process))))
-                       ((or "rebase" "am")   'rebase-sequence)
-                       ((or "cherry-pick" "revert") 'sequence)))
-                   (status)))
-              (goto-char (oref it start))
-              (magit-section-update-highlight))))))))
+    (when-let* ((process-buf (process-buffer process))
+                (- (buffer-live-p process-buf))
+                (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 (cadr (-split-at
+                                    (1+ (length magit-git-global-arguments))
+                                    (process-command process))))
+                   ((or "rebase" "am")   'rebase-sequence)
+                   ((or "cherry-pick" "revert") 'sequence)))
+               (status)))
+          (goto-char (oref it start))
+          (magit-section-update-highlight))))))
 
 (defun magit-process-filter (proc string)
   "Default filter used by `magit-start-process'."
diff --git a/lisp/magit-refs.el b/lisp/magit-refs.el
index c1216f919c..004e27b586 100644
--- a/lisp/magit-refs.el
+++ b/lisp/magit-refs.el
@@ -504,9 +504,9 @@ Insert a header line with the name and description of the
 current branch.  The description is taken from the Git variable
 `branch.<NAME>.description'; if that is undefined then no header
 line is inserted at all."
-  (when-let ((branch (magit-get-current-branch))
-             (desc (magit-get "branch" branch "description"))
-             (desc (split-string desc "\n")))
+  (when-let* ((branch (magit-get-current-branch))
+              (desc (magit-get "branch" branch "description"))
+              (desc (split-string desc "\n")))
     (when (equal (car (last desc)) "")
       (setq desc (butlast desc)))
     (magit-insert-section (branchdesc branch t)
diff --git a/lisp/magit-stash.el b/lisp/magit-stash.el
index 12b5d20bc4..eee2fa7961 100644
--- a/lisp/magit-stash.el
+++ b/lisp/magit-stash.el
@@ -463,8 +463,8 @@ If there is no stash buffer in the same frame, then do 
nothing."
     (magit--maybe-update-stash-buffer)))
 
 (defun magit--maybe-update-stash-buffer ()
-  (when-let ((stash  (magit-section-value-if 'stash))
-             (buffer (magit-get-mode-buffer 'magit-stash-mode nil t)))
+  (when-let* ((stash  (magit-section-value-if 'stash))
+              (buffer (magit-get-mode-buffer 'magit-stash-mode nil t)))
     (if magit--update-stash-buffer
         (setq magit--update-stash-buffer (list stash buffer))
       (setq magit--update-stash-buffer (list stash buffer))
diff --git a/lisp/magit-status.el b/lisp/magit-status.el
index d7a9a10090..6a244cf968 100644
--- a/lisp/magit-status.el
+++ b/lisp/magit-status.el
@@ -629,8 +629,8 @@ arguments are for internal use only."
 
 (defun magit-insert-push-branch-header ()
   "Insert a header line about the branch the current branch is pushed to."
-  (when-let ((branch (magit-get-current-branch))
-             (target (magit-get-push-branch branch)))
+  (when-let* ((branch (magit-get-current-branch))
+              (target (magit-get-push-branch branch)))
     (magit-insert-section (branch target)
       (insert (format "%-10s" "Push: "))
       (insert
@@ -702,10 +702,10 @@ arguments are for internal use only."
 If no remote is configured for the current branch, then fall back
 showing the \"origin\" remote, or if that does not exist the first
 remote in alphabetic order."
-  (when-let ((name (magit-get-some-remote))
-             ;; Under certain configurations it's possible for url
-             ;; to be nil, when name is not, see #2858.
-             (url (magit-get "remote" name "url")))
+  (when-let* ((name (magit-get-some-remote))
+              ;; Under certain configurations it's possible for
+              ;; url to be nil, when name is not, see #2858.
+              (url (magit-get "remote" name "url")))
     (magit-insert-section (remote name)
       (insert (format "%-10s" "Remote: "))
       (insert (propertize name 'font-lock-face 'magit-branch-remote) ?\s)

Reply via email to