0

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?

tian tong
  • 793
  • 3
  • 10
  • 21
  • 1
    Have you verified whether the mode is active, but may not be doing what you expect? `M-x describe-mode` to see what modes are active in the buffer. The Github readme.md webpage for the library at issue has some additional *Configuration* setup beyond just a major-mode-hook: https://github.com/Sarcasm/irony-mode – lawlist Aug 10 '15 at 18:19
  • If I use `M-x irony-mode`, it can work normally. I think it's because my minor can't be loaded. I have typed `(add-hook 'c-mode-hook 'fly-check-mode)`, but `flycheck` can't be loaded automatically in `C-mode`, also. – tian tong Aug 11 '15 at 00:18

1 Answers1

0

That should work fine, so you should recursively bisect your config to find the source of the problem.

Community
  • 1
  • 1
phils
  • 71,335
  • 11
  • 153
  • 198
  • It's a typo, sorry. I mean that I use either of two, I can't succeed. I use emacs 24.5. For your "1" and "2", I don't use `irony-mode`, It's a typo. – tian tong Aug 11 '15 at 01:02