Re: Managing outline-minor-mode to mode hooks

Zhengyi Fu <[email protected]> Fri, 03 Jul 2026 13:08:56 +0800
Newsgroups gmane.emacs.help
Message-ID <[email protected]>
Heime <[email protected]> writes:

> Is there a better way that might improve the addition or 
> removal of outline-minor-mode?  Perhaps simply apply more
> conveniently to prog-mode-hook?  Are there any other modes 
> where it would be advantageous to add outline-minor-mode? 
>
>
> (defun kronaire-outlmr-mdhooks (actm)
>   (let ( (mhls '(sh-mode-hook
>                  python-mode-hook
>                  emacs-lisp-mode-hook
>                  lisp-interaction-mode-hook
>                  org-mode-hook
>                  latex-mode-hook
>                  texinfo-mode-hook
>                  plain-tex-mode-hook
>                  f90-mode-hook
>                  fortran-mode-hook))
>
>          (hkfn (cond
>                   ((eq actm 'add) #'add-hook)
>                   ((eq actm 'remove) #'remove-hook)
>                   (t (error "%s ACTM %s is invalid"
>                        "kronaire-outl-mdhooks, "
>                        actm)))) )
>
>     (dolist (mdhook mhls)
>       ;; (funcall 'add-hook sh-mode-hook #'outline-minor-mode)
>       (funcall hkfn mdhook #'outline-minor-mode)) ))

It may be a good idea to define a globalize minor mode.

(defun turn-on-outline-minor-mode ()
  (outline-minor-mode 1))

(define-globalized-minor-mode
  global-outline-minor-mode
  outline-minor-mode
  turn-on-outline-minor-mode
  :predicate '(sh-mode
	       python-mode
	       emacs-lisp-mode
	       lisp-interaction-mode
	       org-mode
	       latex-mode
	       texinfo-mode
	       plain-tex-mode
	       f90-mode
	       fortran-mode))