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?
Seems like
php-mode
inherits fromc-mode
, which I think means it will runc-mode-hook
. If you look at cc-mode.el, other C-like modes inherit fromprog-mode
instead of directly fromc-mode
, which is probably the Right Thing. You should probably submit a bug tophp-mode
.To fix it in the meantime, just wrap your code in a test for
c-mode