From: Gustav HÃ¥llberg Date: Fri, 14 Aug 2009 08:54:05 +0000 (+0200) Subject: stgit.el: Add stgit-toggle-mark X-Git-Tag: v0.15-rc2~11^2~1 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/stgit/commitdiff_plain/d11e0621dad259315ef587ac50aa3f1bd54032e2 stgit.el: Add stgit-toggle-mark Preparation for upcoming menu bar patch Signed-off-by: Gustav HÃ¥llberg --- diff --git a/contrib/stgit.el b/contrib/stgit.el index 27b1744..81222f6 100644 --- a/contrib/stgit.el +++ b/contrib/stgit.el @@ -812,8 +812,8 @@ (unless stgit-mode-map (setq stgit-mode-map (make-keymap)) (suppress-keymap stgit-mode-map) (mapc (lambda (arg) (define-key stgit-mode-map (car arg) (cdr arg))) - `((" " . stgit-mark) - ("m" . stgit-mark) + `((" " . stgit-mark-down) + ("m" . stgit-mark-down) ("\d" . stgit-unmark-up) ("u" . stgit-unmark-down) ("?" . stgit-help) @@ -885,7 +885,7 @@ (defun stgit-mode () \\[stgit-previous-patch] Move to previous patch \\[stgit-next-patch] Move to next patch -\\[stgit-mark] Mark patch +\\[stgit-mark-down] Mark patch and move down \\[stgit-unmark-up] Unmark patch and move up \\[stgit-unmark-down] Unmark patch and move down @@ -1057,6 +1057,14 @@ (defun stgit-init () (stgit-run "init")) (stgit-reload)) +(defun stgit-toggle-mark () + "Toggle mark on the patch under point." + (interactive) + (stgit-assert-mode) + (if (memq (stgit-patch-name-at-point t t) stgit-marked-patches) + (stgit-unmark) + (stgit-mark))) + (defun stgit-mark () "Mark the patch under point." (interactive) @@ -1069,28 +1077,39 @@ (defun stgit-mark () (when (eq name :index) (error "Cannot mark the index")) (stgit-add-mark (stgit-patch-name patch)) - (ewoc-invalidate stgit-ewoc node)) + (let ((column (current-column))) + (ewoc-invalidate stgit-ewoc node) + (move-to-column column)))) + +(defun stgit-mark-down () + "Mark the patch under point and move to the next patch." + (interactive) + (stgit-mark) (stgit-next-patch)) -(defun stgit-unmark-up () - "Remove mark from the patch on the previous line." +(defun stgit-unmark () + "Remove mark from the patch on the current line." (interactive) (stgit-assert-mode) - (stgit-previous-patch) (let* ((node (ewoc-locate stgit-ewoc)) (patch (ewoc-data node))) (stgit-remove-mark (stgit-patch-name patch)) - (ewoc-invalidate stgit-ewoc node)) - (move-to-column (stgit-goal-column))) + (let ((column (current-column))) + (ewoc-invalidate stgit-ewoc node) + (move-to-column column)))) + +(defun stgit-unmark-up () + "Remove mark from the patch on the previous line." + (interactive) + (stgit-assert-mode) + (stgit-previous-patch) + (stgit-unmark)) (defun stgit-unmark-down () "Remove mark from the patch on the current line." (interactive) (stgit-assert-mode) - (let* ((node (ewoc-locate stgit-ewoc)) - (patch (ewoc-data node))) - (stgit-remove-mark (stgit-patch-name patch)) - (ewoc-invalidate stgit-ewoc node)) + (stgit-unmark) (stgit-next-patch)) (defun stgit-rename (name)