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

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

Re: Level of headings not recognised


From: Heime
Subject: Re: Level of headings not recognised
Date: Sun, 11 Aug 2024 00:02:29 +0000

On Sunday, August 11th, 2024 at 10:08 AM, Christopher Dimech <dimech@gmx.com> 
wrote:

> > Sent: Sunday, August 11, 2024 at 8:30 AM
> > From: "Heime" heimeborgia@protonmail.com
> > To: "Heime" heimeborgia@protonmail.com
> > Cc: "Heime via Users list for the GNU Emacs text editor" 
> > help-gnu-emacs@gnu.org
> > Subject: Re: Level of headings not recognised
> > 
> > On Sunday, August 11th, 2024 at 5:49 AM, Heime heimeborgia@protonmail.com 
> > wrote:
> > 
> > > On Sunday, August 11th, 2024 at 3:07 AM, Heime heimeborgia@protonmail.com 
> > > wrote:
> > > 
> > > > What is wrong in setting heading levels this way ?
> > > > 
> > > > When I apply the following code, Level H1 is considered at same 
> > > > hierarchy as
> > > > other levels. This means that if I do "Hide Sublevels" headings at 
> > > > levels 2,
> > > > 3 etc still get displayed.
> > > > 
> > > > (defvar mast-elisp-levels
> > > > '( (";;; H1" . 1) (";;; H2" . 2) (";;; H3" . 3) (";;; H4" . 4)
> > > > (";;; H5" . 5) (";;; H6" . 6) (";;; H7" . 7) (";;; H8" . 8) ))
> > > > 
> > > > (defun mast-regexp ()
> > > > 
> > > > (let ( (hrklevels nil) )
> > > > 
> > > > (cond
> > > > ((memq major-mode '(emacs-lisp-mode lisp-interaction-mode))
> > > > (setq hrklevels mast-elisp-levels)))
> > > > 
> > > > (when hrklevels
> > > > (setq outline-regexp
> > > > (concat (regexp-opt (mapcar 'car hrklevels)) "\\>"))
> > > > 
> > > > (setq outline-heading-alist hrklevels)) ))
> > > > 
> > > > (defun mast-regexp-hooks (actm)
> > > > 
> > > > (let ( (kmdalit '(emacs-lisp-mode-hook
> > > > lisp-interaction-mode-hook) )
> > > > 
> > > > (hook-fn (cond
> > > > ((eq actm 'add) #'add-hook)
> > > > ((eq actm 'remove) #'remove-hook)
> > > > (t (error "ACTM %s is invalid" actm)))) )
> > > > 
> > > > (dolist (mdhk kmdalit)
> > > > (funcall hook-fn mdhk #'mast-regexp)) ))
> > > 
> > > Should one use setq, setq-local, steq-default. Cannot get headings to
> > > work from level 2 to 8
> > 
> > I am getting into extreme difficulty in setting outline-regexp. How should 
> > it be set ?
> 
> 
> Apply
> 
> (setq-local outline-level 'outline-level)

Would never have figured this out.

 
> The setting ensures that the outline-minor-mode correctly recognizes and 
> interprets
> the hierarchical levels of headings when using custom regex patterns.
> 
> The variable outline-level determines the depth of each heading in the 
> outline.
> By default, this is set to a function that calculates the level based on the 
> number
> of leading asterisks (*) in a heading.
> 
> When you define custom heading levels using outline-regexp and 
> outline-heading-alist,
> the mode needs to know how to calculate the outline levels correctly.
> 
> setq-local sets the value of outline-level locally for the current buffer. 
> This is
> important because you want the custom level recognition to apply only in 
> specific
> modes (like emacs-lisp-mode) and not globally across all buffers.
> 
> By setting outline-level locally, you ensure that outline-minor-mode uses the 
> correct
> function to calculate the levels based on your custom setup. If you don't set
> outline-level locally, outline-minor-mode might fall back on its default 
> behavior,
> which expects levels to be calculated based on asterisks or other default 
> indicators.



reply via email to

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