Skip to content

Conversation

@Fuco1
Copy link
Contributor

@Fuco1 Fuco1 commented May 24, 2017

Hi.

When using define-derived-mode one doesn't need (and shouldn't) use run-hook because the macro adds the form run-mode-hook itself when expanded (use macroexpand to check!).

This results in the hook being called twice, see

(defun my-nginx-mode-init ()
  (message "Hello"))
(add-hook 'nginx-mode-hook 'my-nginx-mode-init)

In messages I have

Hello [2 times]

Simply removing the form and using the one provided by the macro is enough to fix this.

Hi.

When using `define-derived-mode` one doesn't need (and shouldn't) use `run-hook` because the macro adds the form `run-mode-hook` itself when expanded (use macroexpand to check!).

This results in the hook being called twice, see

```elisp
(defun my-nginx-mode-init ()
  (message "Hello"))
(add-hook 'nginx-mode-hook 'my-nginx-mode-init)
```

In messages I have

    Hello [2 times]

Simply removing the form and using the one provided by the macro is enough to fix this.
@ajc ajc merged commit c37ae5f into ajc:master May 25, 2017
@Fuco1 Fuco1 deleted the patch-1 branch May 25, 2017 09:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants