I want irony-mode be turned on automatically in c-mode. But I have tried two ways, both fail. Can someone teach me? I don't like to type M-x irony-mode always.
1:
(require 'irony)
(defun my:irony-init ()
(irony-mode 1))
(add-hook 'c++-mode-hook 'my:irony-init)
(add-hook 'c-mode-hook 'my:irony-init)
OR 2:
(require 'irony)
(add-hook 'c++-mode-hook 'irony-mode)
(add-hook 'c-mode-hook 'irony-mode)
I find not only irony-mode, but also ggtags and flycheck can't load through add-hook. I have (add-hook 'c-mode-hook 'flycheck-mode), but it doesn't work. Can someone help me? My .emacs.d has uploaded to github:https://github.com/cfampc/emacs.d。 My irony-mode is configured in .emacs.d/custom/c-settings.el and flycheck ggtags is in .emacs.d//custom/edit-settings.el. Before I can have ggtags-mode auto-load in C. Now, If I add (add-hook 'c-mode-common-hook 'irony-mode) after (load ...) all of my config file, it does work. But if I add it in .emacs.d/custom/c-settings.el , It doesn't work. why?
That should work fine, so you should recursively bisect your config to find the source of the problem.