diff options
| author | Kyle Meyer <kyle@kyleam.com> | 2017-07-23 22:03:40 -0400 |
|---|---|---|
| committer | Jonas Bernoulli <jonas@bernoul.li> | 2017-07-25 20:10:25 +0200 |
| commit | ec0ec74fe4a0bfa2c26607184eed72095f15f88c (patch) | |
| tree | 5a6ce62c19e9c1f73c381f9ad53ae312be8fe85b /lisp/magit-diff.el | |
| parent | 5d6623496300cbe15209335d608f6b1bdd228b97 (diff) | |
magit-diff-toggle-file-filter: move function and helpers
Now that magit-revision-toggle-file-filter has been generalized to
magit-diff-toggle-file-filter, position the command near similar
commands in magit-diff.el's "Commands > Setting commands" section.
Diffstat (limited to 'lisp/magit-diff.el')
| -rw-r--r-- | lisp/magit-diff.el | 56 |
1 files changed, 28 insertions, 28 deletions
diff --git a/lisp/magit-diff.el b/lisp/magit-diff.el index 1453555..a2fd69a 100644 --- a/lisp/magit-diff.el +++ b/lisp/magit-diff.el @@ -1007,6 +1007,34 @@ Change \"revA..revB\" to \"revB..revA\"." (magit-refresh)) (user-error "No range to swap")))) +(defvar-local magit-diff--last-file-args nil) +(defun magit-diff--toggle-file-args (files) + (cond (files + (setq magit-diff--last-file-args files) + nil) + (magit-diff--last-file-args) + (t + (user-error "No diff file filter to toggle")))) + +(defun magit-diff-toggle-file-filter () + "Toggle the file restriction of the current buffer's diffs. +If the current buffer's mode is derived from `magit-log-mode', +toggle the file restriction in the repository's revision buffer +instead." + (interactive) + (--if-let (and (derived-mode-p 'magit-log-mode) + (magit-mode-get-buffer 'magit-revision-mode)) + (with-current-buffer it + (setf (nth 3 magit-refresh-args) + (magit-diff--toggle-file-args (nth 3 magit-refresh-args))) + (magit-refresh)) + (if (derived-mode-p 'magit-diff-mode) + (setf (nth 3 magit-refresh-args) + (magit-diff--toggle-file-args (nth 3 magit-refresh-args))) + (setq-local magit-diff-section-file-args + (magit-diff--toggle-file-args magit-diff-section-file-args))) + (magit-refresh))) + (defun magit-diff-less-context (&optional count) "Decrease the context for diff hunks by COUNT lines." (interactive "p") @@ -1961,34 +1989,6 @@ or a ref which is not a branch, then it inserts nothing." (insert (propertize " " 'display `((space :align-to ,align-to)))) (insert " ")))))) -(defvar-local magit-diff--last-file-args nil) -(defun magit-diff--toggle-file-args (files) - (cond (files - (setq magit-diff--last-file-args files) - nil) - (magit-diff--last-file-args) - (t - (user-error "No diff file filter to toggle")))) - -(defun magit-diff-toggle-file-filter () - "Toggle the file restriction of the current buffer's diffs. -If the current buffer's mode is derived from `magit-log-mode', -toggle the file restriction in the repository's revision buffer -instead." - (interactive) - (--if-let (and (derived-mode-p 'magit-log-mode) - (magit-mode-get-buffer 'magit-revision-mode)) - (with-current-buffer it - (setf (nth 3 magit-refresh-args) - (magit-diff--toggle-file-args (nth 3 magit-refresh-args))) - (magit-refresh)) - (if (derived-mode-p 'magit-diff-mode) - (setf (nth 3 magit-refresh-args) - (magit-diff--toggle-file-args (nth 3 magit-refresh-args))) - (setq-local magit-diff-section-file-args - (magit-diff--toggle-file-args magit-diff-section-file-args))) - (magit-refresh))) - ;;; Diff Sections (defvar magit-unstaged-section-map |
