GNU bug report logs - #41682
makefile-gmake-mode does not trigger "eval-after-load"'s hooks

Previous Next

Package: emacs;

Reported by: Konstantin Kharlamov <hi-angel <at> yandex.ru>

Date: Wed, 3 Jun 2020 08:20:02 UTC

Severity: normal

Tags: notabug

Done: "Basil L. Contovounesios" <contovob <at> tcd.ie>

Bug is archived. No further changes may be made.

Full log


Message #11 received at 41682 <at> debbugs.gnu.org (full text, mbox):

From: "Basil L. Contovounesios" <contovob <at> tcd.ie>
To: Konstantin Kharlamov <hi-angel <at> yandex.ru>
Cc: 41682 <at> debbugs.gnu.org
Subject: Re: bug#41682: makefile-gmake-mode does not trigger
 "eval-after-load"'s hooks
Date: Wed, 03 Jun 2020 11:21:10 +0100
tags 41682 + notabug
quit

Konstantin Kharlamov <hi-angel <at> yandex.ru> writes:

> Functions added with (eval-after-load 'makefile-gmake-mode …) do not
> trigger when the mode is enabled

I think you've misunderstood what eval-after-load does.

'makefile-gmake-mode' is a major mode function defined in the file
make-mode.el which provides the named feature 'make-mode'.  See
(info "(elisp) Named Features") and (info "(elisp) Hooks for Loading").

https://www.gnu.org/software/emacs/manual/html_node/elisp/Named-Features.html
https://www.gnu.org/software/emacs/manual/html_node/elisp/Hooks-for-Loading.html

eval-after-load, and its newer, preferred sibling with-eval-after-load,
register some Lisp to be run when a file or named feature is or has
already been loaded.

If you want to register some Lisp to run only once, after make-mode.el
is loaded (and makefile-gmake-mode has been defined), then you should
write:

  (with-eval-after-load 'make-mode
    (foo)
    (bar))

If you want to register some Lisp to run every time makefile-gmake-mode
is enabled, then you should write:

  (add-hook 'makefile-gmake-mode-hook #'foo)

If you want to register some Lisp to run every time any make-mode.el
major mode is enabled, then you should write:

  (add-hook 'makefile-mode-hook #'foo)

Is there some other case you're trying to address, or can this bug be
closed?

-- 
Basil




This bug report was last modified 5 years and 44 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.