Reputation: 23
I created a hook function to activate irony-mode when working with c files. However, when I open a php file, these hook is also executed.
Here is the code:
(defun my-company-irony ()
(irony-mode)
(unless (memq 'company-irony company-backends)
(setq-local company-backends (cons 'company-irony company-backends))))
(add-hook 'c-mode-hook #'my-company-irony)
Does anybody knows how to stop executing this hook on php files?
Upvotes: 1
Views: 112
Reputation: 9417
Seems like php-mode
inherits from c-mode
, which I think means it will run c-mode-hook
. If you look at cc-mode.el, other C-like modes inherit from prog-mode
instead of directly from c-mode
, which is probably the Right Thing. You should probably submit a bug to php-mode
.
To fix it in the meantime, just wrap your code in a test for c-mode
(defun my-company-irony ()
(when (eq major-mode 'c-mode)
(irony-mode)
(unless (memq 'company-irony company-backends)
(setq-local company-backends (cons 'company-irony company-backends)))))
Upvotes: 1