Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Remove run-hook, it is run automatically.
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.
  • Loading branch information
Fuco1 authored May 24, 2017
commit 47aaf2c9a0beb0a530430b9c12ec148af6a2bd88
3 changes: 1 addition & 2 deletions nginx-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,7 @@ The variable nginx-indent-level controls the amount of indentation.
(set (make-local-variable 'paragraph-separate) "\\([ \f]*\\|#\\)$")

(set (make-local-variable 'font-lock-defaults)
'(nginx-font-lock-keywords nil))
(run-hooks 'nginx-mode-hook))
'(nginx-font-lock-keywords nil)))

;;;###autoload
(add-to-list 'auto-mode-alist '("nginx\\.conf\\'" . nginx-mode))
Expand Down