* lisp/outline.el (outline-revert-buffer-rehighlight): New function.

(outline-minor-mode): Add 'outline-revert-buffer-rehighlight' to
'revert-buffer-restore-functions'.  When mode is disabled,
remove hooks from 'revert-buffer-restore-functions' and
also from 'after-change-functions'.
This commit is contained in:
Juri Linkov 2024-06-04 19:53:47 +03:00
parent 00d7845953
commit 7f415f7d5e

View file

@ -583,17 +583,17 @@ See the command `outline-mode' for more information on this mode."
(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
(not (and global-font-lock-mode
(font-lock-specified-p major-mode))))
(lambda ()
(outline-minor-mode-highlight-buffer))))
nil t)
#'outline-revert-buffer-rehighlight nil t)
(setq-local line-move-ignore-invisible t)
;; Cause use of ellipses for invisible text.
(add-to-invisibility-spec '(outline . t))
(outline-apply-default-state))
(remove-hook 'after-change-functions
#'outline--fix-buttons-after-change t)
(remove-hook 'revert-buffer-restore-functions
#'outline-revert-buffer-restore-visibility t)
(remove-hook 'revert-buffer-restore-functions
#'outline-revert-buffer-rehighlight t)
(setq line-move-ignore-invisible nil)
;; Cause use of ellipses for invisible text.
(remove-from-invisibility-spec '(outline . t))
@ -1724,6 +1724,17 @@ under `outline-minor-mode' is reverted by `revert-buffer'."
(lambda ()
(outline-hide-by-heading-regexp regexp)))))
(defun outline-revert-buffer-rehighlight ()
"Rehighlight outlines when reverting buffer under `outline-minor-mode'.
This function rehighlightes outlines after the buffer under
`outline-minor-mode' is reverted by `revert-buffer' when font-lock
can't update highlighting for `outline-minor-mode-highlight'."
(when (and outline-minor-mode-highlight
(not (and global-font-lock-mode
(font-lock-specified-p major-mode))))
(lambda ()
(outline-minor-mode-highlight-buffer))))
;;; Visibility cycling