From d100f40298be7176a521c675133242894289027f Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Sun, 7 Sep 2008 02:15:45 +0300 Subject: [PATCH] Remember section visibility across buffer reconstructions. * magit.el (magit-new-section): Find old section and inherit hidden attribute. (magit-create-buffer-sections): Make old top section available to magit-new-section. --- magit.el | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/magit.el b/magit.el index d7a6ae45..62d7efe0 100644 --- a/magit.el +++ b/magit.el @@ -294,17 +294,23 @@ Many Magit faces inherit from this one by default." (defvar magit-top-section nil) (make-variable-buffer-local 'magit-top-section) +(put 'magit-submode 'permanent-local t) + +(defvar magit-old-top-section nil) (defun magit-new-section (title type) - (message "Creating %s" title) - (let ((s (make-magit-section :parent magit-top-section + (let* ((s (make-magit-section :parent magit-top-section :title title - :type type))) + :type type)) + (old (magit-find-section (magit-section-path s) + magit-old-top-section))) (if magit-top-section (setf (magit-section-children magit-top-section) (append (magit-section-children magit-top-section) (list s))) (setq magit-top-section s)) + (if old + (setf (magit-section-hidden s) (magit-section-hidden old))) s)) (defun magit-cancel-section (section) @@ -333,9 +339,12 @@ Many Magit faces inherit from this one by default." (declare (indent 0)) `(let ((inhibit-read-only t)) (erase-buffer) - (setq magit-top-section nil) - ,@body - (magit-propertize-section magit-top-section))) + (let ((magit-old-top-section magit-top-section)) + (setq magit-top-section nil) + ,@body + (magit-propertize-section magit-top-section) + (magit-section-set-hidden magit-top-section + (magit-section-hidden magit-top-section))))) (defun magit-propertize-section (section) (put-text-property (magit-section-beginning section)