* Automatically set outline patterns and typeface for major modes
@ 2023-06-21 19:09 uzibalqa
0 siblings, 0 replies; only message in thread
From: uzibalqa @ 2023-06-21 19:09 UTC (permalink / raw)
To: uzibalqa via Users list for the GNU Emacs text editor
I have a minor mode that specifies the outline pattern and levels (using function outlhg-regexp
that sets outline-regexp, outline-heading-alist), and via the function outlhg-tyface to specify
the corresponding typeface for each heading level.
The appropriate settings need to be used associated with each major mode. Would one make a hook
to each major mode for outlhg-regexp ? And what about outlhg-tyface, would this also be called
through a hook?
Would it be like the following ?
(defun addhook-hgptn ()
"Remove the outline hierarchy functions from the major mode
hook variables."
(add-hook 'emacs-lisp-mode-hook #'outlhg-regexp)
(add-hook 'emacs-lisp-mode-hook #'outlhg-tyface)
(add-hook 'sh-mode-hook #'outlhg-regexp)
(add-hook 'sh-mode-hook #'outlhg-tyface)
(add-hook 'f90-mode-hook #'outlhg-regexp)
(add-hook 'f90-mode-hook #'outlhg-tyface)
(add-hook 'fortran-mode-hook #'outlhg-regexp)
(add-hook 'fortran-mode-hook #'outlhg-tyface)
(add-hook 'latex-mode-hook #'outlhg-regexp)
(add-hook 'latex-mode-hook #'outlhg-tyface)
(add-hook 'plain-tex-mode-hook #'outlhg-regexp)
(add-hook 'plain-tex-mode-hook #'outlhg-tyface) )
Here are the actual functions
(defun outlhg-regexp ()
(cond
((eq major-mode 'emacs-lisp-mode)
(let ( (hrklevels 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 bash-hrklevels) )
(setq outline-regexp
(concat (regexp-opt (mapcar 'car hrklevels)) "\\>"))
(setq outline-heading-alist hrklevels)))
((eq major-mode 'f90-mode)
(let ( (hrklevels fortran-hrklevels) )
(setq outline-regexp
(concat (regexp-opt (mapcar 'car hrklevels)) "\\>"))
(setq outline-heading-alist hrklevels)))
((eq major-mode 'fortran-mode)
(let ( (hrklevels f77-hrklevels) )
(setq outline-regexp
(concat (regexp-opt (mapcar 'car hrklevels)) "\\>"))
(setq outline-heading-alist hrklevels)))
((eq major-mode 'latex-mode)
(let ( (hrklevels latex-hrklevels) )
(setq outline-regexp
(concat (regexp-opt (mapcar 'car hrklevels)) "\\>"))
(setq outline-heading-alist hrklevels)))
((eq major-mode 'plain-tex-mode)
(let ( (hrklevels tex-hrklevels) )
(setq outline-regexp
(concat (regexp-opt (mapcar 'car hrklevels)) "\\>"))
(setq outline-heading-alist hrklevels))) ))
(defun outlhg-tyface ()
(interactive)
(let* ( (pigment-darkbg '("#ff62d4" "#9f80ff" "#fe6060" "#fba849"
"#4fe42f" "#4fafff" "#f0dd60" "#FFFFFF"))
(pigment-lightbg '("#1f1fce" "#006800" "#b60000" "#605b00"
"#a8007f" "#005f88" "#904200" "#7f10d0"))
(pigment
(if (eq (frame-parameter nil 'background-mode) 'dark)
pigment-darkbg
pigment-lightbg)) )
(dotimes (i 8)
(let ((hkfc (intern (format "outline-%d" (1+ i))))
(colr (nth i pigment)))
(set-face-foreground hkfc colr)))))
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-06-21 19:09 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-21 19:09 Automatically set outline patterns and typeface for major modes 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.