From afbf766b8dda1a627fb392c4213d61a69e934323 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Gustav=20H=C3=A5llberg?= Date: Fri, 14 Aug 2009 10:54:03 +0200 Subject: [PATCH] stgit.el: Add +/- to expand/collapse selected patches MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Gustav HÃ¥llberg --- contrib/stgit.el | 38 +++++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/contrib/stgit.el b/contrib/stgit.el index 9dc8bfd..006c082 100644 --- a/contrib/stgit.el +++ b/contrib/stgit.el @@ -666,13 +666,36 @@ at point." (when (eq (stgit-file-status file) 'unmerged) (smerge-mode 1)))) +(defun stgit-expand (&optional patches collapse) + "Show the contents selected patches, or the patch at point. + +See also `stgit-collapse'. + +Non-interactively, operate on PATCHES, and collapse instead of +expand if COLLAPSE is not nil." + (interactive (list (stgit-patches-marked-or-at-point))) + (let ((patches-diff (funcall (if collapse #'intersection #'set-difference) + patches stgit-expanded-patches))) + (setq stgit-expanded-patches + (if collapse + (set-difference stgit-expanded-patches patches-diff) + (append stgit-expanded-patches patches-diff))) + (ewoc-map #'(lambda (patch) + (memq (stgit-patch-name patch) patches-diff)) + stgit-ewoc)) + (move-to-column (stgit-goal-column))) + +(defun stgit-collapse (&optional patches) + "Hide the contents selected patches, or the patch at point. + +See also `stgit-expand'." + (interactive (list (stgit-patches-marked-or-at-point))) + (stgit-expand patches t)) + (defun stgit-select-patch () (let ((patchname (stgit-patch-name-at-point))) - (if (memq patchname stgit-expanded-patches) - (setq stgit-expanded-patches (delq patchname stgit-expanded-patches)) - (setq stgit-expanded-patches (cons patchname stgit-expanded-patches))) - (ewoc-invalidate stgit-ewoc (ewoc-locate stgit-ewoc))) - (move-to-column (stgit-goal-column))) + (stgit-expand (list patchname) + (memq patchname stgit-expanded-patches)))) (defun stgit-select () "With point on a patch, toggle showing files in the patch. @@ -797,6 +820,8 @@ file for (applied) copies and renames." ("U" . stgit-revert-file) ("R" . stgit-resolve-file) ("\r" . stgit-select) + ("+" . stgit-expand) + ("-" . stgit-collapse) ("o" . stgit-find-file-other-window) ("i" . stgit-file-toggle-index) (">" . stgit-push-next) @@ -849,6 +874,9 @@ Commands for patches: \\[stgit-refresh] Refresh patch with changes in index or work tree \\[stgit-diff] Show the patch log and diff +\\[stgit-expand] Show changes in selected patches +\\[stgit-collapse] Hide changes in selected patches + \\[stgit-new] Create a new, empty patch \\[stgit-new-and-refresh] Create a new patch from index or work tree \\[stgit-rename] Rename patch -- 2.11.0