From: Juri Linkov Date: Tue, 4 Jun 2024 16:53:47 +0000 (+0300) Subject: * lisp/outline.el (outline-revert-buffer-rehighlight): New function. X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=387afbcb1fdec3b7e90850f17a7e6b9f35f3c87a;p=emacs.git * 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'. (cherry picked from commit 7f415f7d5e19ea3903500426a0724e49271ac699) --- diff --git a/lisp/outline.el b/lisp/outline.el index 74c679797aa..373902e3f59 100644 --- a/lisp/outline.el +++ b/lisp/outline.el @@ -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