Introduces
magit-log-buffer-name *magit-log*
magit-log-edit-buffer-name *magit-edit-log* (was *magit-log-edit*)
magit-log-grep-buffer-name *magit-grep-log* (was *magit-log-grep*)
magit-process-buffer-name *magit-process*
magit-commit-buffer-name *magit-commit*
magit-stash-buffer-name *magit-stash*
Also adds C-c C-] as a binding for magit-log-edit-cancel-log-message
since C-c C-] as the aborting counterpart to C-c C-c is at least a
vague convention for other modes (cf. rmail, vm, query-replace...)
Motives:
It annoys me that, when wanting to switch to the *magit-log* buffer
from some random place, I can't type *ma<space>-l<space> and have it
complete properly, at least not if I've previously ever done a commit
(because there's then a *magit-log-edit* out there stealing the
completion).
Also looks like if I ever use magit-log-grep, I will be likewise
screwed.
Finally, it disturbs my sense of aesthetics when I look at source code
and see the same strings occuring over and over. Usually, that's
crying defvars/defconsts. (And this will also makes life easier
in the event you don't like my buffer name changes for -log-edit
and -log-grep).
- -
(...This all leaves *magit-tmp* as the only remaining case of a buffer
name string occurring multiple times, but that needs to be handled
differently, so that'll be a different patch...)
(...Note that having buffer names as variables also allows the
eventual possibility of making them local --- or at least the
option thereof --- so that one can be visiting several
repositories at once and not having these buffers all clobbering
each other. There's a tradeoff here in that some folks may find
it confusing/annoying to have more than one set of these buffers
to deal with,... hence option.
*If* one is going to go that route, current gut feeling is buffer
name variables should be local to *just* the status buffer(s),
void elsewhere, and anything needing one of the auxiliary buffers
should dispatch through its own status buffer to get what it
wants. That way, we're not having to repeat/update/copy
per-repository definitions everywhere....)
The patch:
diff --git a/magit.el b/magit.el
index b32ac02..dcacba5 100644
--- a/magit.el
+++ b/magit.el
@@ -1186,16 +1186,18 @@ FUNC should leave point at the end of the modified
region"
(defvar magit-process nil)
(defvar magit-process-client-buffer nil)
+(defvar magit-process-buffer-name "*magit-process*"
+ "Buffer name for running git commands")
(defun magit-run* (cmd-and-args
&optional logline noerase noerror nowait input)
(if (and magit-process
- (get-buffer "*magit-process*"))
+ (get-buffer magit-process-buffer-name))
(error "Git is already running"))
(let ((cmd (car cmd-and-args))
(args (cdr cmd-and-args))
(dir default-directory)
- (buf (get-buffer-create "*magit-process*"))
+ (buf (get-buffer-create magit-process-buffer-name))
(successp nil))
(magit-set-mode-line-process
(magit-process-indicator-from-command cmd-and-args))
@@ -1340,7 +1342,7 @@ FUNC should leave point at the end of the modified region"
(defun magit-display-process ()
"Display output from most recent git command"
(interactive)
- (display-buffer "*magit-process*"))
+ (display-buffer magit-process-buffer-name))
;;; Mode
@@ -2228,11 +2230,14 @@ insert a line to tell how to insert more of them"
:lighter ()
:keymap magit-commit-mode-map)
+(defvar magit-commit-buffer-name "*magit-commit*"
+ "Buffer name for displaying commit log messages")
+
(defun magit-show-commit (commit &optional scroll)
(when (magit-section-p commit)
(setq commit (magit-section-info commit)))
(let ((dir default-directory)
- (buf (get-buffer-create "*magit-commit*")))
+ (buf (get-buffer-create magit-commit-buffer-name)))
(cond ((and (equal magit-currently-shown-commit commit)
;; if it's empty then the buffer was killed
(with-current-buffer buf
@@ -2901,6 +2906,9 @@ in both working tree and staging area.
;;; Log edit mode
+(defvar magit-log-edit-buffer-name "*magit-edit-log*"
+ "Buffer name for composing commit messages")
+
(defvar magit-log-edit-mode-map
(let ((map (make-sparse-keymap)))
(define-key map (kbd "C-c C-c") 'magit-log-edit-commit)
@@ -2909,6 +2917,7 @@ in both working tree and staging area.
(define-key map (kbd "M-p") 'log-edit-previous-comment)
(define-key map (kbd "M-n") 'log-edit-next-comment)
(define-key map (kbd "C-c C-k") 'magit-log-edit-cancel-log-message)
+ (define-key map (kbd "C-c C-]") 'magit-log-edit-cancel-log-message)
map))
(defvar magit-pre-log-edit-window-configuration nil)
@@ -2939,14 +2948,14 @@ Prefix arg means justify as well."
(defun magit-log-edit-append (str)
(save-excursion
- (set-buffer (get-buffer-create "*magit-log-edit*"))
+ (set-buffer (get-buffer-create magit-log-edit-buffer-name))
(goto-char (point-max))
(insert str "\n")))
(defconst magit-log-header-end "-- End of Magit header --\n")
(defun magit-log-edit-get-fields ()
- (let ((buf (get-buffer "*magit-log-edit*"))
+ (let ((buf (get-buffer magit-log-edit-buffer-name))
(result nil))
(if buf
(save-excursion
@@ -2962,7 +2971,7 @@ Prefix arg means justify as well."
(nreverse result)))
(defun magit-log-edit-set-fields (fields)
- (let ((buf (get-buffer-create "*magit-log-edit*")))
+ (let ((buf (get-buffer-create magit-log-edit-buffer-name)))
(save-excursion
(set-buffer buf)
(goto-char (point-min))
@@ -3093,7 +3102,7 @@ Prefix arg means justify as well."
(defun magit-pop-to-log-edit (operation)
(let ((dir default-directory)
- (buf (get-buffer-create "*magit-log-edit*")))
+ (buf (get-buffer-create magit-log-edit-buffer-name)))
(setq magit-pre-log-edit-window-configuration
(current-window-configuration))
(pop-to-buffer buf)
@@ -3250,11 +3259,14 @@ With prefix argument, changes in staging area are kept.
:lighter ()
:keymap magit-stash-mode-map)
+(defvar magit-stash-buffer-name "*magit-stash*"
+ "Buffer name for displaying a stash")
+
(defun magit-show-stash (stash &optional scroll)
(when (magit-section-p stash)
(setq stash (magit-section-info stash)))
(let ((dir default-directory)
- (buf (get-buffer-create "*magit-stash*"))
+ (buf (get-buffer-create magit-stash-buffer-name))
(stash-id (magit-git-string "rev-list" "-1" stash)))
(cond ((and (equal magit-currently-shown-stash stash-id)
(with-current-buffer buf
@@ -3435,6 +3447,11 @@ With a non numeric prefix ARG, show all entries"
:lighter ()
:keymap magit-log-mode-map)
+(defvar magit-log-buffer-name "*magit-log*"
+ "Buffer name for display of log entries")
+(defvar magit-log-grep-buffer-name "*magit-grep-log*"
+ "Buffer name for display of log grep results")
+
(defun magit-log (&optional arg)
(interactive "P")
(let* ((range (if arg
@@ -3442,7 +3459,7 @@ With a non numeric prefix ARG, show all entries"
"HEAD"))
(topdir (magit-get-top-dir default-directory))
(args (list (magit-rev-range-to-git range))))
- (switch-to-buffer "*magit-log*")
+ (switch-to-buffer magit-log-buffer-name)
(magit-mode-init topdir 'log #'magit-refresh-log-buffer range
"--pretty=oneline" args)
(magit-log-mode t)))
@@ -3451,7 +3468,7 @@ With a non numeric prefix ARG, show all entries"
"Search for regexp specified by STR in the commit log."
(interactive "sGrep in commit log: ")
(let ((topdir (magit-get-top-dir default-directory)))
- (switch-to-buffer "*magit-log-grep*")
+ (switch-to-buffer magit-log-grep-buffer-name)
(magit-mode-init topdir 'log #'magit-refresh-log-buffer "HEAD"
"--pretty=oneline"
(list "-E"
@@ -3465,7 +3482,7 @@ With a non numeric prefix ARG, show all entries"
"HEAD"))
(topdir (magit-get-top-dir default-directory))
(args (list (magit-rev-range-to-git range))))
- (switch-to-buffer "*magit-log*")
+ (switch-to-buffer magit-log-buffer-name)
(magit-mode-init topdir 'log #'magit-refresh-log-buffer range
"--stat" args)
(magit-log-mode t)))
@@ -3710,10 +3727,10 @@ With a non numeric prefix ARG, show all entries"
(goto-line line)))
((commit)
(magit-show-commit info)
- (pop-to-buffer "*magit-commit*"))
+ (pop-to-buffer magit-commit-buffer-name))
((stash)
(magit-show-stash info)
- (pop-to-buffer "*magit-stash*"))
+ (pop-to-buffer magit-stash-buffer-name))
((topic)
(magit-checkout info))
((longer)
--
Subscription settings: http://groups.google.com/group/magit/subscribe?hl=en