From 509fb89d06f88364556ad04f6c7b66f395168ded Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Wed, 23 Dec 2020 19:30:46 -0500 Subject: Drop use of dash --- lisp/km-magit.el | 132 +++++++++++++++++++++++++++---------------------------- 1 file changed, 66 insertions(+), 66 deletions(-) (limited to 'lisp/km-magit.el') diff --git a/lisp/km-magit.el b/lisp/km-magit.el index a53768e..11584c1 100644 --- a/lisp/km-magit.el +++ b/lisp/km-magit.el @@ -128,17 +128,17 @@ branch." "Perform a fast-forward merge of the upstream branch. \n(git merge --no-edit --ff-only )" (interactive) - (--if-let (magit-get-upstream-branch) - (magit-merge-plain it '("--ff-only")) - (user-error "No upstream branch"))) + (magit-merge-plain (or (magit-get-upstream-branch) + (user-error "No upstream branch")) + '("--ff-only"))) (defun km/magit-ff-merge-push () "Perform a fast-forward merge of the push branch. \n(git merge --no-edit --ff-only )" (interactive) - (--if-let (magit-get-push-branch) - (magit-merge-plain it '("--ff-only")) - (user-error "No push branch"))) + (magit-merge-plain (or (magit-get-push-branch) + (user-error "No push branch")) + '("--ff-only"))) ;;;###autoload (defun km/magit-merge-pull-message (rev) @@ -154,9 +154,9 @@ second if REV is the name of a remote branch. This assumes that you are pulling PRs into your 'refs/pull/' namespace." - (-when-let (pr (--when-let (magit-rev-name rev "refs/pull/*") - (and (string-match "\\`pull/.+/\\([0-9]+\\)\\'" it) - (match-string 1 it)))) + (when-let ((name (magit-rev-name rev "refs/pull/*")) + (pr (and (string-match "\\`pull/.+/\\([0-9]+\\)\\'" name) + (match-string 1 name)))) (cond ((magit-local-branch-p rev) (format "Merge branch '%s' [#%s]" rev pr)) ((magit-remote-branch-p rev) @@ -208,8 +208,8 @@ This is equivalent to running `magit-branch-and-checkout' with START-POINT set to the current branch. \n(git checkout -b BRANCH)" (interactive (list (magit-read-string "Branch name" nil nil - (--when-let (magit-get-current-branch) - (concat it "-tmp"))))) + (when-let ((b (magit-get-current-branch))) + (concat b "-tmp"))))) (magit-run-git "checkout" "-b" branch)) (defun km/magit-branch--get-versions (branch suffix) @@ -532,15 +532,15 @@ argument." (defun km/magit-describe (rev) "Run 'git describe' on REV." (interactive - (list (or (-when-let (section (magit-current-section)) + (list (or (when-let ((section (magit-current-section))) (cond ((memq (oref section type) '(commit branch)) (oref section value)) ((derived-mode-p 'magit-revision-mode) magit-buffer-revision))) (magit-read-branch-or-commit "Revision")))) - (--when-let (and rev (magit-git-string "describe" rev)) - (kill-new (message "%s" it)))) + (when-let ((desc (and rev (magit-git-string "describe" rev)))) + (kill-new (message "%s" desc)))) (defun km/magit-rev-ancestor-p (rev-a rev-b) "Report whether REV-A is the ancestor of REV-B." @@ -687,10 +687,10 @@ argument. Interactively, this can be accessed using the command (concat push "..")) (t (concat ".." atpoint)))))) - (--when-let (and (derived-mode-p 'magit-revision-mode) - magit-buffer-revision) - (and (magit-rev-verify (concat it "^2")) - (concat it "^-1")))))) + (when-let ((rev (and (derived-mode-p 'magit-revision-mode) + magit-buffer-revision))) + (and (magit-rev-verify (concat rev "^2")) + (concat rev "^-1")))))) (if range (magit-log-setup-buffer (list range) args files) (call-interactively #'magit-log-current)))) @@ -731,35 +731,35 @@ argument. Interactively, this can be accessed using the command (defun km/magit-cherry-dwim () (interactive) - (-let [(head . upstream) - (if (eq major-mode 'magit-log-mode) - (let ((range magit-buffer-revisions)) - (and range - (string-match magit-range-re range) - (cons (match-string 3 range) - (match-string 1 range)))) - (let ((section (magit-current-section)) - (current-branch (magit-get-current-branch))) - (pcase (list (oref section type) - (oref section value)) - (`(unpushed "@{upstream}..") - (cons current-branch (magit-get-upstream-branch))) - (`(unpulled "..@{upstream}") - (cons (magit-get-upstream-branch) current-branch)) - ;; Don't try to match "@{push}" because - ;; `magit-insert-unpulled-from-pushremote' and - ;; `magit-insert-unpulled-from-pushremote' avoid it to - ;; be compatible with all push.default settings. - (`(unpushed ,_) - (cons current-branch (magit-get-push-branch))) - (`(unpulled ,_) - (cons (magit-get-push-branch) current-branch)))))] + (pcase-let ((`(,head . ,upstream) + (if (eq major-mode 'magit-log-mode) + (let ((range magit-buffer-revisions)) + (and range + (string-match magit-range-re range) + (cons (match-string 3 range) + (match-string 1 range)))) + (let ((section (magit-current-section)) + (current-branch (magit-get-current-branch))) + (pcase (list (oref section type) + (oref section value)) + (`(unpushed "@{upstream}..") + (cons current-branch (magit-get-upstream-branch))) + (`(unpulled "..@{upstream}") + (cons (magit-get-upstream-branch) current-branch)) + ;; Don't try to match "@{push}" because + ;; `magit-insert-unpulled-from-pushremote' and + ;; `magit-insert-unpulled-from-pushremote' avoid it to + ;; be compatible with all push.default settings. + (`(unpushed ,_) + (cons current-branch (magit-get-push-branch))) + (`(unpulled ,_) + (cons (magit-get-push-branch) current-branch))))))) (if (and head upstream) (magit-cherry head upstream) (call-interactively #'magit-cherry)))) (defun km/magit--insert-count-lines (rev counts) - (-let [(n-behind n-ahead) counts] + (pcase-let ((`(,n-behind ,n-ahead) counts)) (when (> n-ahead 0) (magit-insert-section (unpushed (concat rev "..")) (magit-insert-heading @@ -971,13 +971,13 @@ COMMIT." (km/magit-copy-commit-summary magit-buffer-revision))) (defun km/magit-copy-region-commits (&optional read-separator) - (--when-let (magit-region-values 'commit) + (when-let ((commit (magit-region-values 'commit))) (deactivate-mark) (kill-new (message "%s" (mapconcat #'identity - it + commit (if read-separator (read-string "Separator: ") ", ")))))) (defun km/magit-copy--truncated-message (msg) @@ -1031,12 +1031,12 @@ function." (defun km/magit-github-url-from-bugref () ;; `bug-reference-url-format' may be defined in an untracked ;; `.dir-locals.el`, so do this from the main worktree. - (-when-let* ((wtree (caar (magit-list-worktrees))) - (url - (with-temp-buffer - (let ((default-directory (file-name-as-directory wtree))) - (hack-dir-local-variables-non-file-buffer) - bug-reference-url-format)))) + (when-let ((wtree (caar (magit-list-worktrees))) + (url + (with-temp-buffer + (let ((default-directory (file-name-as-directory wtree))) + (hack-dir-local-variables-non-file-buffer) + bug-reference-url-format)))) (and url (string-match "\\`https://github.com/[^/]+/[^/]+" url) (match-string 0 url)))) @@ -1057,29 +1057,29 @@ function." (let ((ln (lambda (loc) (save-restriction (1+ (count-lines (point-min) loc)))))) - (-when-let* ((rev (or magit-buffer-revision - (magit-rev-parse "HEAD"))) - (fname (magit-file-relative-name)) - (lines (if (use-region-p) - (prog1 (format "%s-L%s" - (funcall ln (region-beginning)) - (1- (funcall ln (region-end)))) - (deactivate-mark)) - (funcall ln (point))))) + (when-let ((rev (or magit-buffer-revision + (magit-rev-parse "HEAD"))) + (fname (magit-file-relative-name)) + (lines (if (use-region-p) + (prog1 (format "%s-L%s" + (funcall ln (region-beginning)) + (1- (funcall ln (region-end)))) + (deactivate-mark)) + (funcall ln (point))))) (format "%s/blob/%s/%s#L%s" (or (km/magit-github-url) "") rev fname lines)))) (defun km/magit-github-commit-link () - (--when-let (or (and (eq major-mode 'magit-revision-mode) - magit-buffer-revision) - (and (derived-mode-p 'magit-mode) - (let ((sec (magit-current-section))) - (and (eq (oref sec type) 'commit) - (oref sec value))))) + (when-let ((rev (or (and (eq major-mode 'magit-revision-mode) + magit-buffer-revision) + (and (derived-mode-p 'magit-mode) + (let ((sec (magit-current-section))) + (and (eq (oref sec type) 'commit) + (oref sec value))))))) (format "%s/commit/%s" (or (km/magit-github-url) "") - (magit-rev-parse it)))) + (magit-rev-parse rev)))) (defun km/magit-github-diff-link () (when (derived-mode-p 'magit-diff-mode) -- cgit v1.2.3