]> git.eshelyaron.com Git - emacs.git/commitdiff
Move revert-buffer-restore-functions use from buff-menu.el to outline.el
authorJuri Linkov <juri@linkov.net>
Mon, 3 Jun 2024 18:13:38 +0000 (21:13 +0300)
committerEshel Yaron <me@eshelyaron.com>
Mon, 3 Jun 2024 19:33:32 +0000 (21:33 +0200)
* lisp/buff-menu.el (Buffer-menu-mode): Remove
revert-buffer-restore-functions with handling of
outline-minor-mode and move it to outline-minor-mode.

* lisp/outline.el (outline-minor-mode):
Add revert-buffer-restore-functions to call
outline-minor-mode-highlight-buffer after reverting the buffer
with outline-minor-mode and outline-minor-mode-highlight
where font-lock can't be used to update highlighting.

(cherry picked from commit fe79a6ff507670a2ab79fca060c2727fcd0a4dae)

lisp/buff-menu.el
lisp/outline.el

index b431637414b0edf32950b88cd17140effef0a753..d59c5b6cf213b2269da75af109d9e8ab6da09d59 100644 (file)
@@ -232,8 +232,6 @@ then the buffer will be displayed in the buffer list.")
     ["Quit" quit-window
      :help "Remove the buffer menu from the display"]))
 
-(declare-function outline-minor-mode-highlight-buffer "outline" ())
-
 (define-derived-mode Buffer-menu-mode tabulated-list-mode "Buffer Menu"
   "Major mode for Buffer Menu buffers.
 The Buffer Menu is invoked by the commands \\[list-buffers],
@@ -276,13 +274,7 @@ In Buffer Menu mode, the following commands are defined:
   :interactive nil
   (setq-local buffer-stale-function
               (lambda (&optional _noconfirm) 'fast))
-  (add-hook 'tabulated-list-revert-hook 'list-buffers--refresh nil t)
-  (add-hook 'revert-buffer-restore-functions
-            (lambda ()
-              (when (bound-and-true-p outline-minor-mode)
-                (lambda ()
-                  (outline-minor-mode-highlight-buffer))))
-            nil t))
+  (add-hook 'tabulated-list-revert-hook 'list-buffers--refresh nil t))
 
 (defun buffer-menu--display-help ()
   (message "%s"
index 5f4d4f3dcbaae6e05bac6cdf6be5c2dc3fcb532e..b7afa6b3f45ec2f32d23d487ed0ab14879e4a4f0 100644 (file)
@@ -580,6 +580,14 @@ 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
+                  (lambda ()
+                    (when (and outline-minor-mode outline-minor-mode-highlight
+                               (not (and global-font-lock-mode
+                                         (font-lock-specified-p major-mode))))
+                      (lambda ()
+                        (outline-minor-mode-highlight-buffer))))
+                  nil t)
         (setq-local line-move-ignore-invisible t)
        ;; Cause use of ellipses for invisible text.
        (add-to-invisibility-spec '(outline . t))