help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Setting up user defined texinfo headlines using outline-heading-alis


From: Yuri Khan
Subject: Re: Setting up user defined texinfo headlines using outline-heading-alist
Date: Thu, 13 May 2021 23:05:18 +0700

On Thu, 13 May 2021 at 22:10, Christopher Dimech <dimech@gmx.com> wrote:

> I have followed your suggestion of using a function that sets 
> outline-heading-alist
> using texinfo-mode-hook.
>
> Have included the following setup (see code section), yet I am still getting
>
> @node uchapter-amcoh
> @unnumbered 6 @ Ameliorating Waveform Coherency...
>
> whenever I hit  "C-C @ C-t" (Hide Body).  Should I not get @usec and @usubsec
> showing up as well?

Now that you gave a recipe, I was able to reproduce it. I saved your
test.texi and put your code into /tmp/20210513/.emacs and started
Emacs as “HOME=. emacs test.texi”. This way, my own config does not
affect the reproduction.

I pressed C-c @ C-t, and, yes, everything after the first heading got
collapsed. So next I pressed C-c @ C-h to see what other commands are
available. I spotted C-c @ C-a (outline-show-all) as the way to expand
it all back, and C-c @ C-n (outline-next-visible-heading) as a
reasonable way to check what Emacs thinks are your headings. And,
predictably, starting at the top, it stopped on @unnumbered, and then
at the bottom of the buffer. Which means it does not detect @usec as a
heading.

Next, I went to read the docstring on outline-next-visible-heading. And it says:

    A heading line is one that starts with a ‘*’ (or that
    ‘outline-regexp’ matches).

So next let’s see what outline-regexp is:

    outline-regexp is a variable defined in ‘outline.el’.
    Its value is "[*^L]+"
    […]
    Regular expression to match the beginning of a heading.
    Any line whose beginning matches this regexp is considered to
start a heading.
    Note that Outline mode only checks this regexp at the start of a line,
    so the regexp need not (and usually does not) start with ‘^’.

So let’s change your hook function to set that:

    (defun instate-texinfo-hdlevels ()
      (setq-local outline-heading-alist texinfo-hdlevels)
      (setq-local outline-regexp
                  (concat (regexp-opt (mapcar 'car texinfo-hdlevels)) "\\>")))

Now I press C-M-x within the above source to update the function
definition, switch to test.texi, and press M-x normal-mode RET to
reapply the major mode, which reruns all its hooks, which sets the
variables as needed. Now, C-c @ C-n from the top goes through
@unnumbered, @usec, @usec, @usubsec, @usec, @usubsec, bottom; and C-c
@ C-t leaves all custom headings visible:

    @node uchapter-amcoh
    @unnumbered 6 @ Ameliorating Waveform Coherency...
    @usec{@value{seclb}, Abductive Reasoning}...
    @usec{@value{seclb}, Parsimony over Complexity}...
    @usubsec{@value{seclb}, The Claerbout Conjecture}...
    @usec{@value{seclb}, Correlograms in Helioseismology}...
    @usubsec{@value{seclb}, Solar Magnetic Cycle and the Interface Dynamo}...

Now I save the modified .emacs and restart this Emacs instance to see
if my solution works when applied from the init file. It does, so I am
confident enough to post it.

Next you might want to read the full docstring for outline-regexp, as
it tells you the recommended way to set it so that it travels with
your file rather than lives in your personal configuration. You might
also see if setting outline-heading alist the same way works.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]