help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Functions which are mode dependent


From: Heime
Subject: Re: Functions which are mode dependent
Date: Sat, 24 Aug 2024 09:46:44 +0000

Is this be the correct way for a minor mode to use the variable
tema-expr-elisp for imenu-generic-expression that will be applied
when enabling tema-minor-mode on a buffer in emacs-lisp-mode ?

(defvar tema-expr-elisp
  '(("Functions" "^\\s-(defun\\s-+\\(\\_<.?\\_>\\)" 1)))
 
(defun tema-imenu-expr-elisp ()
  "Set up a custom imenu expression for the current buffer."
  (setq-local imenu-generic-expression tema-expr-elisp))
 
;;;###autoload
(define-minor-mode tema-minor-mode
  "DESC."
  :init-value nil
  :lighter " Tema"
 
  (if tema-minor-mode
      (progn
        (add-hook 'sh-mode-hook #'tema-imenu-expr-sh)
        (add-hook 'emacs-lisp-mode-hook #'tema-imenu-expr-elisp))
    (remove-hook 'sh-mode-hook #'tema-imenu-expr-sh)
    (remove-hook 'emacs-lisp-mode-hook #'tema-imenu-expr-elisp)))
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]