From babf29aa2a4d69a57e141a9f35176ab74e63650d Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Mon, 3 Jun 2024 21:13:38 +0300 Subject: [PATCH] Move revert-buffer-restore-functions use from buff-menu.el to outline.el * 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 | 10 +--------- lisp/outline.el | 8 ++++++++ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lisp/buff-menu.el b/lisp/buff-menu.el index b431637414b..d59c5b6cf21 100644 --- a/lisp/buff-menu.el +++ b/lisp/buff-menu.el @@ -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" diff --git a/lisp/outline.el b/lisp/outline.el index 5f4d4f3dcba..b7afa6b3f45 100644 --- a/lisp/outline.el +++ b/lisp/outline.el @@ -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)) -- 2.39.5