]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/outline.el (outline-revert-buffer-restore-visibility): New function.
authorJuri Linkov <juri@linkov.net>
Tue, 4 Jun 2024 06:37:02 +0000 (09:37 +0300)
committerEshel Yaron <me@eshelyaron.com>
Tue, 4 Jun 2024 09:07:03 +0000 (11:07 +0200)
(outline-minor-mode): Add 'outline-revert-buffer-restore-visibility'
to 'revert-buffer-restore-functions' (bug#69511).

(cherry picked from commit f69826a63d18782e372753d25d14a35249ef605d)

lisp/outline.el

index b7afa6b3f45ec2f32d23d487ed0ab14879e4a4f0..80621c78b3b2e55fad665a6257c8c595099c15ba 100644 (file)
@@ -580,6 +580,8 @@ See the command `outline-mode' for more information on this mode."
        (add-hook 'change-major-mode-hook
                  (lambda () (outline-minor-mode -1))
                  nil t)
+        (add-hook 'revert-buffer-restore-functions
+                  #'outline-revert-buffer-restore-visibility nil t)
         (add-hook 'revert-buffer-restore-functions
                   (lambda ()
                     (when (and outline-minor-mode outline-minor-mode-highlight
@@ -1713,6 +1715,13 @@ for example, after reverting the buffer."
                    (concat "\\`" (regexp-quote heading) "\\'"))
                  (nreverse headings) "\\|"))))
 
+(defun outline-revert-buffer-restore-visibility ()
+  "Preserve visibility of outlines in `outline-minor-mode' for `revert-buffer'."
+  (let ((regexp (outline-hidden-headings-regexp)))
+    (when regexp
+      (lambda ()
+        (outline-hide-by-heading-regexp regexp)))))
+
 \f
 ;;; Visibility cycling