branch: elpa/magit
commit da52ac901247b12241504e9baf89275c13b41def
Author: Jonas Bernoulli <[email protected]>
Commit: Jonas Bernoulli <[email protected]>

    Revert "Remove kludge for and-let* bug in older Emacs releases"
    
    This reverts commit 92020002b3f162e26af11f1a01c21bb18111b1cc.
    
    These `progn' used to be necessary because `and-let*' used to behave
    like `if'.  That bug was fixed in Emacs 27.1 -- since then it behaves
    like `when', as its author intended.
    
    However, going forward we will use the `and-let*' implementation from
    the `cond-let' package and that takes a single BODYFORM.  Sometimes
    it would be convenient if it supported multiple BODY forms and they
    behaved like those were wrapped with `progn' and other times like they
    were wrapped with `and', and we could determine which would be useful
    more often and the optimize for that.  Requiring an explicit `and' or
    `progn' is better, especially when the author is forced to call out
    the fact that there *also* is a side-effect.
---
 lisp/magit-diff.el | 40 +++++++++++++++++++++-------------------
 lisp/magit-git.el  | 19 +++++++++++--------
 lisp/magit-refs.el |  5 +++--
 3 files changed, 35 insertions(+), 29 deletions(-)

diff --git a/lisp/magit-diff.el b/lisp/magit-diff.el
index 2105d7e8849..1ccfb0db2bc 100644
--- a/lisp/magit-diff.el
+++ b/lisp/magit-diff.el
@@ -1176,8 +1176,9 @@ The information can be in three forms:
 If no DWIM context is found, nil is returned."
   (cond
    ((and-let* ((commits (magit-region-values '(commit branch) t)))
-      (deactivate-mark)
-      (concat (car (last commits)) ".." (car commits))))
+      (progn
+        (deactivate-mark)
+        (concat (car (last commits)) ".." (car commits)))))
    (magit-buffer-refname
     (cons 'commit magit-buffer-refname))
    ((derived-mode-p 'magit-stash-mode)
@@ -1231,23 +1232,24 @@ If no DWIM context is found, nil is returned."
   (and-let* ((commits (magit-region-values '(commit branch) t))
              (revA (car (last commits)))
              (revB (car commits)))
-    (when interactive
-      (deactivate-mark))
-    (if mbase
-        (let ((base (magit-git-string "merge-base" revA revB)))
-          (cond
-           ((string= (magit-rev-parse revA) base)
-            (format "%s..%s" revA revB))
-           ((string= (magit-rev-parse revB) base)
-            (format "%s..%s" revB revA))
-           (interactive
-            (let ((main (magit-completing-read "View changes along"
-                                               (list revA revB)
-                                               nil t nil nil revB)))
-              (format "%s...%s"
-                      (if (string= main revB) revA revB) main)))
-           ((format "%s...%s" revA revB))))
-      (format "%s..%s" revA revB))))
+    (progn
+      (when interactive
+        (deactivate-mark))
+      (if mbase
+          (let ((base (magit-git-string "merge-base" revA revB)))
+            (cond
+             ((string= (magit-rev-parse revA) base)
+              (format "%s..%s" revA revB))
+             ((string= (magit-rev-parse revB) base)
+              (format "%s..%s" revB revA))
+             (interactive
+              (let ((main (magit-completing-read "View changes along"
+                                                 (list revA revB)
+                                                 nil t nil nil revB)))
+                (format "%s...%s"
+                        (if (string= main revB) revA revB) main)))
+             ((format "%s...%s" revA revB))))
+        (format "%s..%s" revA revB)))))
 
 (defun magit-diff-read-range-or-commit (prompt &optional secondary-default 
mbase)
   "Read range or revision with special diff range treatment.
diff --git a/lisp/magit-git.el b/lisp/magit-git.el
index 60d6a592e0d..09537e84151 100644
--- a/lisp/magit-git.el
+++ b/lisp/magit-git.el
@@ -1494,10 +1494,11 @@ Git."
 
 (defun magit-name-tag (rev &optional lax)
   (and-let* ((name (magit-rev-name rev "refs/tags/*")))
-    (when (string-suffix-p "^0" name)
-      (setq name (substring name 0 -2)))
-    (and (or lax (not (string-match-p "[~^]" name)))
-         (substring name 5))))
+    (progn
+      (when (string-suffix-p "^0" name)
+        (setq name (substring name 0 -2)))
+      (and (or lax (not (string-match-p "[~^]" name)))
+           (substring name 5)))))
 
 (defun magit-ref-abbrev (refname)
   "Return an unambiguous abbreviation of REFNAME."
@@ -2337,8 +2338,9 @@ If `first-parent' is set, traverse only first parents."
 
 (defun magit-format-rev-summary (rev)
   (and-let* ((str (magit-rev-format "%h %s" rev)))
-    (magit--put-face 0 (string-match " " str) 'magit-hash str)
-    str))
+    (progn
+      (magit--put-face 0 (string-match " " str) 'magit-hash str)
+      str)))
 
 (defvar magit-ref-namespaces
   '(("\\`HEAD\\'"                  . magit-head)
@@ -2667,8 +2669,9 @@ and this option only controls what face is used.")
   (magit-read-range
    prompt
    (or (and-let* ((revs (magit-region-values '(commit branch) t)))
-         (deactivate-mark)
-         (concat (car (last revs)) ".." (car revs)))
+         (progn
+           (deactivate-mark)
+           (concat (car (last revs)) ".." (car revs))))
        (magit-branch-or-commit-at-point)
        secondary-default
        (magit-get-current-branch))))
diff --git a/lisp/magit-refs.el b/lisp/magit-refs.el
index 47bcf1e09d4..6b29c236e8a 100644
--- a/lisp/magit-refs.el
+++ b/lisp/magit-refs.el
@@ -366,8 +366,9 @@ Type \\[magit-reset] to reset `HEAD' to the commit at point.
            (and-let* ((buffer (magit-get-mode-buffer
                                'magit-refs-mode nil
                                (eq use-buffer-args 'selected))))
-             (setq args (buffer-local-value 'magit-buffer-arguments buffer))
-             t)))
+             (progn
+               (setq args (buffer-local-value 'magit-buffer-arguments buffer))
+               t))))
      (t
       (setq args (alist-get 'magit-show-refs transient-values))))
     args))

Reply via email to