unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Heime <heimeborgia@protonmail.com>
To: Heime <heimeborgia@protonmail.com>
Cc: Yuri Khan <yuri.v.khan@gmail.com>,
	Heime via Users list for the GNU Emacs text editor
	<help-gnu-emacs@gnu.org>
Subject: Re: Functions which are mode dependent
Date: Mon, 26 Aug 2024 22:35:58 +0000	[thread overview]
Message-ID: <I6VML3_I5TQOCSm2JO2xdauQ49QvocWIWh0Kqk3haCIKVIM7CHtK0wzlEw0qUviFzRtwzx5R5VboP3mKoyg6pSAJB7A3STAXS1rE6xXncoU=@protonmail.com> (raw)
In-Reply-To: <yrsPey3L_VMkud1UE4kCE5KEF6_YlI_2EpZXzoqiVQrYbEBjP4M1pcG3fd_3-qyR5HFGvDB1TBc8Oa-It406zhlu8tu7XgSKKZK0Dvcfd2E=@protonmail.com>






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



      reply	other threads:[~2024-08-26 22:35 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-18 21:14 Functions which are mode dependent Heime
2024-08-20 21:49 ` Heime
2024-08-22 13:26   ` Heime
2024-08-23 10:05   ` Joel Reicher
2024-08-23 12:26     ` Heime
2024-08-22 18:29 ` Stefan Monnier via Users list for the GNU Emacs text editor
2024-08-22 18:42   ` Heime
2024-08-22 18:58 ` Yuri Khan
2024-08-22 22:07   ` Heime
2024-08-22 22:16     ` Heime
2024-08-22 23:38       ` Heime
2024-08-24  9:46         ` Heime
2024-08-24 10:20           ` Yuri Khan
2024-08-24 11:33             ` Heime
2024-08-24 21:08               ` Heime
2024-08-26 22:35                 ` Heime [this message]
     [not found] <cZeTZGgEO8ZqskRdwTYwyC8I8Nbdvc559IWYt1uERmxLYkgONsnVPIUsdZWEE43YjvR97Osjq3ZFn72HYANJnd0uZM10K1BZlgM-2iUDyAI=3D@protonmail.com>
     [not found] ` <CAP=5Fd=5F8XY-OK4kGu9LigEqbKiQgGft3ShWY58mrUPwqPcn15VPQ@mail.gmail.com>
     [not found]   ` <3RfPnnmfz0Qgr0JGJbNKnydaMu1QfnGGBk7xX7qxkXSkzXBNt8snc9Ye1n6AvZtOln0VoPDXmjnYc=5FX5lGkPVxnvPPlBbjvnuKMQs4cki18=3D@protonmail.com>
     [not found]     ` <qAaQUpb=5FJAFuU-wWLUZIi9mi6FRdXycVjQbRTi7ntswqlXGkv1k=5FaIwP9lr0av3lZ15ls2QpARUIkXOVwhHrlJ4wfyNv9PfiHjuVVzTANvc=3D@protonmail.com>
     [not found]       ` <b3r6FxVdJog97l0Sg4GtNPjvqS0kLsrpkgPKr8zOQnU3yNSLFkyCXgnGcrSaAT6hYmjme8qhUm3ecdhut8r6DXd4Hg=5FjRH0cU19tfjx=5F9JI=3D@protonmail.com>
     [not found]         ` <Y7NJnzV2gxP2ItkZNRVxRX8eD0Y-uEnE2EXo07CPNuckyabsLJoKMkpD82ReWhb3tFdL6uCFSsaLBhfZX7yXihd=5FNlUCgc2oBCFBbiv=5FCAw=3D@protonmail.com>
     [not found]           ` <CAP=5Fd=5F8UR+=3DB1GAKOTLwjgM=5FQ=5FGRbQttrwtO4 PD7wx9sJFErpcQ@mail.gmail.com>
     [not found]             ` <uumSbkMJHz2MJY2Yok3T3XDtIY2hSd8f=5FAYXIAqCmJYiv5Lf3in4c22uy6658I8RnsI4iIF-XWzGlfSPdX=5F13c6k1VPGPXov0Nnzeplp8e0=3D@protonmail.com>

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='I6VML3_I5TQOCSm2JO2xdauQ49QvocWIWh0Kqk3haCIKVIM7CHtK0wzlEw0qUviFzRtwzx5R5VboP3mKoyg6pSAJB7A3STAXS1rE6xXncoU=@protonmail.com' \
    --to=heimeborgia@protonmail.com \
    --cc=help-gnu-emacs@gnu.org \
    --cc=yuri.v.khan@gmail.com \
    /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).