Use named functions for the section jumpers so that the online help

has something to show.
This commit is contained in:
Marius Vollmer 2008-08-19 00:42:44 +03:00
parent 4b3fcac93f
commit 601d26bf5a
2 changed files with 22 additions and 8 deletions

3
NEWS
View file

@ -5,6 +5,9 @@ Changes in magit 0.6:
* Key bindings and command behavior for diffing, history listing, and * Key bindings and command behavior for diffing, history listing, and
resetting have changed. Please see the manual. resetting have changed. Please see the manual.
* Some key bindings have been added for moving around in the status
buffer.
* All buffers created by Magit are now in magit-mode and share all key * All buffers created by Magit are now in magit-mode and share all key
bindings. bindings.

View file

@ -248,10 +248,13 @@
(goto-char prev-section) (goto-char prev-section)
(error "No previous section.")))) (error "No previous section."))))
(defun magit-section-jumper (section) (defmacro magit-define-section-jumper (sym title)
(let ((section (if (symbolp section) (list section) section))) (let ((fun (intern (format "magit-jump-to-%s" sym)))
`(lambda () (interactive) (magit-goto-section ',section)))) (doc (format "Jump to section `%s'." title)))
`(defun ,fun ()
(interactive)
(magit-goto-section '(,sym)))))
;;; Running asynchronous commands ;;; Running asynchronous commands
(defun magit-set-mode-line-process (str) (defun magit-set-mode-line-process (str)
@ -313,15 +316,23 @@
;;; Mode ;;; Mode
;; We define individual functions (instead of using lambda etc) so
;; that the online help can show something meaningful.
(magit-define-section-jumper untracked "Untracked changes")
(magit-define-section-jumper unstaged "Unstaged changes")
(magit-define-section-jumper staged "Staged changes")
(magit-define-section-jumper unpushed "Unpushed changes")
(defvar magit-mode-map (defvar magit-mode-map
(let ((map (make-keymap))) (let ((map (make-keymap)))
(suppress-keymap map t) (suppress-keymap map t)
(define-key map (kbd "M-n") 'magit-next-section) (define-key map (kbd "M-n") 'magit-next-section)
(define-key map (kbd "M-p") 'magit-previous-section) (define-key map (kbd "M-p") 'magit-previous-section)
(define-key map (kbd "1") (magit-section-jumper 'untracked)) (define-key map (kbd "1") 'magit-jump-to-untracked)
(define-key map (kbd "2") (magit-section-jumper 'unstaged)) (define-key map (kbd "2") 'magit-jump-to-unstaged)
(define-key map (kbd "3") (magit-section-jumper 'staged)) (define-key map (kbd "3") 'magit-jump-to-staged)
(define-key map (kbd "4") (magit-section-jumper 'unpushed)) (define-key map (kbd "4") 'magit-jump-to-unpushed)
(define-key map (kbd "g") 'magit-status) (define-key map (kbd "g") 'magit-status)
(define-key map (kbd "s") 'magit-stage-thing-at-point) (define-key map (kbd "s") 'magit-stage-thing-at-point)
(define-key map (kbd "S") 'magit-stage-all) (define-key map (kbd "S") 'magit-stage-all)