Using jtags-mode (version 0.96) via ELPA in a development version of Emacs 24+, I cannot seem to enable the minor mode programmatically (manual invocation works fine). Before I drill into the gory details with what I have tried and the setup that I expect to work, the bottom line is that, after adding jtags-mode to the Java hook variable, I get the following complaint from Emacs when I first vist a Java source file:
Toggling jtags-mode off; better pass an explicit argument. [2 times]
After thoroughly reading the documentation on jtags-mode setup, I expected the following to suffice:
;; Support for Java coding.
(autoload 'jtags-mode "jtags" "Toggle jtags mode." 1)
(defun java-setup ()
(setq tab-stop-list '(4 8 12 16 20 24 28 32 36 40 44 48 52 56 60 64 68 72 76 80 84 88 92)
indent-tabs-mode nil
tab-width 4
fill-column 96
c-comment-start-regexp "\\(@\\|/\\(/\\|[*][*]?\\)\\)"
jtags-display-menu-flag t
jtags-mode 1)
(java-mode-indent-annotations-setup))
(add-hook 'java-mode-hook 'java-setup)
(add-hook 'java-mode-hook 'jtags-mode)
...
But this led to the complaint above. I have since tried to invoke jtags-mode directly in the java-setup() function, to no avail.
I would gladly take pointers on how to debug this issue if there is no obvious or easy solution.
Functions named
xxx-modeare often toggle functions when called without arguments, i.e. they turn the mode on if it was off and vice versa. As you have added this function to a hook, this is how it is called. Several minor modes provide a function liketurn-on-xxx-modethat are designed to be added to hook directly.When called with an argument, 1 typically activates them and -1 deactivates. Try calling it from your setup function rather than adding the
jtags-modefunction to the hookI would suggest activating the minor mode from your setup function. Also, in your setup code, you set the
jtags-modevariable to 1, which normall is not the right thing to do. For example:Finally, a reservation. I haven’t used
jtags-mode, this answer is based on general knowledge on how minor modes work.