[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: |
Mon, 26 Aug 2024 22:35:58 +0000 |
Sent with Proton Mail secure email.
On Sunday, August 25th, 2024 at 9:08 AM, Heime <heimeborgia@protonmail.com>
wrote:
> On Saturday, August 24th, 2024 at 11:33 PM, Heime heimeborgia@protonmail.com
> wrote:
>
> > On Saturday, August 24th, 2024 at 10:20 PM, Yuri Khan yuri.v.khan@gmail.com
> > wrote:
> >
> > > On Sat, 24 Aug 2024 at 16:46, Heime heimeborgia@protonmail.com wrote:
> > >
> > > > 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 ?
> > >
> > > No. Consider:
> > >
> > > 1. You open an Elisp file (C-x C-f /home/me/some.el RET).
> > > 2. A buffer is created.
> > > 3. The file’s contents are loaded into the buffer.
> > > 4. The buffer switches to emacs-lisp-mode.
> > > 5. emacs-lisp-mode runs emacs-lisp-mode-hook. At this point, the hook
> > > is empty so nothing special happens.
> > > 6. You enable your minor mode (M-x tema-minor-mode RET).
> > > 7. It adds tema-imenu-expr-elisp to emacs-lisp-mode-hook, but at this
> > > point it is too late for your current buffer.
> > >
> > > Observed result: your minor mode is enabled in the buffer of some.el,
> > > but its configuration is not applied.
>
>
> When enabling the minor mode in an already opened buffer, I can check the
> current major-mode and directly call the appropriate configuration function
> (tema-imenu-expr-sh or tema-imenu-expr-elisp) for the current buffer.
>
This should not use any hooks, to make tema-imenu-expr-elisp activate
for the current buffer. This should be a good idea I think.
But then, how would one disable the tema-imenu-expr-sh setting when the
minor-mode is turned off ?
;;;###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-imenu-expr-sh))
((eq major-mode 'emacs-lisp-mode) (tema-imenu-expr-elisp))))
(tema-disable-imenu) ))
- Re: Functions which are mode dependent, (continued)
- Re: Functions which are mode dependent, Stefan Monnier, 2024/08/22
- Re: Functions which are mode dependent, Yuri Khan, 2024/08/22
- Re: Functions which are mode dependent, Heime, 2024/08/22
- Re: Functions which are mode dependent, Heime, 2024/08/22
- Re: Functions which are mode dependent, Heime, 2024/08/22
- Re: Functions which are mode dependent, Heime, 2024/08/24
- Re: Functions which are mode dependent, Yuri Khan, 2024/08/24
- Re: Functions which are mode dependent, Heime, 2024/08/24
- Re: Functions which are mode dependent, Heime, 2024/08/24
- Re: Functions which are mode dependent,
Heime <=