all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Christopher Dimech <dimech@gmx.com>
To: Heime <heimeborgia@protonmail.com>
Cc: Heime via Users list for the GNU Emacs text editor
	<help-gnu-emacs@gnu.org>
Subject: Level of headings not recognised
Date: Sun, 11 Aug 2024 00:08:45 +0200	[thread overview]
Message-ID: <trinity-73cfb31d-8689-45bf-b953-4de6163d6d93-1723327725424@3c-app-mailcom-bs07> (raw)
In-Reply-To: <puET6WPAc6-Gkhhnb2nsxNOkFSMqxTh6pKT_szSAHJoBPngSBYGAYrHr3okCJavbyhh46nYIJWDArUHRcWAU07MdwF63JIgw6KwFa_M7tiI=@protonmail.com>

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

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	other threads:[~2024-08-10 22:08 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-10 15:07 Level of headings not recognised Heime
2024-08-10 17:49 ` Heime
2024-08-10 20:30   ` Heime
2024-08-10 22:08     ` Christopher Dimech [this message]
2024-08-11  0:02       ` Heime

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=trinity-73cfb31d-8689-45bf-b953-4de6163d6d93-1723327725424@3c-app-mailcom-bs07 \
    --to=dimech@gmx.com \
    --cc=heimeborgia@protonmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.