Added minor mode for the different magit buffer.

Signed-off-by: Rémi Vanicat <vanicat@debian.org>
This commit is contained in:
Rémi Vanicat 2010-04-09 13:22:08 +02:00 committed by Phil Jackson
parent 8175d6dfad
commit 9105c3e557

104
magit.el
View file

@ -1420,6 +1420,34 @@ FUNC should leave point at the end of the modified region"
(define-key map (kbd "q") 'quit-window)
map))
(defvar magit-commit-mode-map
(let ((map (make-sparse-keymap)))
map))
(defvar magit-status-mode-map
(let ((map (make-sparse-keymap)))
map))
(defvar magit-stash-mode-map
(let ((map (make-sparse-keymap)))
map))
(defvar magit-log-mode-map
(let ((map (make-sparse-keymap)))
map))
(defvar magit-reflog-mode-map
(let ((map (make-sparse-keymap)))
map))
(defvar magit-diff-mode-map
(let ((map (make-sparse-keymap)))
map))
(defvar magit-wazzup-mode-map
(let ((map (make-sparse-keymap)))
map))
(easy-menu-define magit-mode-menu magit-mode-map
"Magit menu"
'("Magit"
@ -2105,6 +2133,13 @@ must return a string which will represent the log line.")
"--pretty=medium"
"--cc" "-p" commit)))
(define-minor-mode magit-commit-mode
"Minor mode to view git commit"
:group magit
:init-value ()
:lighter ()
:keymap magit-commit-mode-map)
(defun magit-show-commit (commit &optional scroll)
(when (magit-section-p commit)
(setq commit (magit-section-info commit)))
@ -2127,7 +2162,8 @@ must return a string which will represent the log line.")
(set-buffer buf)
(goto-char (point-min))
(magit-mode-init dir 'commit
#'magit-refresh-commit-buffer commit))))))
#'magit-refresh-commit-buffer commit)
(magit-commit-mode t))))))
(defvar magit-marked-commit nil)
@ -2269,6 +2305,13 @@ must return a string which will represent the log line.")
(let ((default-directory dir))
(magit-run* (list "git" "init"))))))
(define-minor-mode magit-status-mode
"Minor mode for looking at git status"
:group magit
:init-value ()
:lighter ()
:keymap magit-status-mode-map)
;;;###autoload
(defun magit-status (dir)
(interactive (list (or (and (not current-prefix-arg)
@ -2291,7 +2334,8 @@ must return a string which will represent the log line.")
(file-name-nondirectory
(directory-file-name topdir)) "*"))))))
(switch-to-buffer buf)
(magit-mode-init topdir 'status #'magit-refresh-status)))))
(magit-mode-init topdir 'status #'magit-refresh-status)
(magit-status-mode t)))))
;;; Staging and Unstaging
@ -3065,6 +3109,13 @@ Prefix arg means justify as well."
(defvar magit-currently-shown-stash nil)
(define-minor-mode magit-stash-mode
"Minor mode for looking at git status"
:group magit
:init-value ()
:lighter ()
:keymap magit-stash-mode-map)
(defun magit-show-stash (stash &optional scroll)
(when (magit-section-p stash)
(setq stash (magit-section-info stash)))
@ -3089,7 +3140,8 @@ Prefix arg means justify as well."
(let* ((range (cons (concat stash "^2^") stash))
(args (magit-rev-range-to-git range)))
(magit-mode-init dir 'diff #'magit-refresh-diff-buffer
range args)))))))
range args)
(magit-stash-mode t)))))))
;;; Topic branches (using topgit)
@ -3225,6 +3277,13 @@ Prefix arg means justify as well."
,@args
"--"))))
(define-minor-mode magit-log-mode
"Minor mode for looking at git status"
:group magit
:init-value ()
:lighter ()
:keymap magit-log-mode-map)
(defun magit-log (&optional arg)
(interactive "P")
(let* ((range (if arg
@ -3234,7 +3293,8 @@ Prefix arg means justify as well."
(args (list (magit-rev-range-to-git range))))
(switch-to-buffer "*magit-log*")
(magit-mode-init topdir 'log #'magit-refresh-log-buffer range
"--pretty=oneline" args)))
"--pretty=oneline" args)
(magit-log-mode t)))
(defun magit-log-grep (str)
"Search for regexp specified by STR in the commit log."
@ -3244,7 +3304,8 @@ Prefix arg means justify as well."
(magit-mode-init topdir 'log #'magit-refresh-log-buffer "HEAD"
"--pretty=oneline"
(list "-E"
(format "--grep=%s" (shell-quote-argument str))))))
(format "--grep=%s" (shell-quote-argument str))))
(magit-log-mode t)))
(defun magit-log-long (&optional arg)
(interactive "P")
@ -3255,7 +3316,8 @@ Prefix arg means justify as well."
(args (list (magit-rev-range-to-git range))))
(switch-to-buffer "*magit-log*")
(magit-mode-init topdir 'log #'magit-refresh-log-buffer range
"--stat" args)))
"--stat" args)
(magit-log-mode t)))
;;; Reflog
@ -3269,6 +3331,13 @@ Prefix arg means justify as well."
"--pretty=format:* %H %s"
args)))
(define-minor-mode magit-reflog-mode
"Minor mode for looking at git status"
:group magit
:init-value ()
:lighter ()
:keymap magit-reflog-mode-map)
(defun magit-reflog (head)
(interactive (list (magit-read-rev "Reflog of" "HEAD")))
(if head
@ -3276,7 +3345,8 @@ Prefix arg means justify as well."
(args (magit-rev-to-git head)))
(switch-to-buffer "*magit-reflog*")
(magit-mode-init topdir 'reflog
#'magit-refresh-reflog-buffer head args))))
#'magit-refresh-reflog-buffer head args)
(magit-reflog-mode t))))
(defun magit-reflog-head ()
(interactive)
@ -3291,6 +3361,13 @@ Prefix arg means justify as well."
'magit-wash-diffs
"diff" (magit-diff-U-arg) args)))
(define-minor-mode magit-diff-mode
"Minor mode for looking at git status"
:group magit
:init-value ()
:lighter ()
:keymap magit-diff-mode-map)
(defun magit-diff (range)
(interactive (list (magit-read-rev-range "Diff")))
(if range
@ -3300,7 +3377,8 @@ Prefix arg means justify as well."
(display-buffer buf)
(save-excursion
(set-buffer buf)
(magit-mode-init dir 'diff #'magit-refresh-diff-buffer range args)))))
(magit-mode-init dir 'diff #'magit-refresh-diff-buffer range args)
(magit-diff-mode t)))))
(defun magit-diff-working-tree (rev)
(interactive (list (magit-read-rev "Diff with (default HEAD)")))
@ -3369,6 +3447,13 @@ Prefix arg means justify as well."
"--"))))
(magit-set-section-info ref section))))))))))
(define-minor-mode magit-wazzup-mode
"Minor mode for looking at git status"
:group magit
:init-value ()
:lighter ()
:keymap magit-wazzup-mode-map)
(defun magit-wazzup (&optional all)
(interactive "P")
(let ((topdir (magit-get-top-dir default-directory))
@ -3376,7 +3461,8 @@ Prefix arg means justify as well."
(switch-to-buffer "*magit-wazzup*")
(magit-mode-init topdir 'wazzup
#'magit-refresh-wazzup-buffer
current-branch all)))
current-branch all)
(magit-wazzup-mode t)))
;;; Miscellaneous