unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Heime <heimeborgia@protonmail.com>
To: Heime via Users list for the GNU Emacs text editor
	<help-gnu-emacs@gnu.org>
Subject: Disabling minor mode after setting imenu-generic-expression
Date: Wed, 28 Aug 2024 23:22:45 +0000	[thread overview]
Message-ID: <qQUKFVc3Y0S95cod4Q6OJDrTTPU9QQpspTR7m-uL--hWVd5SWIjOE6VUh9MoSm_lV7D7v7bakGKtq_xpv1UO-0MpdnQhQ-R9hrbqTNg8GbY=@protonmail.com> (raw)

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) ))




             reply	other threads:[~2024-08-28 23:22 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-28 23:22 Heime [this message]
  -- strict thread matches above, loose matches on Subject: below --
2024-08-27 19:00 Disabling minor mode after setting imenu-generic-expression 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='qQUKFVc3Y0S95cod4Q6OJDrTTPU9QQpspTR7m-uL--hWVd5SWIjOE6VUh9MoSm_lV7D7v7bakGKtq_xpv1UO-0MpdnQhQ-R9hrbqTNg8GbY=@protonmail.com' \
    --to=heimeborgia@protonmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).