From acc5652f1f94c454f5b0a8e8dd920e55387e7f7e Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20K=C3=A5gedal?= Date: Thu, 26 Feb 2009 20:59:07 +0100 Subject: [PATCH] stgit.el: Expand or collapse only the patch at point, instead of rerunning stg-reload. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: David Kågedal Signed-off-by: Karl Hasselström --- contrib/stgit.el | 45 ++++++++++++++++++++++++++++++++------------- 1 file changed, 32 insertions(+), 13 deletions(-) diff --git a/contrib/stgit.el b/contrib/stgit.el index 3c8734c..3b63533 100644 --- a/contrib/stgit.el +++ b/contrib/stgit.el @@ -350,6 +350,15 @@ find copied files." (insert " \n")) (put-text-property start (point) 'stgit-file-patchsym patchsym)))) +(defun stgit-collapse-patch (patchsym) + "Collapse the patch with name PATCHSYM after the line at point." + (save-excursion + (forward-line) + (let ((start (point))) + (while (eq (get-text-property (point) 'stgit-file-patchsym) patchsym) + (forward-line)) + (delete-region start (point))))) + (defun stgit-rescan () "Rescan the status buffer." (save-excursion @@ -398,23 +407,33 @@ find copied files." (propertize "no patches in series" 'face 'stgit-description-face)))))) +(defun stgit-select-file () + (let ((patched-file (stgit-patched-file-at-point))) + (unless patched-file + (error "No patch or file on the current line")) + (let ((filename (expand-file-name (cdr patched-file)))) + (unless (file-exists-p filename) + (error "File does not exist")) + (find-file filename)))) + +(defun stgit-toggle-patch-file-list (curpath) + (let ((inhibit-read-only t)) + (if (memq curpatch stgit-expanded-patches) + (save-excursion + (setq stgit-expanded-patches (delq curpatch stgit-expanded-patches)) + (stgit-collapse-patch curpatch)) + (progn + (setq stgit-expanded-patches (cons curpatch stgit-expanded-patches)) + (stgit-expand-patch curpatch))))) + (defun stgit-select () "Expand or collapse the current entry" (interactive) (let ((curpatch (stgit-patch-at-point))) - (if (not curpatch) - (let ((patched-file (stgit-patched-file-at-point))) - (unless patched-file - (error "No patch or file on the current line")) - (let ((filename (expand-file-name (cdr patched-file)))) - (unless (file-exists-p filename) - (error "File does not exist")) - (find-file filename))) - (setq stgit-expanded-patches - (if (memq curpatch stgit-expanded-patches) - (delq curpatch stgit-expanded-patches) - (cons curpatch stgit-expanded-patches))) - (stgit-reload)))) + (if curpatch + (stgit-toggle-patch-file-list curpatch) + (stgit-select-file)))) + (defun stgit-find-file-other-window () "Open file at point in other window" -- 2.11.0