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: Jean Louis
Subject: Re: Setting up user defined texinfo headlines using outline-heading-alist
Date: Thu, 13 May 2021 21:29:31 +0300
User-agent: Mutt/2.0.6 (2021-03-06)

Hello Yuri,

Thank you for insightful explanation. 

* Yuri Khan <yuri.v.khan@gmail.com> [2021-05-13 19:12]:
>     outline-regexp is a variable defined in ‘outline.el’.
>     Its value is (regexp-op "[*^L]+"

Here, not quite sure, but how I see the above regular expression
it will fold on the new line where there is character ^L, is it?

> 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)) "\\>")))

Interesting, I did not know the `regexp-opt' function, that is
very handy. It finds the regular expression that will match the
given list of strings and I find your application smart.

(regexp-opt '("something" "anything")) ⇒ "\\(?:\\(?:any\\|some\\)thing\\)"

(regexp-opt '("TODO" "DONE" "DELEGATED")) ⇒ 
"\\(?:D\\(?:ELEGATED\\|ONE\\)\\|TODO\\)"

and that may be reused with certainty to work:

(highlight-regexp "\\(?:D\\(?:ELEGATED\\|ONE\\)\\|TODO\\)")


-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

Sign an open letter in support of Richard M. Stallman
https://stallmansupport.org/
https://rms-support-letter.github.io/




reply via email to

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