help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: minor-mode hook not run


From: Andreas Röhler
Subject: Re: minor-mode hook not run
Date: Wed, 21 Mar 2018 12:57:18 +0100
User-agent: Mozilla/5.0 (X11; Linux i686; rv:52.0) Gecko/20100101 Thunderbird/52.6.0

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 via email to

[Prev in Thread] Current Thread [Next in Thread]