aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Bernoulli <jonas@bernoul.li>2015-09-02 16:45:18 +0200
committerJonas Bernoulli <jonas@bernoul.li>2015-09-02 16:45:18 +0200
commitce2f4f90d1267ccf87197dce45d357919103c8d3 (patch)
tree7afa2c754a94cb26f04ea95f0acfc8a94bd71336
parente02359fc4a9bbfc911b317ea7a3597294d1a9cc5 (diff)
call magit-mode-get-buffer with nil as FORMAT
`magit-mode-get-buffer' can derive the name of the variable whose value is the buffer-name format string to be used based on the MODE argument. Some callers already make use of this and pass nil as FORMAT, but many others did not do so until now. Deriving the name of the variable from the name of the mode is fairly cheap so it is okay to do so, especially because nor specifying the format variable explicitly makes many callers cleaner. However we cannot completely remove the FORMAT argument for backward (and possibly forward) compatibility reasons.
-rw-r--r--Documentation/RelNotes/2.2.2.txt3
-rw-r--r--lisp/magit-diff.el19
-rw-r--r--lisp/magit-log.el9
-rw-r--r--lisp/magit-mode.el4
-rw-r--r--lisp/magit-process.el12
-rw-r--r--lisp/magit.el3
6 files changed, 17 insertions, 33 deletions
diff --git a/Documentation/RelNotes/2.2.2.txt b/Documentation/RelNotes/2.2.2.txt
index b72ac42..0bb94ed 100644
--- a/Documentation/RelNotes/2.2.2.txt
+++ b/Documentation/RelNotes/2.2.2.txt
@@ -37,4 +37,5 @@ This is a bugfix release.
* `magit-wip-log' did not display a log if the working tree or index
ref did not exist.
-This release also contains various documentation fixes.
+This release also contains various documentation fixes and code
+clean-ups.
diff --git a/lisp/magit-diff.el b/lisp/magit-diff.el
index d1199e6..3a2332e 100644
--- a/lisp/magit-diff.el
+++ b/lisp/magit-diff.el
@@ -766,8 +766,7 @@ showing just the new changes or all the changes that will
be commited."
(interactive (magit-diff-arguments))
(let* ((toplevel (magit-toplevel))
- (diff-buf (magit-mode-get-buffer magit-diff-buffer-name-format
- 'magit-diff-mode toplevel)))
+ (diff-buf (magit-mode-get-buffer nil 'magit-diff-mode toplevel)))
(if (magit-commit-message-buffer)
(if (and (or ;; most likely an explicit amend
(not (magit-anything-staged-p))
@@ -823,9 +822,7 @@ for a commit."
default-directory)))
(unless (magit-rev-verify commit)
(user-error "%s is not a commit" commit))
- (-when-let (buffer (magit-mode-get-buffer
- magit-revision-buffer-name-format
- 'magit-revision-mode))
+ (-when-let (buffer (magit-mode-get-buffer nil 'magit-revision-mode))
(with-current-buffer buffer
(let ((prev (car magit-refresh-args)))
(unless (equal commit prev)
@@ -1104,8 +1101,7 @@ commit or stash at point, then prompt for a commit."
(magit-blame-mode
(setq rev (magit-blame-chunk-get :hash)
cmd 'magit-show-commit
- buf (magit-mode-get-buffer
- magit-revision-buffer-name-format 'magit-revision-mode)))
+ buf (magit-mode-get-buffer nil 'magit-revision-mode)))
((derived-mode-p 'git-rebase-mode)
(save-excursion
(goto-char (line-beginning-position))
@@ -1113,21 +1109,18 @@ commit or stash at point, then prompt for a commit."
(match-string 2))
(setq rev it
cmd 'magit-show-commit
- buf (magit-mode-get-buffer
- magit-revision-buffer-name-format 'magit-revision-mode))
+ buf (magit-mode-get-buffer nil 'magit-revision-mode))
(user-error "No commit on this line"))))
(t
(magit-section-case
((commit branch)
(setq rev (magit-section-value it)
cmd 'magit-show-commit
- buf (magit-mode-get-buffer
- magit-revision-buffer-name-format 'magit-revision-mode)))
+ buf (magit-mode-get-buffer nil 'magit-revision-mode)))
(stash
(setq rev (magit-section-value it)
cmd 'magit-stash-show
- buf (magit-mode-get-buffer
- magit-diff-buffer-name-format 'magit-diff-mode))))))
+ buf (magit-mode-get-buffer nil 'magit-diff-mode))))))
(if rev
(if (and buf
(setq win (get-buffer-window buf))
diff --git a/lisp/magit-log.el b/lisp/magit-log.el
index 458b19b..49d9f6a 100644
--- a/lisp/magit-log.el
+++ b/lisp/magit-log.el
@@ -609,8 +609,7 @@ prefix argument instead bury the revision buffer, provided it
is displayed in the current frame."
(interactive "p")
(if (< arg 0)
- (let* ((buf (magit-mode-get-buffer magit-revision-buffer-name-format
- 'magit-revision-mode))
+ (let* ((buf (magit-mode-get-buffer nil 'magit-revision-mode))
(win (and buf (get-buffer-window buf (selected-frame)))))
(if win
(with-selected-window win
@@ -959,16 +958,14 @@ another window, using `magit-show-commit'."
(or (magit-section-when commit
(and (or (and (magit-diff-auto-show-p 'log-follow)
(magit-mode-get-buffer
- magit-revision-buffer-name-format
- 'magit-revision-mode))
+ nil 'magit-revision-mode))
(and (magit-diff-auto-show-p 'log-oneline)
(derived-mode-p 'magit-log-mode)))
(magit-section-value it)))
(and magit-blame-mode
(magit-diff-auto-show-p 'blame-follow)
(magit-mode-get-buffer
- magit-revision-buffer-name-format
- 'magit-revision-mode)
+ nil 'magit-revision-mode)
(magit-blame-chunk-get :hash)))
(magit-show-commit it t))
(setq magit-log-show-commit-timer nil))))))
diff --git a/lisp/magit-mode.el b/lisp/magit-mode.el
index 3f2b459..4d0f8e0 100644
--- a/lisp/magit-mode.el
+++ b/lisp/magit-mode.el
@@ -563,9 +563,7 @@ current repository."
(run-hooks 'magit-pre-refresh-hook)
(magit-refresh-buffer)
(unless (derived-mode-p 'magit-status-mode)
- (--when-let (magit-mode-get-buffer
- magit-status-buffer-name-format
- 'magit-status-mode)
+ (--when-let (magit-mode-get-buffer nil 'magit-status-mode)
(with-current-buffer it
(magit-refresh-buffer)))))
(magit-revert-buffers)))
diff --git a/lisp/magit-process.el b/lisp/magit-process.el
index cdaa8fa..b36e653 100644
--- a/lisp/magit-process.el
+++ b/lisp/magit-process.el
@@ -132,12 +132,10 @@ When this is nil, no sections are ever removed."
(hack-dir-local-variables-non-file-buffer))
(defun magit-process-buffer (&optional pwd create)
- (or (magit-mode-get-buffer magit-process-buffer-name-format
- 'magit-process-mode pwd)
+ (or (magit-mode-get-buffer nil 'magit-process-mode pwd)
(and create
- (with-current-buffer (magit-mode-get-buffer-create
- magit-process-buffer-name-format
- 'magit-process-mode pwd)
+ (with-current-buffer
+ (magit-mode-get-buffer-create nil 'magit-process-mode pwd)
(magit-process-mode)
(let ((inhibit-read-only t))
(make-local-variable 'text-property-default-nonsticky)
@@ -515,9 +513,7 @@ tracked in the current repository are reverted if
"Special sentinel used by `magit-run-git-sequencer'."
(when (memq (process-status process) '(exit signal))
(magit-process-sentinel process event)
- (--when-let (magit-mode-get-buffer
- magit-status-buffer-name-format
- 'magit-status-mode)
+ (--when-let (magit-mode-get-buffer nil 'magit-status-mode)
(with-current-buffer it
(--when-let
(magit-get-section
diff --git a/lisp/magit.el b/lisp/magit.el
index 41cc94f..5b96ee4 100644
--- a/lisp/magit.el
+++ b/lisp/magit.el
@@ -1080,8 +1080,7 @@ is done using `magit-find-index-noselect'."
(when magit-wip-after-apply-mode
(magit-wip-commit-after-apply (list file) " after un-/stage")))
(message "Abort")))
- (--when-let (magit-mode-get-buffer
- magit-status-buffer-name-format 'magit-status-mode)
+ (--when-let (magit-mode-get-buffer nil 'magit-status-mode)
(with-current-buffer it (magit-refresh)))
t)