Subject: bug#65750: 12.2; LaTeX-mark-section and LaTeX-section-list

From: Ikumi Keita <[email-masked]>
Date: Thu, 07 Sep 2023 14:56:07 +0900

Hi Janet,

>>>>> Janet Chen <[email-masked]> writes:
> I've added a custom section to LaTeX-section-list, but LaTeX-mark-section ignores it. This may be the intended behavior, but I think it would make more sense for it to mark sections based on the entries in LaTeX-section-list.
> In case it matters, here's the buffer local value of my LaTeX-section-list:
> (("part" 0)
>  ("chapter" 1)
>  ("section" 2)
>  ("nsection" 2)
>  ("subsection" 3)
>  ("subsubsection" 4)
>  ("paragraph" 5)
>  ("subparagraph" 6))

Sorry for inconvenience. I assume you have file local variable section
like this:
%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% LaTeX-section-list: (("part" 0) ("chapter" 1) ("section" 2) ("nsection" 2) ("subsection" 3) ("subsubsection" 4) ("paragraph" 5) ("subparagraph" 6))
%%% End:

For a tentative workaround, add the following code block in your init
file (~/.emacs.d/init.el) and try it out:
(add-hook 'LaTeX-mode-hook
	  (lambda ()
	    (add-hook 'hack-local-variables-hook
		      (lambda ()
			(setq-local outline-regexp (LaTeX-outline-regexp t))
			(setq outline-heading-alist
			      (mapcar (lambda (x)
					(cons (concat "\\" (nth 0 x)) (nth 1 x)))
				      LaTeX-section-list)))
		      nil t)))

To developers:
`LaTeX-common-initialization' sets up some variables including
`outline-regexp' and `outline-heading-alist' before `run-mode-hooks',
which is responsible for parsing and applying the file local variables.
Shouldn't we move such set-up codes after `run-mode-hooks'? (And if so,
similar argument applies for other AUCTeX major modes as well.)

Regards,
Ikumi Keita
#StandWithUkraine #StopWarInUkraine