Commit 637f7718 authored by Jonas Bernoulli's avatar Jonas Bernoulli

Revert "avoid backquote in pcase uses"

This reverts commit 5d39492d.

See #2572.
parent fd992a41
......@@ -324,7 +324,7 @@ remove the command on the current line, if any."
(setq initial (match-string-no-properties 2))))
(setq command (read-shell-command "Execute: " initial))
(pcase (list command initial)
('("" nil) (ding))
(`("" nil) (ding))
(`("" ,_)
(delete-region (match-beginning 0) (1+ (match-end 0))))
(`(,_ nil)
......
......@@ -76,9 +76,9 @@ With a prefix argument and if necessary, attempt a 3-way merge."
(interactive (and current-prefix-arg (list "--3way")))
(--when-let (magit-apply--get-selection)
(pcase (list (magit-diff-type) (magit-diff-scope))
(`(,(or 'unstaged 'staged) ,_)
(`(,(or `unstaged `staged) ,_)
(user-error "Change is already in the working tree"))
(`(untracked ,(or 'file 'files))
(`(untracked ,(or `file `files))
(magit-am-popup))
(`(,_ region) (magit-apply-region it args))
(`(,_ hunk) (magit-apply-hunk it args))
......@@ -157,9 +157,9 @@ With a prefix argument and if necessary, attempt a 3-way merge."
(or (magit-region-sections 'hunk 'file)
(let ((section (magit-current-section)))
(pcase (magit-section-type section)
((or 'hunk 'file) section)
((or 'staged 'unstaged 'untracked
'stashed-index 'stashed-worktree 'stashed-untracked)
((or `hunk `file) section)
((or `staged `unstaged `untracked
`stashed-index `stashed-worktree `stashed-untracked)
(magit-section-children section))
(_ (user-error "Cannot apply this, it's not a change"))))))
......@@ -181,12 +181,12 @@ With a prefix argument and if necessary, attempt a 3-way merge."
(--when-let (magit-apply--get-selection)
(pcase (list (magit-diff-type) (magit-diff-scope))
(`(untracked ,_) (magit-stage-untracked))
('(unstaged region) (magit-apply-region it "--cached"))
('(unstaged hunk) (magit-apply-hunk it "--cached"))
('(unstaged hunks) (magit-apply-hunks it "--cached"))
('(unstaged file) (magit-stage-1 "-u" (list (magit-section-value it))))
('(unstaged files) (magit-stage-1 "-u" (magit-region-values)))
('(unstaged list) (magit-stage-1 "-u"))
(`(unstaged region) (magit-apply-region it "--cached"))
(`(unstaged hunk) (magit-apply-hunk it "--cached"))
(`(unstaged hunks) (magit-apply-hunks it "--cached"))
(`(unstaged file) (magit-stage-1 "-u" (list (magit-section-value it))))
(`(unstaged files) (magit-stage-1 "-u" (magit-region-values)))
(`(unstaged list) (magit-stage-1 "-u"))
(`(staged ,_) (user-error "Already staged"))
(`(committed ,_) (user-error "Cannot stage committed changes"))
(`(undefined ,_) (user-error "Cannot stage this change")))))
......@@ -235,9 +235,9 @@ ignored) files.
(defun magit-stage-untracked ()
(let* ((section (magit-current-section))
(files (pcase (magit-diff-scope)
('file (list (magit-section-value section)))
('files (magit-region-values))
('list (magit-untracked-files))))
(`file (list (magit-section-value section)))
(`files (magit-region-values))
(`list (magit-untracked-files))))
plain repos)
(dolist (file files)
(if (magit-git-repo-p file t)
......@@ -265,12 +265,12 @@ ignored) files.
(pcase (list (magit-diff-type) (magit-diff-scope))
(`(untracked ,_) (user-error "Cannot unstage untracked changes"))
(`(unstaged ,_) (user-error "Already unstaged"))
('(staged region) (magit-apply-region it "--reverse" "--cached"))
('(staged hunk) (magit-apply-hunk it "--reverse" "--cached"))
('(staged hunks) (magit-apply-hunks it "--reverse" "--cached"))
('(staged file) (magit-unstage-1 (list (magit-section-value it))))
('(staged files) (magit-unstage-1 (magit-region-values)))
('(staged list) (magit-unstage-all))
(`(staged region) (magit-apply-region it "--reverse" "--cached"))
(`(staged hunk) (magit-apply-hunk it "--reverse" "--cached"))
(`(staged hunks) (magit-apply-hunks it "--reverse" "--cached"))
(`(staged file) (magit-unstage-1 (list (magit-section-value it))))
(`(staged files) (magit-unstage-1 (magit-region-values)))
(`(staged list) (magit-unstage-all))
(`(committed ,_) (if magit-unstage-committed
(magit-reverse-in-index)
(user-error "Cannot unstage committed changes")))
......@@ -382,20 +382,20 @@ without requiring confirmation."
(let ((file (magit-section-value section)))
(push file files)
(pcase (cons (pcase type
('staged ?X)
('unstaged ?Y)
('untracked ?Z))
(`staged ?X)
(`unstaged ?Y)
(`untracked ?Z))
(cddr (assoc file status)))
('(?Z) (--each (magit-untracked-files nil file)
(`(?Z) (--each (magit-untracked-files nil file)
(push it delete)))
((or '(?Z ?? ??) '(?Z ?! ?!)) (push file delete))
((or '(?Z ?D ? ) `(,_ ?D ?D)) (push file delete))
((or `(?Z ?? ??) `(?Z ?! ?!)) (push file delete))
((or `(?Z ?D ? ) `(,_ ?D ?D)) (push file delete))
((or `(,_ ?U ,_) `(,_ ,_ ?U)) (push file resolve))
(`(,_ ?A ?A) (push file resolve))
(`(?X ?M ,(or ? ?M ?D)) (push section discard))
(`(?Y ,_ ?M ) (push section discard))
('(?X ?A ?M ) (push file discard-new))
('(?X ?C ?M ) (push file discard-new))
(`(?X ?A ?M ) (push file discard-new))
(`(?X ?C ?M ) (push file discard-new))
(`(?X ?A ,(or ? ?D)) (push file delete))
(`(?X ?C ,(or ? ?D)) (push file delete))
(`(?X ?D ,(or ? ?M )) (push file resurrect))
......
......@@ -299,10 +299,10 @@ depending on the value of option `magit-commit-squash-confirm'."
(--when-let (and git-commit-mode
magit-commit-show-diff
(pcase last-command
('magit-commit
(`magit-commit
(apply-partially 'magit-diff-staged nil))
('magit-commit-amend 'magit-diff-while-amending)
('magit-commit-reword 'magit-diff-while-amending)))
(`magit-commit-amend 'magit-diff-while-amending)
(`magit-commit-reword 'magit-diff-while-amending)))
(condition-case nil
(let ((magit-inhibit-save-previous-winconf 'unset)
(magit-display-buffer-noselect t)
......
......@@ -579,8 +579,8 @@ buffer."
(interactive "P")
(let ((magit-diff-refresh-popup
(pcase major-mode
('magit-revision-mode magit-revision-mode-refresh-popup)
('magit-diff-mode magit-diff-mode-refresh-popup)
(`magit-revision-mode magit-revision-mode-refresh-popup)
(`magit-diff-mode magit-diff-mode-refresh-popup)
(_ magit-diff-refresh-popup)))
(magit-diff-arguments
(if (derived-mode-p 'magit-diff-mode)
......@@ -602,8 +602,8 @@ buffer."
"Show changes for the thing at point."
(interactive (magit-diff-arguments))
(pcase (magit-diff--dwim)
('unstaged (magit-diff-unstaged args files))
('staged (magit-diff-staged nil args files))
(`unstaged (magit-diff-unstaged args files))
(`staged (magit-diff-staged nil args files))
(`(commit . ,value)
(magit-diff (format "%s^..%s" value value) args files))
(`(stash . ,value) (magit-stash-show value args))
......@@ -967,9 +967,9 @@ which, as the name suggests always visits the actual file."
(setq rev nil))
(setq hunk
(pcase (magit-diff-scope)
((or 'hunk 'region) current)
((or 'file 'files) (car (magit-section-children current)))
('list (car (magit-section-children
((or `hunk `region) current)
((or `file `files) (car (magit-section-children current)))
(`list (car (magit-section-children
(car (magit-section-children current)))))))
(when (and hunk
;; Currently the `hunk' type is also abused for file
......@@ -1131,8 +1131,8 @@ commit or stash at point, then prompt for a commit."
(funcall fn)
(error
(goto-char (pcase fn
('scroll-up (point-min))
('scroll-down (point-max)))))))
(`scroll-up (point-min))
(`scroll-down (point-max)))))))
(let ((magit-display-buffer-noselect t))
(if (eq cmd 'magit-show-commit)
(apply #'magit-show-commit rev (magit-diff-arguments))
......@@ -1325,13 +1325,13 @@ section or a child thereof."
(insert (propertize
(format "unmerged %s%s" file
(pcase (cddr (car (magit-file-status file)))
('(?D ?D) " (both deleted)")
('(?D ?U) " (deleted by us)")
('(?U ?D) " (deleted by them)")
('(?A ?A) " (both added)")
('(?A ?U) " (added by us)")
('(?U ?A) " (added by them)")
('(?U ?U) "")))
(`(?D ?D) " (both deleted)")
(`(?D ?U) " (deleted by us)")
(`(?U ?D) " (deleted by them)")
(`(?A ?A) " (both added)")
(`(?A ?U) " (added by us)")
(`(?U ?A) " (added by them)")
(`(?U ?U) "")))
'face 'magit-diff-file-heading))
(insert ?\n))))
t)
......@@ -1782,12 +1782,12 @@ Do not confuse this with `magit-diff-scope' (which see)."
(if (memq stype '(staged unstaged tracked untracked))
stype
(pcase stype
('file (let* ((parent (magit-section-parent it))
(`file (let* ((parent (magit-section-parent it))
(type (magit-section-type parent)))
(if (eq type 'file)
(magit-diff-type parent)
type)))
('hunk (-> it magit-section-parent magit-section-parent
(`hunk (-> it magit-section-parent magit-section-parent
magit-section-type))))))
((derived-mode-p 'magit-log-mode)
(if (or (and (magit-section-match 'commit section)
......@@ -1831,11 +1831,11 @@ actually a `diff' but a `diffstat' section."
ssection)
(`(hunk nil t ,_)
(if (magit-section-internal-region-p section) 'region 'hunk))
('(hunk t t nil) 'hunks)
(`(hunk t t nil) 'hunks)
(`(hunk ,_ ,_ ,_) 'hunk)
('(file t t nil) 'files)
(`(file t t nil) 'files)
(`(file ,_ ,_ ,_) 'file)
(`(,(or 'staged 'unstaged 'untracked)
(`(,(or `staged `unstaged `untracked)
nil ,_ ,_) 'list)))))
;;; Diff Highlight
......@@ -1871,9 +1871,9 @@ are highlighted."
(defun magit-diff-highlight-recursive (section &optional selection)
(pcase (magit-diff-scope section)
('list (magit-diff-highlight-list section selection))
('file (magit-diff-highlight-file section selection))
('hunk (magit-diff-highlight-heading section selection)
(`list (magit-diff-highlight-list section selection))
(`file (magit-diff-highlight-file section selection))
(`hunk (magit-diff-highlight-heading section selection)
(magit-diff-paint-hunk section selection t))
(_ (magit-section-highlight section nil))))
......@@ -1903,10 +1903,10 @@ are highlighted."
(magit-section-end section))
(pcase (list (magit-section-type section)
(and (member section selection) t))
('(file t) 'magit-diff-file-heading-selection)
('(file nil) 'magit-diff-file-heading-highlight)
('(hunk t) 'magit-diff-hunk-heading-selection)
('(hunk nil) 'magit-diff-hunk-heading-highlight))))
(`(file t) 'magit-diff-file-heading-selection)
(`(file nil) 'magit-diff-file-heading-highlight)
(`(hunk t) 'magit-diff-hunk-heading-selection)
(`(hunk nil) 'magit-diff-hunk-heading-highlight))))
;;; Hunk Paint
......@@ -1945,13 +1945,13 @@ are highlighted."
(cond
((looking-at "^\\+\\+?\\([<=|>]\\)\\{7\\}")
(setq stage (pcase (list (match-string 1) highlight)
('("<" nil) 'magit-diff-our)
('("<" t) 'magit-diff-our-highlight)
('("|" nil) 'magit-diff-base)
('("|" t) 'magit-diff-base-highlight)
('("=" nil) 'magit-diff-their)
('("=" t) 'magit-diff-their-highlight)
('(">" nil) nil)))
(`("<" nil) 'magit-diff-our)
(`("<" t) 'magit-diff-our-highlight)
(`("|" nil) 'magit-diff-base)
(`("|" t) 'magit-diff-base-highlight)
(`("=" nil) 'magit-diff-their)
(`("=" t) 'magit-diff-their-highlight)
(`(">" nil) nil)))
'magit-diff-conflict-heading)
((looking-at (if merging "^\\(\\+\\| \\+\\)" "^\\+"))
(magit-diff-paint-whitespace merging)
......@@ -1998,14 +1998,14 @@ are highlighted."
(pcase (list magit-diff-refine-hunk
(magit-section-refined section)
(eq section (magit-current-section)))
((or `(all nil ,_) '(t nil t))
((or `(all nil ,_) `(t nil t))
(setf (magit-section-refined section) t)
(save-excursion
(goto-char (magit-section-start section))
;; `diff-refine-hunk' does not handle combined diffs.
(unless (looking-at "@@@")
(diff-refine-hunk))))
((or `(nil t ,_) '(t t nil))
((or `(nil t ,_) `(t t nil))
(setf (magit-section-refined section) nil)
(remove-overlays (magit-section-start section)
(magit-section-end section)
......
......@@ -256,12 +256,12 @@ mind at all, then it asks the user for a command to run."
command revA revB)
(pcase range
((and (guard (not magit-ediff-dwim-show-on-hunks))
(or 'unstaged 'staged))
(or `unstaged `staged))
(setq command (if (magit-anything-unmerged-p)
#'magit-ediff-resolve
#'magit-ediff-stage)))
('unstaged (setq command #'magit-ediff-show-unstaged))
('staged (setq command #'magit-ediff-show-staged))
(`unstaged (setq command #'magit-ediff-show-unstaged))
(`staged (setq command #'magit-ediff-show-staged))
(`(commit . ,value)
(setq command #'magit-ediff-show-commit
revB value))
......@@ -273,14 +273,14 @@ mind at all, then it asks the user for a command to run."
(_
(when (derived-mode-p 'magit-diff-mode)
(pcase (magit-diff-type)
('committed (-let [(a b) (magit-ediff-compare--read-revisions
(`committed (-let [(a b) (magit-ediff-compare--read-revisions
(car magit-refresh-args))]
(setq revA a revB b)))
((guard (not magit-ediff-dwim-show-on-hunks))
(setq command #'magit-ediff-stage))
('unstaged (setq command #'magit-ediff-show-unstaged))
('staged (setq command #'magit-ediff-show-staged))
('undefined (setq command nil))
(`unstaged (setq command #'magit-ediff-show-unstaged))
(`staged (setq command #'magit-ediff-show-staged))
(`undefined (setq command nil))
(_ (setq command nil))))))
(cond ((not command)
(call-interactively
......
......@@ -395,7 +395,7 @@ the upstream isn't ahead of the current branch) show."
(interactive "P")
(let ((magit-log-refresh-popup
(pcase major-mode
('magit-log-mode magit-log-mode-refresh-popup)
(`magit-log-mode magit-log-mode-refresh-popup)
(_ magit-log-refresh-popup)))
(magit-log-arguments
(-if-let (buffer (magit-mode-get-buffer 'magit-log-mode))
......@@ -853,22 +853,22 @@ Do not add this to a hook variable."
(when (derived-mode-p 'magit-log-mode)
(cl-incf magit-log-count))
(looking-at (pcase style
('log magit-log-heading-re)
('cherry magit-log-cherry-re)
('module magit-log-module-re)
('reflog magit-log-reflog-re)
('stash magit-log-stash-re)
('bisect-vis magit-log-bisect-vis-re)
('bisect-log magit-log-bisect-log-re)))
(`log magit-log-heading-re)
(`cherry magit-log-cherry-re)
(`module magit-log-module-re)
(`reflog magit-log-reflog-re)
(`stash magit-log-stash-re)
(`bisect-vis magit-log-bisect-vis-re)
(`bisect-log magit-log-bisect-log-re)))
(magit-bind-match-strings
(hash msg refs graph author date gpg cherry _ refsub side) nil
(let ((align (not (member "--stat" (cadr magit-refresh-args)))))
(magit-delete-line)
(magit-insert-section section (commit hash)
(pcase style
('stash (setf (magit-section-type section) 'stash))
('module (setf (magit-section-type section) 'module-commit))
('bisect-log (setq hash (magit-rev-parse "--short" hash))))
(`stash (setf (magit-section-type section) 'stash))
(`module (setf (magit-section-type section) 'module-commit))
(`bisect-log (setq hash (magit-rev-parse "--short" hash))))
(when cherry
(when (and (derived-mode-p 'magit-refs-mode)
magit-refs-show-commit-count)
......@@ -1418,8 +1418,8 @@ and the respective options are `magit-log-show-margin' and
(if (local-variable-p 'magit-show-margin)
(magit-set-buffer-margin magit-show-margin)
(pcase major-mode
('magit-log-mode (magit-set-buffer-margin magit-log-show-margin))
('magit-reflog-mode (magit-set-buffer-margin magit-reflog-show-margin)))))
(`magit-log-mode (magit-set-buffer-margin magit-log-show-margin))
(`magit-reflog-mode (magit-set-buffer-margin magit-reflog-show-margin)))))
(defun magit-set-buffer-margin (enable)
(let ((width (cond ((not enable) nil)
......
......@@ -896,21 +896,21 @@ and are defined in `magit-popup-mode-map' (which see)."
(def (or (lookup-key (current-local-map) key t)
(lookup-key (current-global-map) key))))
(pcase def
('magit-invoke-popup-switch
(`magit-invoke-popup-switch
(magit-popup-manpage man (magit-popup-lookup int :switches)))
('magit-invoke-popup-option
(`magit-invoke-popup-option
(magit-popup-manpage man (magit-popup-lookup int :options)))
('magit-popup-help
(`magit-popup-help
(magit-popup-manpage man nil))
((or 'self-insert-command
'magit-invoke-popup-action)
((or `self-insert-command
`magit-invoke-popup-action)
(setq def (or (magit-popup-lookup int :actions)
(magit-popup-lookup int :variables)))
(if def
(magit-popup-describe-function (magit-popup-event-fun def))
(ding)
(message nil)))
('nil (ding)
(`nil (ding)
(message nil))
(_ (magit-popup-describe-function def)))))
......@@ -922,14 +922,14 @@ and are defined in `magit-popup-mode-map' (which see)."
(setq arg (magit-popup-event-arg arg)))
(let ((winconf (current-window-configuration)) buffer)
(pcase magit-popup-manpage-package
('woman (delete-other-windows)
(`woman (delete-other-windows)
(split-window-below)
(with-no-warnings ; display-buffer-function is obsolete
(let ((display-buffer-alist nil)
(display-buffer-function nil))
(woman topic)))
(setq buffer (current-buffer)))
('man (cl-letf (((symbol-function #'fboundp) (lambda (_) nil)))
(`man (cl-letf (((symbol-function #'fboundp) (lambda (_) nil)))
(setq buffer (man topic)))
(delete-other-windows)
(split-window-below)
......
......@@ -117,7 +117,7 @@ the variable isn't already set."
(if (pcase (list magit-remote-add-set-remote.pushDefault
(magit-get "remote.defaultPush"))
(`(,(pred stringp) ,_) t)
((or `(ask ,_) '(ask-if-unset nil))
((or `(ask ,_) `(ask-if-unset nil))
(y-or-n-p (format "Set `remote.pushDefault' to \"%s\"? " remote))))
(progn (magit-call-git "remote" "add" "-f" remote url)
(magit-call-git "config" "remote.pushDefault" remote)
......
......@@ -922,10 +922,10 @@ invisible."
(defun magit-section-goto-successor-1 (section)
(or (--when-let (pcase (magit-section-type section)
('staged 'unstaged)
('unstaged 'staged)
('unpushed 'unpulled)
('unpulled 'unpushed))
(`staged 'unstaged)
(`unstaged 'staged)
(`unpushed 'unpulled)
(`unpulled 'unpushed))
(magit-get-section `((,it) (status))))
(--when-let (car (magit-section-siblings section 'next))
(magit-get-section (magit-section-ident it)))
......@@ -1002,8 +1002,8 @@ excluding SECTION itself."
(-when-let (parent (magit-section-parent section))
(let ((siblings (magit-section-children parent)))
(pcase direction
('prev (cdr (member section (reverse siblings))))
('next (cdr (member section siblings)))
(`prev (cdr (member section (reverse siblings))))
(`next (cdr (member section siblings)))
(_ (remq section siblings))))))
(defun magit-region-values (&rest types)
......
......@@ -1503,9 +1503,9 @@ defaulting to the branch at point."
(?d "[d]etach HEAD & delete" 'detach)
(?c "[c]heckout master & delete" 'master)
(?a "[a]bort" 'abort)))
('detach (magit-call-git "checkout" "--detach"))
('master (magit-call-git "checkout" "master"))
('abort (user-error "Abort")))
(`detach (magit-call-git "checkout" "--detach"))
(`master (magit-call-git "checkout" "master"))
(`abort (user-error "Abort")))
(setq force t))
(magit-run-git "branch" (if force "-D" "-d") branch))))))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment