unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Disabling minor mode after setting imenu-generic-expression
@ 2024-08-28 23:22 Heime
  0 siblings, 0 replies; 6+ messages in thread
From: Heime @ 2024-08-28 23:22 UTC (permalink / raw)
  To: Heime via Users list for the GNU Emacs text editor

Have set 'imenu-generic-expression' for a buffer when it is in 'emacs-lisp-mode'
using '(eq major-mode'.  Customarily, it is the major mode sets the default value
to 'imenu-generic-expression'.  I want to save the original value, so that when 
I deactivate the minor mode, I reset 'imenu-generic-expression' to any previous
value before the minor mode changed it.

How can I do so ?

(defun tema-expr-elisp ()

(setq imenu-generic-expression
  `( ("defun"
        ,(concat "^\\s-*"
                 "(\\(defun\\|define-minor-mode\\)\\s-+"
                 "\\(\\(\\sw\\|\\s_\\)+\\)") 2) )) )

;;;###autoload
(define-minor-mode tema-minor-mode
  "DESC."
  :init-value nil
  :lighter " Tema"

  (if tema-minor-mode
      (progn
        (cond
          ((eq major-mode 'sh-mode) (tema-expr-sh))
          ((eq major-mode 'emacs-lisp-mode) (tema-expr-elisp))))
    (tema-disable-function) ))




^ permalink raw reply	[flat|nested] 6+ messages in thread
* Disabling minor mode after setting imenu-generic-expression
@ 2024-08-27 19:00 Heime
  2024-08-28  5:15 ` Yuri Khan
  0 siblings, 1 reply; 6+ messages in thread
From: Heime @ 2024-08-27 19:00 UTC (permalink / raw)
  To: Heime via Users list for the GNU Emacs text editor

Have set 'imenu-generic-expression' for a buffer when it is in 'emacs-lisp-mode'
using '(eq major-mode'.  But how do I revert back to the initial sate after disabling
the minor mode ?  What should 'tema-disable-function' do  exactly ?

(defun tema-expr-elisp ()

  (setq imenu-generic-expression
    `( ("defun"
          ,(concat "^\\s-*"
                   "(\\(defun\\|define-minor-mode\\)\\s-+"
                   "\\(\\(\\sw\\|\\s_\\)+\\)") 2) )) )

;;;###autoload
(define-minor-mode tema-minor-mode
  "DESC."
  :init-value nil
  :lighter " Tema"

  (if tema-minor-mode
      (progn
        ;; Apply the configuration for the current buffer if the major mode matches
        (cond
          ((eq major-mode 'sh-mode) (tema-expr-sh))
          ((eq major-mode 'emacs-lisp-mode) (tema-expr-elisp))))
    (tema-disable-function) ))





^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-08-29 10:21 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-28 23:22 Disabling minor mode after setting imenu-generic-expression Heime
  -- strict thread matches above, loose matches on Subject: below --
2024-08-27 19:00 Heime
2024-08-28  5:15 ` Yuri Khan
2024-08-28  9:09   ` Heime
2024-08-29  1:21   ` Stefan Monnier via Users list for the GNU Emacs text editor
2024-08-29 10:21     ` Heime

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).