diff options
| author | Jonas Bernoulli <jonas@bernoul.li> | 2025-08-22 20:55:38 +0200 |
|---|---|---|
| committer | Jonas Bernoulli <jonas@bernoul.li> | 2025-08-22 20:55:38 +0200 |
| commit | 1c48327a067c41f78f35cc65bdbf3067f1d3d25d (patch) | |
| tree | 2d93943ac31df9274f0b97030e4c1cdd1a753047 | |
| parent | fc69a08eb04af57b55d4f02b1dfe218daaa9b36a (diff) | |
Use Cond-Let's and$
Anaphoric macros get a bad rep and while my own infatuation was somewhat
short lived, there are cases where I still find them useful, such as in
the case of
(and$ (function-with-a-name-that-makes-if-obvious-what-is-returned)
(function-with-a-name-that-makes-if-obvious-what-is-expected $))
Many of the cases where this commits starts using `and$', fall squarely
into that category. There are a few where I an on the fence. That's
because I've just invented this macro and need some practice to fully
develop my sense of when it is, and is not, appropriate to use this
macro.
| -rw-r--r-- | lisp/magit-branch.el | 5 | ||||
| -rw-r--r-- | lisp/magit-diff.el | 26 | ||||
| -rw-r--r-- | lisp/magit-git.el | 63 | ||||
| -rw-r--r-- | lisp/magit-gitignore.el | 6 | ||||
| -rw-r--r-- | lisp/magit-log.el | 16 | ||||
| -rw-r--r-- | lisp/magit-mode.el | 4 | ||||
| -rw-r--r-- | lisp/magit-patch.el | 8 | ||||
| -rw-r--r-- | lisp/magit-process.el | 6 | ||||
| -rw-r--r-- | lisp/magit-repos.el | 20 | ||||
| -rw-r--r-- | lisp/magit-section.el | 80 | ||||
| -rw-r--r-- | lisp/magit-sequence.el | 15 | ||||
| -rw-r--r-- | lisp/magit-status.el | 4 | ||||
| -rw-r--r-- | lisp/magit-transient.el | 4 |
13 files changed, 126 insertions, 131 deletions
diff --git a/lisp/magit-branch.el b/lisp/magit-branch.el index 3b2b40f..064e938 100644 --- a/lisp/magit-branch.el +++ b/lisp/magit-branch.el @@ -787,9 +787,8 @@ the remote." (or (not (eq magit-branch-rename-push-target 'forge-only)) (and (require (quote forge) nil t) (fboundp 'forge--split-forge-url) - (and-let ((url (magit-git-string - "remote" "get-url" remote))) - (forge--split-forge-url url))))) + (and$ (magit-git-string "remote" "get-url" remote) + (forge--split-forge-url $))))) (let ((old-target (magit-get-push-branch old t)) (new-target (magit-get-push-branch new t)) (remote (magit-get-push-remote new))) diff --git a/lisp/magit-diff.el b/lisp/magit-diff.el index 45addb3..699d23f 100644 --- a/lisp/magit-diff.el +++ b/lisp/magit-diff.el @@ -2246,8 +2246,8 @@ keymap is the parent of their keymaps." (defun magit-diff-use-window-width-as-stat-width () "Use the `window-width' as the value of `--stat-width'." - (and-let ((window (get-buffer-window (current-buffer) 'visible))) - (list (format "--stat-width=%d" (window-width window))))) + (and$ (get-buffer-window (current-buffer) 'visible) + (list (format "--stat-width=%d" (window-width $))))) (defun magit-diff-wash-diffs (args &optional limit) (run-hooks 'magit-diff-wash-diffs-hook) @@ -2884,9 +2884,8 @@ or a ref which is not a branch, then it inserts nothing." "Insert headers about the commit into a revision buffer." (magit-insert-section (headers) (magit-insert-heading nil - (and-let ((string (magit-rev-format "%D" magit-buffer-revision - "--decorate=full"))) - (concat (magit-format-ref-labels string) " ")) + (and$ (magit-rev-format "%D" magit-buffer-revision "--decorate=full") + (concat (magit-format-ref-labels $) " ")) (propertize (magit-rev-parse (magit--rev-dereference magit-buffer-revision)) 'font-lock-face 'magit-hash)) @@ -3240,8 +3239,8 @@ actually a `diff' but a `diffstat' section." (when (and section (or (not strict) (and (not (eq (magit-diff-type section) 'untracked)) - (not (eq (and-let ((parent (oref section parent))) - (oref parent type)) + (not (eq (and$ (oref section parent) + (oref $ type)) 'diffstat))))) (pcase (list (oref section type) (and siblings t) @@ -3280,8 +3279,8 @@ actually a `diff' but a `diffstat' section." (pcase scope ('hunk section) ('file (first-hunk section)) - ('list (and-let ((first-file (car (oref section children)))) - (first-hunk first-file))) + ('list (and$ (car (oref section children)) + (first-hunk $))) ('module nil))))) (defun magit-diff--file-section () @@ -3371,11 +3370,10 @@ actually a `diff' but a `diffstat' section." (cond ((not magit-diff-adjust-tab-width) tab-width) - ((and-let ((buffer (find-buffer-visiting file))) - (cache (buffer-local-value 'tab-width buffer)))) - ((and-let ((elt (assoc file magit-diff--tab-width-cache))) - (or (cdr elt) - tab-width))) + ((and$ (find-buffer-visiting file) + (buffer-local-value 'tab-width $))) + ((and$ (assoc file magit-diff--tab-width-cache) + (or (cdr $) tab-width))) ((or (eq magit-diff-adjust-tab-width 'always) (and (numberp magit-diff-adjust-tab-width) (>= magit-diff-adjust-tab-width diff --git a/lisp/magit-git.el b/lisp/magit-git.el index a286805..b35431b 100644 --- a/lisp/magit-git.el +++ b/lisp/magit-git.el @@ -821,10 +821,8 @@ Also see `magit-git-config-p'." (defun magit-git-dir (&optional path) "Like (expand-file-name PATH (magit-gitdir)) or just (magit-gitdir)." (declare (obsolete magit-gitdir "Magit 4.0.0")) - (and-let ((dir (magit-gitdir))) - (if path - (expand-file-name (convert-standard-filename path) dir) - dir))) + (and$ (magit-gitdir) + (if path (expand-file-name (convert-standard-filename path) $) $))) (defun magit-gitdir (&optional directory) "Return the absolute and resolved path of the .git directory. @@ -1180,8 +1178,8 @@ range. Otherwise, it can be any revision or range accepted by Return nil, if FILE appears neither in REV nor OTHER-REV, or if no rename is detected." (or (car (member file (magit-revision-files rev))) - (and-let ((renamed (magit-renamed-files rev other-rev))) - (car (rassoc file renamed))))) + (and$ (magit-renamed-files rev other-rev) + (car (rassoc file $))))) (defun magit-file-status (&rest args) (magit--with-temp-process-buffer @@ -1341,10 +1339,10 @@ are considered." (defun magit-ignore-submodules-p (&optional return-argument) (or (cl-find-if (##string-prefix-p "--ignore-submodules" %) magit-buffer-diff-args) - (and-let ((value (magit-get "diff.ignoreSubmodules"))) - (if return-argument - (concat "--ignore-submodules=" value) - (concat "diff.ignoreSubmodules=" value))))) + (and$ (magit-get "diff.ignoreSubmodules") + (if return-argument + (concat "--ignore-submodules=" $) + (concat "diff.ignoreSubmodules=" $))))) ;;; Revisions and References @@ -1449,8 +1447,8 @@ Git." rev)) (defun magit-rev-branch (rev) - (and-let ((name (magit-rev-name rev "refs/heads/*"))) - (and (not (string-match-p "[~^]" name)) name))) + (and$ (magit-rev-name rev "refs/heads/*") + (and (not (string-match-p "[~^]" $)) $))) (defun magit-rev-fixup-target (rev) (let ((msg (magit-rev-format "%s" rev))) @@ -1480,13 +1478,13 @@ Git." (magit-name-remote-branch rev t))))) (defun magit-name-local-branch (rev &optional lax) - (and-let ((name (magit-rev-name rev "refs/heads/*"))) - (and (or lax (not (string-match-p "[~^]" name))) name))) + (and$ (magit-rev-name rev "refs/heads/*") + (and (or lax (not (string-match-p "[~^]" $))) $))) (defun magit-name-remote-branch (rev &optional lax) - (and-let ((name (magit-rev-name rev "refs/remotes/*"))) - (and (or lax (not (string-match-p "[~^]" name))) - (substring name 8)))) + (and$ (magit-rev-name rev "refs/remotes/*") + (and (or lax (not (string-match-p "[~^]" $))) + (substring $ 8)))) (defun magit-name-tag (rev &optional lax) (and-let ((name (magit-rev-name rev "refs/tags/*"))) @@ -1571,8 +1569,8 @@ to, or to some other symbolic-ref that points to the same ref." (memq (get-text-property (magit-point) 'font-lock-face) (list 'magit-branch-local 'magit-branch-current)) - (and-let ((branch (magit-thing-at-point 'git-revision t))) - (cdr (magit-split-branch-name branch)))) + (and$ (magit-thing-at-point 'git-revision t) + (cdr (magit-split-branch-name $)))) (and (not (eq type 'local)) (memq (get-text-property (magit-point) 'font-lock-face) (list 'magit-branch-remote @@ -1731,8 +1729,8 @@ if any, nil otherwise. If the upstream is not configured, the configured remote is an url, or the named branch does not exist, then return nil. I.e., return an existing local or remote-tracking branch ref." - (and-let ((branch (or branch (magit-get-current-branch)))) - (magit-ref-fullname (concat branch "@{upstream}")))) + (and$ (or branch (magit-get-current-branch)) + (magit-ref-fullname (concat $ "@{upstream}")))) (defun magit-get-upstream-branch (&optional branch) "Return the name of the upstream branch of BRANCH. @@ -1842,8 +1840,8 @@ according to the branch type." (defun magit-get-some-remote (&optional branch) (or (magit-get-remote branch) - (and-let ((main (magit-main-branch))) - (magit-get-remote main)) + (and$ (magit-main-branch) + (magit-get-remote $)) (magit-primary-remote) (car (magit-list-remotes)))) @@ -2104,11 +2102,10 @@ When nil, use `magit-list-refs-sortby'. If both are nil, use (magit-git-lines "ls-remote" remote))) (defun magit-remote-head (remote) - (and-let ((line (cl-find-if - (##string-match - "\\`ref: refs/heads/\\([^\s\t]+\\)[\s\t]HEAD\\'" %) - (magit-git-lines "ls-remote" "--symref" remote "HEAD")))) - (match-str 1 line))) + (and$ (cl-find-if (##string-match + "\\`ref: refs/heads/\\([^\s\t]+\\)[\s\t]HEAD\\'" %) + (magit-git-lines "ls-remote" "--symref" remote "HEAD")) + (match-str 1 $))) (defun magit-list-modified-modules () (seq-keep (##and (string-match "\\`\\+\\([^ ]+\\) \\(.+\\) (.+)\\'" %) @@ -2303,8 +2300,8 @@ If `first-parent' is set, traverse only first parents." "--not" rev))) (defun magit-commit-parents (rev) - (and-let ((str (magit-git-string "rev-list" "-1" "--parents" rev))) - (cdr (split-string str)))) + (and$ (magit-git-string "rev-list" "-1" "--parents" rev) + (cdr (split-string $)))) (defun magit-patch-id (rev) (with-connection-local-variables @@ -2520,9 +2517,9 @@ and this option only controls what face is used.") (setq end (magit--abbrev-if-hash end))) (pcase sep (".." (cons beg end)) - ("..." (and-let ((base (magit-git-string "merge-base" beg end))) - (cons (if abbrev (magit-rev-abbrev base) base) - end)))))) + ("..." (and$ (magit-git-string "merge-base" beg end) + (cons (if abbrev (magit-rev-abbrev $) $) + end)))))) (defun magit--split-range-raw (range) (and (string-match magit-range-re range) diff --git a/lisp/magit-gitignore.el b/lisp/magit-gitignore.el index 9bf0bfa..ef2bc7a 100644 --- a/lisp/magit-gitignore.el +++ b/lisp/magit-gitignore.el @@ -118,9 +118,9 @@ Rules that are defined in that file affect all local repositories." (mapcan (lambda (file) (cons (concat "/" file) - (and-let ((ext (file-name-extension file))) - (list (concat "/" (file-name-directory file) "*." ext) - (concat "*." ext))))) + (and$ (file-name-extension file) + (list (concat "/" (file-name-directory file) "*." $) + (concat "*." $))))) (sort (nconc (magit-untracked-files nil base) ;; The untracked section of the status buffer lists diff --git a/lisp/magit-log.el b/lisp/magit-log.el index bf9c1b2..96f34be 100644 --- a/lisp/magit-log.el +++ b/lisp/magit-log.el @@ -642,7 +642,7 @@ commits before and half after." "SPC" #'self-insert-command) (defun magit-log-read-revs (&optional use-current) - (or (and use-current (and-let ((buf (magit-get-current-branch))) (list buf))) + (or (and use-current (and$ (magit-get-current-branch) (list $))) (let ((crm-separator "\\(\\.\\.\\.?\\|[, ]\\)") (crm-local-completion-map magit-log-read-revs-map)) (split-string (magit-completing-read-multiple @@ -900,9 +900,9 @@ limit. Otherwise set it to 256." (magit-refresh)) (defun magit-log-get-commit-limit (&optional args) - (and-let ((str (seq-find (##string-match "^-n\\([0-9]+\\)?$" %) - (or args magit-buffer-log-args)))) - (string-to-number (match-str 1 str)))) + (and$ (seq-find (##string-match "^-n\\([0-9]+\\)?$" %) + (or args magit-buffer-log-args)) + (string-to-number (match-str 1 $)))) ;;;; Mode Commands @@ -954,14 +954,14 @@ of the current repository first; creating it if necessary." "In log, jump to" (magit-list-refnames nil t) nil 'any nil 'magit-revision-history - (or (and-let ((rev (magit-commit-at-point))) - (magit-rev-fixup-target rev)) + (or (and$ (magit-commit-at-point) + (magit-rev-fixup-target $)) (magit-get-current-branch))))) (with-current-buffer (cond ((derived-mode-p 'magit-log-mode) (current-buffer)) - ((and-let ((buf (magit-get-mode-buffer 'magit-log-mode))) - (pop-to-buffer-same-window buf))) + ((and$ (magit-get-mode-buffer 'magit-log-mode) + (pop-to-buffer-same-window $))) (t (apply #'magit-log-all-branches (magit-log-arguments)))) (unless (magit-log-goto-commit-section (magit-rev-abbrev commit)) diff --git a/lisp/magit-mode.el b/lisp/magit-mode.el index 412855f..92b469c 100644 --- a/lisp/magit-mode.el +++ b/lisp/magit-mode.el @@ -1144,8 +1144,8 @@ The arguments are for internal use." ;; each window displaying the buffer). The selected window ;; comes first in this list, but we want to process it last. (nreverse (get-buffer-window-list buffer nil t)))) - (and-let ((section (magit-section-at))) - `((nil ,section ,@(magit-section-get-relative-position section)))))) + (and$ (magit-section-at) + `((nil ,$ ,@(magit-section-get-relative-position $)))))) (defun magit--refresh-buffer-set-positions (positions) (pcase-dolist diff --git a/lisp/magit-patch.el b/lisp/magit-patch.el index 43ca9c6..e592521 100644 --- a/lisp/magit-patch.el +++ b/lisp/magit-patch.el @@ -116,8 +116,8 @@ which creates patches for all commits that are reachable from (save-match-data (find-file (expand-file-name - (concat (and-let ((v (transient-arg-value "--reroll-count=" args))) - (format "v%s-" v)) + (concat (and$ (transient-arg-value "--reroll-count=" args) + (format "v%s-" $)) "0000-cover-letter.patch") (let ((topdir (magit-toplevel))) (if-let ((dir (transient-arg-value "--output-directory=" args))) @@ -250,8 +250,8 @@ which creates patches for all commits that are reachable from (list (expand-file-name (read-file-name "Apply patch: " default-directory nil nil - (and-let ((file (magit-file-at-point))) - (file-relative-name file)))) + (and$ (magit-file-at-point) + (file-relative-name $)))) (transient-args 'magit-patch-apply)))) (if (not file) (transient-setup 'magit-patch-apply) diff --git a/lisp/magit-process.el b/lisp/magit-process.el index 2f0a57f..6f3d2bc 100644 --- a/lisp/magit-process.el +++ b/lisp/magit-process.el @@ -1026,9 +1026,9 @@ from the user." magit-process-password-prompt-regexps string))) (process-send-string process - (concat (or (and-let ((key (match-str 99 string))) - (run-hook-with-args-until-success - 'magit-process-find-password-functions key)) + (concat (or (and$ (match-str 99 string) + (run-hook-with-args-until-success + 'magit-process-find-password-functions $)) (let ((read-passwd-map (magit-process-make-keymap process read-passwd-map))) (read-passwd prompt))) diff --git a/lisp/magit-repos.el b/lisp/magit-repos.el index c79d6e6..e6147a1 100644 --- a/lisp/magit-repos.el +++ b/lisp/magit-repos.el @@ -439,23 +439,27 @@ which only lists the first one found." (defun magit-repolist-column-unpulled-from-upstream (spec) "Insert number of upstream commits not in the current branch." - (and-let ((br (magit-get-upstream-branch))) - (magit-repolist-insert-count (cadr (magit-rev-diff-count "HEAD" br)) spec))) + (and$ (magit-get-upstream-branch) + (magit-repolist-insert-count (cadr (magit-rev-diff-count "HEAD" $)) + spec))) (defun magit-repolist-column-unpulled-from-pushremote (spec) "Insert number of commits in the push branch but not the current branch." - (and-let ((br (magit-get-push-branch nil t))) - (magit-repolist-insert-count (cadr (magit-rev-diff-count "HEAD" br)) spec))) + (and$ (magit-get-push-branch nil t) + (magit-repolist-insert-count (cadr (magit-rev-diff-count "HEAD" $)) + spec))) (defun magit-repolist-column-unpushed-to-upstream (spec) "Insert number of commits in the current branch but not its upstream." - (and-let ((br (magit-get-upstream-branch))) - (magit-repolist-insert-count (car (magit-rev-diff-count "HEAD" br)) spec))) + (and$ (magit-get-upstream-branch) + (magit-repolist-insert-count (car (magit-rev-diff-count "HEAD" $)) + spec))) (defun magit-repolist-column-unpushed-to-pushremote (spec) "Insert number of commits in the current branch but not its push branch." - (and-let ((br (magit-get-push-branch nil t))) - (magit-repolist-insert-count (car (magit-rev-diff-count "HEAD" br)) spec))) + (and$ (magit-get-push-branch nil t) + (magit-repolist-insert-count (car (magit-rev-diff-count "HEAD" $)) + spec))) (defun magit-repolist-column-branches (spec) "Insert number of branches." diff --git a/lisp/magit-section.el b/lisp/magit-section.el index 97e097d..dd753dc 100644 --- a/lisp/magit-section.el +++ b/lisp/magit-section.el @@ -520,8 +520,8 @@ the click occurred. Otherwise return the section at point." The return value has the form ((TYPE . VALUE)...)." (cons (cons (oref section type) (magit-section-ident-value section)) - (and-let ((parent (oref section parent))) - (magit-section-ident parent)))) + (and$ (oref section parent) + (magit-section-ident $)))) (defun magit-section-equal (a b) "Return t if A an B are the same section." @@ -581,8 +581,8 @@ instead of in the one whose root `magit-root-section' is." If optional RAW is non-nil, return a list of section objects, beginning with SECTION, otherwise return a list of section types." (cons (if raw section (oref section type)) - (and-let ((parent (oref section parent))) - (magit-section-lineage parent raw)))) + (and$ (oref section parent) + (magit-section-lineage $ raw)))) (defvar-local magit-insert-section--current nil "For internal use only.") (defvar-local magit-insert-section--parent nil "For internal use only.") @@ -1017,8 +1017,8 @@ global map, this involves advising `tab-bar--define-keys'." (defun magit-section-hidden (section) "Return t if SECTION and/or an ancestor is hidden." (or (oref section hidden) - (and-let ((parent (oref section parent))) - (magit-section-hidden parent)))) + (and$ (oref section parent) + (magit-section-hidden $)))) (defun magit-section-hidden-body (section &optional pred) "Return t if the content of SECTION or of any children is hidden." @@ -1037,8 +1037,8 @@ global map, this involves advising `tab-bar--define-keys'." When the body of an ancestor of SECTION is collapsed then SECTION's body (and heading) obviously cannot be visible." (or (oref section hidden) - (and-let ((parent (oref section parent))) - (magit-section-invisible-p parent)))) + (and$ (oref section parent) + (magit-section-invisible-p $)))) (defun magit-section-show-level (level) "Show surrounding sections up to LEVEL. @@ -1143,14 +1143,14 @@ or when INTERACTIVE is non-nil, show the section in the echo area." (if ident (magit-section-ident section) (apply #'vector (magit-section-lineage section))) - (and-let ((m (oref section start))) - (if (markerp m) (marker-position m) m)) + (and$ (oref section start) + (if (markerp $) (marker-position $) $)) (if-let ((m (oref section content))) (format "[%s-]" (if (markerp m) (marker-position m) m)) "") - (and-let ((m (oref section end))) - (if (markerp m) (marker-position m) m))))) + (and$ (oref section end) + (if (markerp $) (marker-position $) $))))) (when interactive (message "%s" str)) str)) @@ -1248,8 +1248,8 @@ of course you want to be that precise." (defun magit-section-match-2 (condition section) (if (eq (car condition) '*) (or (magit-section-match-2 (cdr condition) section) - (and-let ((parent (oref section parent))) - (magit-section-match-2 condition parent))) + (and$ (oref section parent) + (magit-section-match-2 condition $))) (and (cond-let [[c (car condition)]] ((class-p c) @@ -1258,8 +1258,8 @@ of course you want to be that precise." (cl-typep section class)) ((eq (oref section type) c))) (or (not (setq condition (cdr condition))) - (and-let ((parent (oref section parent))) - (magit-section-match-2 condition parent)))))) + (and$ (oref section parent) + (magit-section-match-2 condition $)))))) (defun magit-section-value-if (condition &optional section) "If the section at point matches CONDITION, then return its value. @@ -1270,9 +1270,9 @@ then return nil. If the section does not match, then return nil. See `magit-section-match' for the forms CONDITION can take." - (and-let ((section (or section (magit-current-section)))) - (and (magit-section-match condition section) - (oref section value)))) + (and$ (or section (magit-current-section)) + (and (magit-section-match condition $) + (oref $ value)))) (defmacro magit-section-case (&rest clauses) "Choose among clauses on the type of the section at point. @@ -1576,8 +1576,8 @@ is explicitly expanded." (defun magit-section--set-section-properties (section) (pcase-let* (((eieio start end children keymap) section) (props `( magit-section ,section - ,@(and-let ((map (symbol-value keymap))) - (list 'keymap map))))) + ,@(and$ (symbol-value keymap) + (list 'keymap $))))) (if children (save-excursion (goto-char start) @@ -1776,8 +1776,8 @@ evaluated its BODY. Admittedly that's a bit of a hack." (and as-child (oref section heading-highlight-face)) (slot-boundp section 'painted) - (and-let ((children (oref section children))) - (magit-section-selective-highlight-p (car children) t)))) + (and$ (oref section children) + (magit-section-selective-highlight-p (car $) t)))) ;;; Paint @@ -1890,19 +1890,19 @@ to nil." (bound-and-true-p long-line-threshold)) :warning))))) (oref found start))))) (defun magit-section-goto-successor--related-1 (section) - (or (and-let ((alt (pcase (oref section type) - ('staged 'unstaged) - ('unstaged 'staged) - ('unpushed 'unpulled) - ('unpulled 'unpushed)))) - (magit-get-section `((,alt) (status)))) - (and-let ((next (car (magit-section-siblings section 'next)))) - (magit-get-section (magit-section-ident next))) - (and-let ((prev (car (magit-section-siblings section 'prev)))) - (magit-get-section (magit-section-ident prev))) - (and-let ((parent (oref section parent))) - (or (magit-get-section (magit-section-ident parent)) - (magit-section-goto-successor--related-1 parent))))) + (or (and$ (pcase (oref section type) + ('staged 'unstaged) + ('unstaged 'staged) + ('unpushed 'unpulled) + ('unpulled 'unpushed)) + (magit-get-section `((,$) (status)))) + (and$ (magit-section-siblings section 'next) + (magit-get-section (magit-section-ident (car $)))) + (and$ (magit-section-siblings section 'prev) + (magit-get-section (magit-section-ident (car $)))) + (and$ (oref section parent) + (or (magit-get-section (magit-section-ident $)) + (magit-section-goto-successor--related-1 $))))) ;;; Region @@ -2079,12 +2079,12 @@ When `magit-section-preserve-visibility' is nil, return nil." (memq section (if sselection selection (setq selection (magit-region-sections)))) - (and-let ((parent (oref section parent))) - (magit-section-selected-p parent selection))))) + (and$ (oref section parent) + (magit-section-selected-p $ selection))))) (defun magit-section-parent-value (section) - (and-let ((parent (oref section parent))) - (oref parent value))) + (and$ (oref section parent) + (oref $ value))) (defun magit-section-siblings (section &optional direction) "Return a list of the sibling sections of SECTION. diff --git a/lisp/magit-sequence.el b/lisp/magit-sequence.el index 123bf72..1195935 100644 --- a/lisp/magit-sequence.el +++ b/lisp/magit-sequence.el @@ -361,9 +361,8 @@ the process manually." (or (file-exists-p (expand-file-name "CHERRY_PICK_HEAD" dir)) ;; And CHERRY_PICK_HEAD does not exist when a conflict happens ;; while picking a series of commits with --no-commit. - (and-let ((line (magit-file-line - (expand-file-name "sequencer/todo" dir)))) - (string-prefix-p "pick" line))))) + (and$ (magit-file-line (expand-file-name "sequencer/todo" dir)) + (string-prefix-p "pick" $))))) ;;; Revert @@ -419,9 +418,8 @@ without prompting." (or (file-exists-p (expand-file-name "REVERT_HEAD" dir)) ;; And REVERT_HEAD does not exist when a conflict happens ;; while reverting a series of commits with --no-commit. - (and-let ((line (magit-file-line - (expand-file-name "sequencer/todo" dir)))) - (string-prefix-p "revert" line))))) + (and$ (magit-file-line (expand-file-name "sequencer/todo" dir)) + (string-prefix-p "revert" $))))) ;;; Patch @@ -1031,9 +1029,8 @@ status buffer (i.e., the reverse of how they will be applied)." (magit-sequence-insert-sequence (magit-file-line (expand-file-name "rebase-merge/stopped-sha" dir)) onto - (and-let ((lines (magit-file-lines - (expand-file-name "rebase-merge/done" dir)))) - (cadr (split-string (car (last lines)))))))) + (and$ (magit-file-lines (expand-file-name "rebase-merge/done" dir)) + (cadr (split-string (car (last $)))))))) (defun magit-rebase-insert-apply-sequence (onto) (let* ((dir (magit-gitdir)) diff --git a/lisp/magit-status.el b/lisp/magit-status.el index 5777444..d499b0d 100644 --- a/lisp/magit-status.el +++ b/lisp/magit-status.el @@ -454,8 +454,8 @@ Type \\[magit-commit] to create a commit. (`(,largs ,lfiles) (magit-log--get-value 'magit-status-mode 'status))) (magit-setup-buffer #'magit-status-mode nil :initial-section #'magit-status-goto-initial-section - :select-section (and-let ((args (magit-status--get-file-position))) - (lambda () (apply #'magit-status--goto-file-position args))) + :select-section (and$ (magit-status--get-file-position) + (lambda () (apply #'magit-status--goto-file-position $))) (magit-buffer-diff-args dargs) (magit-buffer-diff-files dfiles) (magit-buffer-log-args largs) diff --git a/lisp/magit-transient.el b/lisp/magit-transient.el index 8fa9d5c..7a111d6 100644 --- a/lisp/magit-transient.el +++ b/lisp/magit-transient.el @@ -192,8 +192,8 @@ (default (if (functionp defaultp) (funcall defaultp obj) defaultp)) (fallback (oref obj fallback)) (fallback (and fallback - (and-let ((val (magit-get fallback))) - (concat fallback ":" val))))) + (and$ (magit-get fallback) + (concat fallback ":" $))))) (if (not globalp) (setq value (magit-git-string "config" "--local" variable)) (setq value global) |
