X-Git-Url: https://git.distorted.org.uk/~mdw/stgit/blobdiff_plain/32d7545de276f1004db22db07b46865b5c27b14c..6c82670d2b729cf1b491241044d9bab58b572597:/contrib/stgit.el diff --git a/contrib/stgit.el b/contrib/stgit.el index 93e3fa2..44a3f51 100644 --- a/contrib/stgit.el +++ b/contrib/stgit.el @@ -68,6 +68,8 @@ Argument DIR is the repository path." "Capture StGit output and, if there was any output, show it in a window at the end. Returns nil if there was no output." + (declare (debug ([&or stringp null] body)) + (indent 1)) `(let ((output-buf (get-buffer-create ,(or name "*StGit output*"))) (stgit-dir default-directory) (inhibit-read-only t)) @@ -82,7 +84,6 @@ Returns nil if there was no output." (setq buffer-read-only t) (if (< (point-min) (point-max)) (display-buffer output-buf t))))) -(put 'stgit-capture-output 'lisp-indent-function 1) (defun stgit-make-run-args (args) "Return a copy of ARGS with its elements converted to strings." @@ -418,7 +419,7 @@ find copied files." (error "File does not exist")) (find-file filename)))) -(defun stgit-toggle-patch-file-list (curpath) +(defun stgit-select-patch (curpath) (let ((inhibit-read-only t)) (if (memq curpatch stgit-expanded-patches) (save-excursion @@ -433,7 +434,7 @@ find copied files." (interactive) (let ((curpatch (stgit-patch-at-point))) (if curpatch - (stgit-toggle-patch-file-list curpatch) + (stgit-select-patch curpatch) (stgit-select-file)))) @@ -463,19 +464,23 @@ find copied files." (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 +522,12 @@ find copied files." ("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) @@ -587,14 +594,10 @@ Commands: "Unmark all patches." (setq stgit-marked-patches '())) -(defun stgit-patch-at-point (&optional cause-error allow-file) +(defun stgit-patch-at-point (&optional cause-error) "Return the patch name on the current line as a symbol. -If CAUSE-ERROR is not nil, signal an error if none found. -If ALLOW-FILE is not nil, also handle when point is on a file of -a patch." +If CAUSE-ERROR is not nil, signal an error if none found." (or (get-text-property (point) 'stgit-patchsym) - (and allow-file - (get-text-property (point) 'stgit-file-patchsym)) (when cause-error (error "No patch on this line"))))