unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: "Andreas Röhler" <andreas.roehler@easy-emacs.de>
To: help-gnu-emacs@gnu.org
Subject: Re: minor-mode hook not run
Date: Wed, 21 Mar 2018 12:57:18 +0100	[thread overview]
Message-ID: <83fcbe37-e20f-a79c-bc00-01ff5c31225d@easy-emacs.de> (raw)
In-Reply-To: <jwvzi32wl1b.fsf-monnier+gmane.emacs.help@gnu.org>

On 20.03.2018 21:31, Stefan Monnier wrote:
>> (define-minor-mode foo
>                       ^^^
> This should likely be `foo-mode`.
> 
>>    "Do something" nil " FOO"}
> 
> Is the above } intended?

No, it's a typo, sorry.

> 
>>    :keymap foo-map
> 
> [ I strongly recommend not to use :keymap argument and just name your
>    minor mode map `<MINORMODE>-map`.  ]
> 
>>    (cond
>>     ((eq major-mode 'abc)
> 
> It's usually better to test (derived-mode-p 'abc).

Okay, done.


> 
>>      (add-hook 'foo-mode-hook 'foo-load-abc nil t)
> 
> Adding elements to one's own hook here definitely deserve a "bug ugly
> hack" comment explaining why you'd want to do it that way.

Hmm, not sure if I understand that part.

Purpose is a generic key for related commands:
For example to start a REPL, haskell-mode calls
‘haskell-interactive-switch’, python.el calls ‘run-python’,
python-mode.el ‘py-shell’ etc.

Instead of remembering different keys and change them maybe at several
locations, a unified command ‘gk-repl’ is provided, whose key-binding
should DTRT in all modes.

For the audacious:
https://github.com/andreas-roehler/general-key

> 
> In any case, the minor mode `foo` will run `foo-hook` but not
> `foo-mode-hook` (which would be run by the `foo-mode` minor mode).
> 

That solved it, thanks all,

Andreas



  reply	other threads:[~2018-03-21 11:57 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-20 18:39 minor-mode hook not run Andreas Röhler
2018-03-20 20:31 ` Stefan Monnier
2018-03-21 11:57   ` Andreas Röhler [this message]
2018-03-22 13:52     ` Stefan Monnier
2018-03-23 12:46       ` Andreas Röhler
2018-03-20 20:31 ` John Shahid
     [not found] ` <mailman.10975.1521577943.27995.help-gnu-emacs@gnu.org>
2018-03-20 21:17   ` Emanuel Berg

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=83fcbe37-e20f-a79c-bc00-01ff5c31225d@easy-emacs.de \
    --to=andreas.roehler@easy-emacs.de \
    --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).