* Setting outline-regexp automatically for a major mode
@ 2023-06-22 12:20 uzibalqa
0 siblings, 0 replies; only message in thread
From: uzibalqa @ 2023-06-22 12:20 UTC (permalink / raw)
To: uzibalqa via Users list for the GNU Emacs text editor
I have made a minor mode called tika that gets activated automatically for some
major modes.
I use hooks for that
(defun tika-addhook ()
"Activate minor-mode' automatically for specific major-modes."
(add-hook 'emacs-lisp-mode-hook #'tika-minor-mode)
(add-hook 'sh-mode-hook #'tika-minor-mode)
(add-hook 'f90-mode-hook #'tika-minor-mode)
(add-hook 'fortran-mode-hook #'tika-minor-mode)
(add-hook 'latex-mode-hook #'tika-minor-mode)
(add-hook 'plain-tex-mode-hook #'tika-minor-mode))
This minor mode also sets the variables outline-regexp and outline-heading-alist
according to the specific major mode using the function tika-outlhg-regexp. Which
I want to run automatically as soon as a file gets loaded.
Would one make hooks for the function like so, or do something else
(defun tika-addhook-hgptn ()
(add-hook 'emacs-lisp-mode-hook #'tika-outlhg-regexp)
(add-hook 'sh-mode-hook #'tika-outlhg-regexp)
(add-hook 'f90-mode-hook #'tika-outlhg-regexp)
(add-hook 'fortran-mode-hook #'tika-outlhg-regexp)
(add-hook 'latex-mode-hook #'tika-outlhg-regexp)
(add-hook 'plain-tex-mode-hook #'tika-outlhg-regexp) )
When should tika-addhook-hgptn be called ? I have been thinking
of doing the following
(require 'tika)
(tika-addhook)
(tika-addhook-hgptn)
Or is the above complicating a simple thing ?
This is the function setting outline-regexp and outline-heading-alist
(defun tika-outlhg-regexp ()
(cond
((eq major-mode 'emacs-lisp-mode)
(let ( (hrklevels tematika-elisp-hrklevels) )
(setq outline-regexp
(concat (regexp-opt (mapcar 'car hrklevels)) "\\>"))
(setq outline-heading-alist hrklevels)
(setq-local outline-level 'outline-level)))
((eq major-mode 'sh-mode)
(let ( (hrklevels tematika-bash-hrklevels) )
(setq outline-regexp
(concat (regexp-opt (mapcar 'car hrklevels)) "\\>"))
(setq outline-heading-alist hrklevels)))
((eq major-mode 'f90-mode)
(let ( (hrklevels tematika-fortran-hrklevels) )
(setq outline-regexp
(concat (regexp-opt (mapcar 'car hrklevels)) "\\>"))
(setq outline-heading-alist hrklevels)))
((eq major-mode 'fortran-mode)
(let ( (hrklevels tematika-f77-hrklevels) )
(setq outline-regexp
(concat (regexp-opt (mapcar 'car hrklevels)) "\\>"))
(setq outline-heading-alist hrklevels)))
((eq major-mode 'latex-mode)
(let ( (hrklevels tematika-latex-hrklevels) )
(setq outline-regexp
(concat (regexp-opt (mapcar 'car hrklevels)) "\\>"))
(setq outline-heading-alist hrklevels)
(setq-local outline-level 'outline-level)))
((eq major-mode 'plain-tex-mode)
(let ( (hrklevels tematika-tex-hrklevels) )
(setq outline-regexp
(concat (regexp-opt (mapcar 'car hrklevels)) "\\>"))
(setq outline-heading-alist hrklevels))) ))
;; tematika-outlhg-regexp ends here
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-06-22 12:20 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-22 12:20 Setting outline-regexp automatically for a major mode uzibalqa
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.