Subject: Re: bug#69254: 14.0.2; outline-hide-body doesn't work when called in LaTeX-mode-hook

From: Ikumi Keita <[email-masked]>
Date: Mon, 19 Feb 2024 18:41:57 +0900

Hi Richard,

>>>>> Richard Stanton via bug-auctex via Bug reporting list for AUCTeX <[email-masked]> writes:
> Using Emacs 29.2 under MacOS 12.7.3, I want LaTeX files to open with
> section bodies hidden, and just headers showing. I can get this to work
> manually when I'm editing the file by running the command
> "outline-hide-body". But when I run the same command as part of
> LaTeX-mode-hook, the file opens with nothing hidden.

> Here's the relevant portion of my init.el file. The rest of it just
> deals with setting up straight.el:

> (use-package tex :straight auctex)

> (add-hook 'LaTeX-mode-hook (lambda()
>                              (outline-minor-mode 1)
>                              (outline-hide-body)
>                              ))

> Note that:

> 1) If I add other commands to this LaTeX-mode-hook, they get executed just
> fine. it seems to be only the outline-hide-body command that isn't doing
> what I expect.

> 2) Everything works as I hope if I don't load AUCTeX but use the
> built-in LaTeX mode instead (with the appropriately renamed hook).

> Is this a bug, or am i missing something?

Sorry for bothering you. I think this is an outcome of the fix of
bug#65750[1] last September.

In the fix, settings for outline mode were deferred after the parsing
file local variables so that user's customize to section commands are
reflected to outline related functionalities. This however means that
`LaTeX-mode-hook' runs before outline mode settings are ready.

I haven't come up with a clean solutions yet. For a tentative
workaround, you can use
(add-hook 'LaTeX-mode-hook
	  (lambda ()
	    (add-hook 'find-file-hook
		      (lambda()
                        (outline-minor-mode 1)
                        (outline-hide-body))
		      nil t)))

instead of
(add-hook 'LaTeX-mode-hook (lambda()
                             (outline-minor-mode 1)
                             (outline-hide-body)
                             ))
.

[1] https://debbugs.gnu.org/cgi/bugreport.cgi?bug=65750

Regards,
Ikumi Keita
#StandWithUkraine #StopWarInUkraine
#Gaza #StopMassiveKilling #CeasefireNOW