[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/git-commit 41a0f6ed30 2/7: Use and-let* instead of when-le
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/git-commit 41a0f6ed30 2/7: Use and-let* instead of when-let* if value matters |
Date: |
Mon, 31 Jul 2023 13:00:11 -0400 (EDT) |
branch: elpa/git-commit
commit 41a0f6ed30f51245c0bb6b5876d7525730c5d17f
Author: Jonas Bernoulli <jonas@bernoul.li>
Commit: Jonas Bernoulli <jonas@bernoul.li>
Use and-let* instead of when-let* if value matters
---
lisp/magit-diff.el | 86 ++++++++++++++++++++++++++++--------------------------
lisp/magit-git.el | 18 +++++++-----
lisp/magit-refs.el | 11 +++----
3 files changed, 60 insertions(+), 55 deletions(-)
diff --git a/lisp/magit-diff.el b/lisp/magit-diff.el
index 745b203db6..c474db1533 100644
--- a/lisp/magit-diff.el
+++ b/lisp/magit-diff.el
@@ -1116,10 +1116,10 @@ The information can be in three forms:
If no DWIM context is found, nil is returned."
(cond
- ((when-let* ((commits (magit-region-values '(commit branch) t)))
- ;; Cannot use and-let* because of debbugs#31840.
- (deactivate-mark)
- (concat (car (last commits)) ".." (car commits))))
+ ((and-let* ((commits (magit-region-values '(commit branch) t)))
+ (progn ; work around debbugs#31840
+ (deactivate-mark)
+ (concat (car (last commits)) ".." (car commits)))))
(magit-buffer-refname
(cons 'commit magit-buffer-refname))
((derived-mode-p 'magit-stash-mode)
@@ -1168,26 +1168,27 @@ If no DWIM context is found, nil is returned."
(t range)))
(defun magit-diff--region-range (&optional interactive mbase)
- (when-let* ((commits (magit-region-values '(commit branch) t)) ;debbugs#31840
- (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)))
- (t "%s...%s" revA revB)))
- (format "%s..%s" revA revB))))
+ (and-let* ((commits (magit-region-values '(commit branch) t))
+ (revA (car (last commits)))
+ (revB (car commits)))
+ (progn ; work around debbugs#31840
+ (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)))
+ (t "%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.
@@ -1706,24 +1707,25 @@ the Magit-Status buffer for DIRECTORY."
(user-error "No file at point"))))
(defun magit-diff-visit--hunk ()
- (when-let* ((scope (magit-diff-scope)) ;debbugs#31840
- (section (magit-current-section)))
- (cl-case scope
- ((file files)
- (setq section (car (oref section children))))
- (list
- (setq section (car (oref section children)))
- (when section
- (setq section (car (oref section children))))))
- (and
- ;; Unmerged files appear in the list of staged changes
- ;; but unlike in the list of unstaged changes no diffs
- ;; are shown here. In that case `section' is nil.
- section
- ;; Currently the `hunk' type is also abused for file
- ;; mode changes, which we are not interested in here.
- (not (equal (oref section value) '(chmod)))
- section)))
+ (and-let* ((scope (magit-diff-scope))
+ (section (magit-current-section)))
+ (progn ; work around debbugs#31840
+ (cl-case scope
+ ((file files)
+ (setq section (car (oref section children))))
+ (list
+ (setq section (car (oref section children)))
+ (when section
+ (setq section (car (oref section children))))))
+ (and
+ ;; Unmerged files appear in the list of staged changes
+ ;; but unlike in the list of unstaged changes no diffs
+ ;; are shown here. In that case `section' is nil.
+ section
+ ;; Currently the `hunk' type is also abused for file
+ ;; mode changes, which we are not interested in here.
+ (not (equal (oref section value) '(chmod)))
+ section))))
(defun magit-diff-visit--goto-from-p (section in-worktree)
(and magit-diff-visit-previous-blob
diff --git a/lisp/magit-git.el b/lisp/magit-git.el
index 778f6d1551..db75252077 100644
--- a/lisp/magit-git.el
+++ b/lisp/magit-git.el
@@ -1462,11 +1462,12 @@ Git."
(substring name 8))))
(defun magit-name-tag (rev &optional lax)
- (when-let* ((name (magit-rev-name rev "refs/tags/*"))) ;debbugs#31840
- (when (string-suffix-p "^0" name)
- (setq name (substring name 0 -2)))
- (and (or lax (not (string-match-p "[~^]" name)))
- (substring name 5))))
+ (and-let* ((name (magit-rev-name rev "refs/tags/*")))
+ (progn ; work around debbugs#31840
+ (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."
@@ -2295,9 +2296,10 @@ If `first-parent' is set, traverse only first parents."
"--"))
(defun magit-format-rev-summary (rev)
- (when-let* ((str (magit-rev-format "%h %s" rev))) ;debbugs#31840
- (magit--put-face 0 (string-match " " str) 'magit-hash str)
- str))
+ (and-let* ((str (magit-rev-format "%h %s" rev)))
+ (progn ; work around debbugs#31840
+ (magit--put-face 0 (string-match " " str) 'magit-hash str)
+ str)))
(defvar magit-ref-namespaces
'(("\\`HEAD\\'" . magit-head)
diff --git a/lisp/magit-refs.el b/lisp/magit-refs.el
index e4b31c826d..92b6e8e4cb 100644
--- a/lisp/magit-refs.el
+++ b/lisp/magit-refs.el
@@ -354,11 +354,12 @@ Type \\[magit-reset] to reset `HEAD' to the commit at
point.
((eq major-mode 'magit-refs-mode)
(setq args magit-buffer-arguments))
((and (memq use-buffer-args '(always selected))
- (when-let* ((buffer (magit-get-mode-buffer ;debbugs#31840
- 'magit-refs-mode nil
- (eq use-buffer-args 'selected))))
- (setq args (buffer-local-value 'magit-buffer-arguments buffer))
- t)))
+ (and-let* ((buffer (magit-get-mode-buffer
+ 'magit-refs-mode nil
+ (eq use-buffer-args 'selected))))
+ (progn ; work around debbugs#31840
+ (setq args (buffer-local-value 'magit-buffer-arguments buffer))
+ t))))
(t
(setq args (alist-get 'magit-show-refs transient-values))))
args))
- [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, 2023/07/31
- [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 <=
- [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