From: Gustav Hållberg Date: Fri, 17 Apr 2009 01:15:19 +0000 (+0200) Subject: stgit.el: Bind line movement keys in a sane way X-Git-Tag: v0.15-rc1~23 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/stgit/commitdiff_plain/58f72f169cc817897ef74eb1298261c5faa23d1f?ds=inline stgit.el: Bind line movement keys in a sane way Use p/n for stgit-{previous,next}-patch and C-p/n and up/down for stgit-{previous,next}-line, which makes stgit-mode behave more like dired-mode and git-mode. Signed-off-by: Gustav Hållberg Signed-off-by: David Kågedal Signed-off-by: Karl Hasselström --- diff --git a/contrib/stgit.el b/contrib/stgit.el index 93e3fa2..ed6342c 100644 --- a/contrib/stgit.el +++ b/contrib/stgit.el @@ -463,19 +463,23 @@ (defun stgit-git-status () (pop-to-buffer nil) (git-status dir)))) -(defun stgit-next-line (&optional arg try-vscroll) +(defun stgit-goal-column () + "Return goal column for the current line" + (cond ((get-text-property (point) 'stgit-file-patchsym) 4) + ((get-text-property (point) 'stgit-patchsym) 2) + (t 0))) + +(defun stgit-next-line (&optional arg) "Move cursor vertically down ARG lines" - (interactive "p\np") - (next-line arg try-vscroll) - (when (looking-at " \\S-") - (forward-char 2))) + (interactive "p") + (next-line arg) + (move-to-column (stgit-goal-column))) -(defun stgit-previous-line (&optional arg try-vscroll) +(defun stgit-previous-line (&optional arg) "Move cursor vertically up ARG lines" - (interactive "p\np") - (previous-line arg try-vscroll) - (when (looking-at " \\S-") - (forward-char 2))) + (interactive "p") + (previous-line arg) + (move-to-column (stgit-goal-column))) (defun stgit-next-patch (&optional arg) "Move cursor down ARG patches" @@ -517,10 +521,12 @@ (unless stgit-mode-map ("u" . stgit-unmark-down) ("?" . stgit-help) ("h" . stgit-help) - ("p" . stgit-previous-line) - ("n" . stgit-next-line) - ("\C-p" . stgit-previous-patch) - ("\C-n" . stgit-next-patch) + ("\C-p" . stgit-previous-line) + ("\C-n" . stgit-next-line) + ([up] . stgit-previous-line) + ([down] . stgit-next-line) + ("p" . stgit-previous-patch) + ("n" . stgit-next-patch) ("\M-{" . stgit-previous-patch) ("\M-}" . stgit-next-patch) ("s" . stgit-git-status)