Subject: bug#51809: 29.0.50; [PATCH] Support for outline default state in Diff buffers

From: Matthias Meulien <[email-masked]>
Date: Tue, 28 Dec 2021 23:28:31 +0100

Juri Linkov <[email-masked]> writes:

> (...)  Also xref works nicely, although I don't know why it requires
> `outline-apply-default-state' after enabling `outline-minor-mode':

It's a mistake to rely on `hack-local-variables-hook' to call
`outline-apply-default-state' when Outline minor mode is enabled since
`hack-local-variables-hook' is run after processing a file's local
variable specs.

An explicit call to `outline-apply-default-state' in the implementation
of outline-minor-mode fix the problem:

diff --git a/lisp/outline.el b/lisp/outline.el
index 1a878dee04..65956b9dae 100644
--- a/lisp/outline.el
+++ b/lisp/outline.el
@@ -439,8 +439,7 @@ outline-minor-mode
         (setq-local line-move-ignore-invisible t)
 	;; Cause use of ellipses for invisible text.
 	(add-to-invisibility-spec '(outline . t))
-        (add-hook 'hack-local-variables-hook
-                  #'outline-apply-default-state nil t))
+        (outline-apply-default-state))
     (when (or outline-minor-mode-cycle outline-minor-mode-highlight)
       (if font-lock-fontified
           (font-lock-remove-keywords nil outline-font-lock-keywords))

I'll send an updated patch after some time using this.
-- 
Matthias