* Level of headings not recognised @ 2024-08-10 15:07 Heime 2024-08-10 17:49 ` Heime 0 siblings, 1 reply; 5+ messages in thread From: Heime @ 2024-08-10 15:07 UTC (permalink / raw) To: Heime via Users list for the GNU Emacs text editor 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)) )) ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Level of headings not recognised 2024-08-10 15:07 Level of headings not recognised Heime @ 2024-08-10 17:49 ` Heime 2024-08-10 20:30 ` Heime 0 siblings, 1 reply; 5+ messages in thread From: Heime @ 2024-08-10 17:49 UTC (permalink / raw) To: Heime; +Cc: Heime via Users list for the GNU Emacs text editor 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 ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Level of headings not recognised 2024-08-10 17:49 ` Heime @ 2024-08-10 20:30 ` Heime 2024-08-10 22:08 ` Christopher Dimech 0 siblings, 1 reply; 5+ messages in thread From: Heime @ 2024-08-10 20:30 UTC (permalink / raw) To: Heime; +Cc: Heime via Users list for the GNU Emacs text editor 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 ? ^ permalink raw reply [flat|nested] 5+ messages in thread
* Level of headings not recognised 2024-08-10 20:30 ` Heime @ 2024-08-10 22:08 ` Christopher Dimech 2024-08-11 0:02 ` Heime 0 siblings, 1 reply; 5+ messages in thread From: Christopher Dimech @ 2024-08-10 22:08 UTC (permalink / raw) To: Heime; +Cc: Heime via Users list for the GNU Emacs text editor > 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. ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Level of headings not recognised 2024-08-10 22:08 ` Christopher Dimech @ 2024-08-11 0:02 ` Heime 0 siblings, 0 replies; 5+ messages in thread From: Heime @ 2024-08-11 0:02 UTC (permalink / raw) To: Christopher Dimech; +Cc: Heime via Users list for the GNU Emacs text editor 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. ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-08-11 0:02 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 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 2024-08-11 0:02 ` Heime
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.