X-Git-Url: https://git.distorted.org.uk/~mdw/stgit/blobdiff_plain/022a3664de84fc5cb6b94abb7ae1f27276c88ccf..0f076fe6b1a561a3a84a2f5938110118944577a2:/contrib/stgit.el diff --git a/contrib/stgit.el b/contrib/stgit.el index 9cf909f..220e159 100644 --- a/contrib/stgit.el +++ b/contrib/stgit.el @@ -9,6 +9,8 @@ ;; ;; To start: `M-x stgit' +(require 'git nil t) + (defun stgit (dir) "Manage stgit patches" (interactive "DDirectory: \n") @@ -144,6 +146,21 @@ Argument DIR is the repository path." (forward-line 1)) (setq stgit-marked-patches (nreverse marked))))) +(defun stgit-quit () + "Hide the stgit buffer" + (interactive) + (bury-buffer)) + +(defun stgit-git-status () + "Show status using `git-status'" + (interactive) + (unless (fboundp 'git-status) + (error "stgit-git-status requires git-status")) + (let ((dir default-directory)) + (save-selected-window + (pop-to-buffer nil) + (git-status dir)))) + (defvar stgit-mode-hook nil "Run after `stgit-mode' is setup.") @@ -155,11 +172,14 @@ Argument DIR is the repository path." (suppress-keymap stgit-mode-map) (mapc (lambda (arg) (define-key stgit-mode-map (car arg) (cdr arg))) '((" " . stgit-mark) - ("\d" . stgit-unmark) + ("m" . stgit-mark) + ("\d" . stgit-unmark-up) + ("u" . stgit-unmark-down) ("?" . stgit-help) ("h" . stgit-help) ("p" . previous-line) ("n" . next-line) + ("s" . stgit-git-status) ("g" . stgit-reload) ("r" . stgit-refresh) ("\C-c\C-r" . stgit-rename) @@ -176,7 +196,8 @@ Argument DIR is the repository path." ("=" . stgit-show) ("D" . stgit-delete) ([(control ?/)] . stgit-undo) - ("\C-_" . stgit-undo)))) + ("\C-_" . stgit-undo) + ("q" . stgit-quit)))) (defun stgit-mode () "Major mode for interacting with StGit. @@ -239,7 +260,7 @@ Commands: "Run stg init" (interactive) (stgit-capture-output nil - (stgit-run "init")) + (stgit-run "init")) (stgit-reload)) (defun stgit-mark () @@ -250,13 +271,19 @@ Commands: (stgit-reload)) (next-line)) -(defun stgit-unmark () - "Mark the patch on the previous line" +(defun stgit-unmark-up () + "Remove mark from the patch on the previous line" (interactive) (forward-line -1) - (let ((patch (stgit-patch-at-point))) - (stgit-remove-mark patch) - (stgit-reload))) + (stgit-remove-mark (stgit-patch-at-point)) + (stgit-reload)) + +(defun stgit-unmark-down () + "Remove mark from the patch on the current line" + (interactive) + (stgit-remove-mark (stgit-patch-at-point)) + (forward-line) + (stgit-reload)) (defun stgit-rename (name) "Rename the patch under point" @@ -273,7 +300,7 @@ Commands: "Run stg repair" (interactive) (stgit-capture-output nil - (stgit-run "repair")) + (stgit-run "repair")) (stgit-reload)) (defun stgit-commit () @@ -315,7 +342,7 @@ With numeric prefix argument, pop that many patches." (let ((patch (stgit-patch-at-point)) (applied (stgit-applied-at-point))) (stgit-capture-output nil - (stgit-run (if applied "pop" "push") patch)) + (stgit-run (if applied "pop" "push") patch)) (stgit-reload))) (defun stgit-goto () @@ -323,7 +350,7 @@ With numeric prefix argument, pop that many patches." (interactive) (let ((patch (stgit-patch-at-point))) (stgit-capture-output nil - (stgit-run "goto" patch)) + (stgit-run "goto" patch)) (stgit-reload))) (defun stgit-show () @@ -447,14 +474,14 @@ With prefix argument, run it with the --hard flag." With prefix argument, refresh the patch under point." (interactive "P") (let ((patchargs (if arg - (let ((patches (stgit-patches-marked-or-at-point))) - (cond ((null patches) - (error "no patch to update")) - ((> (length patches) 1) - (error "too many patches selected")) - (t - (cons "-p" patches)))) - nil))) + (let ((patches (stgit-patches-marked-or-at-point))) + (cond ((null patches) + (error "no patch to update")) + ((> (length patches) 1) + (error "too many patches selected")) + (t + (cons "-p" patches)))) + nil))) (stgit-capture-output nil (apply 'stgit-run "refresh" patchargs))) (stgit-reload))