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

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

Re: Allowing spaces in the regexp for outlines


From: Heime
Subject: Re: Allowing spaces in the regexp for outlines
Date: Wed, 27 Mar 2024 19:32:05 +0000

On Thursday, March 28th, 2024 at 7:12 AM, Christopher Dimech <dimech@gmx.com> 
wrote:

> > Sent: Thursday, March 21, 2024 at 4:32 PM
> > From: "Stefan Monnier via Users list for the GNU Emacs text editor" 
> > help-gnu-emacs@gnu.org
> > To: help-gnu-emacs@gnu.org
> > Subject: Re: Allowing spaces in the regexp for outlines
> > 
> > > Have made a regexp for outlines to use ';;;' followed by 'H' and a number.
> > > 
> > > I would like to allow any number of spaces between the ';;;' and the 
> > > letter 'H'.
> > > How can I change the regexp to allow such a capability ?
> > 
> > Why?
> 
> 
> There is already the functionality for changing the font-lock for 
> outline-minor-mode.
> So why not ! It is not so easy to do though. Because managing outlines in a 
> buffer
> is valuable for almost everybody, it would help for there to me clear 
> explanation
> of what has to be done with actual examples. Good for this would be in the 
> Introduction
> to Emacs Lisp Programming.

That would help a lot. How can one set general patterns for each outline level 
precisely ?

Is the way to do it like this

(defvar el-hglevels '( (";;; H1" . 1) (";;; H2" . 2) (";;; H3" . 3) ))
 
(setq outline-regexp (concat (regexp-opt (mapcar 'car el-hglevels)) "\\>"))
(setq outline-heading-alist el-hglevels)
(setq-local outline-level 'outline-level)

> > ELisp already has a set convention for outlining, where `;;;` is
> > a top-level heading, then `;;;;` is a subheading, `;;;;;` is
> > a subsubheading, etc...
> > 
> > Stefan



reply via email to

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