leoliu / ggtags

Emacs frontend to GNU Global source code tagging system.
http://elpa.gnu.org
577 stars 56 forks source link

auto enable ggtags #197

Closed yanglimingcn closed 4 years ago

yanglimingcn commented 4 years ago

.dir-locals ((nil (ggtags-process-environment "GTAGSFORCECPP=" "GTAGSLABEL=gtags")) (nil (ggtags-mode t))) ;;;;;;;;;;;;;;;; when open this directory, ggtags-mode is enabled, but mode-line can not see the project name. ggtags-mode-line-project-name is enabled

leoliu commented 4 years ago

I think it is because you are only setting variable ggtags-mode to t and not actually activating the ggtags minor-mode. Normally you should activate this way:

(add-hook 'c-mode-common-hook
          (lambda ()
            (when (derived-mode-p 'c-mode 'c++-mode 'java-mode)
              (ggtags-mode 1))))

Change c-mode-common-hook to other major mode hook if not c,c++,java.

yanglimingcn commented 4 years ago

In this case, I just jump to the project root, not open one file of the project. so no language mode will be enabled. BTW when open this directory, ggtags-mode is enabled, but mode-line can not see the project name. but in minor mode set I can see GG image

leoliu commented 4 years ago

Because you are setting var ggtags-mode in your dir-locals which doesn’t do what you want. you need to activate minor mode this way instead: M-: (ggtags-mode t) RET

yanglimingcn commented 4 years ago

OK,thanks