From 3b5c8e80b0c10add7fae0e305ec954ca9d0bcb12 Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Tue, 4 Jun 2024 09:37:02 +0300 Subject: [PATCH] * lisp/outline.el (outline-revert-buffer-restore-visibility): New function. (outline-minor-mode): Add 'outline-revert-buffer-restore-visibility' to 'revert-buffer-restore-functions' (bug#69511). (cherry picked from commit f69826a63d18782e372753d25d14a35249ef605d) --- lisp/outline.el | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lisp/outline.el b/lisp/outline.el index b7afa6b3f45..80621c78b3b 100644 --- a/lisp/outline.el +++ b/lisp/outline.el @@ -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))))) + ;;; Visibility cycling -- 2.39.5