1

I am relatively new to emacs and using emacs version 21.3.1 and trying out the ctags for emacs (mainly to jump to definitions).

I am working with a big solution with lots of projects. Problem is that whenever I am trying to jump to tags under a cursor using command M-. , it tries to find a tags table from current directory of the source file.

My TAGS file is located at the root of my solution. So I have to point to it using M-x visit-tags-table [path to my tag file].

Is there a way to set this when I start up emacs so I do not have to point to it every time?

4
  • Do you mean even after telling Emacs where the TAGS file is, it keeps asking for its location?
    – choroba
    Jan 16, 2013 at 15:33
  • Once I specify it, it doesn't ask anymore. I just want this to be done on startup.
    – joonho
    Jan 16, 2013 at 15:42
  • Nevermind, I was able to set it in my .emacs file by adding (setq tags-table-list '("[path to my tag file]"))
    – joonho
    Jan 16, 2013 at 15:45
  • Are you using emacsclient? Do not open a new emacs for each file to be edited.
    – choroba
    Jan 16, 2013 at 15:55

2 Answers 2

4

It seems like the variable tags-file-name is the one you want to set.

One way would be to set it in your .emacs, something like:

(setq tags-file-name "path/to/file")

I wouldn't do it, as it will fix the tags table globally, and in case you'd like to use a different table (say for a different project) this won't work.

It seems that you could use the so called local variables and set this one per file. Do C-h v tags-file-name RET to see some more info.

1
  • Your method worked too. However I have decided not to set the tags on start-up for the exact reason you mentioned. Thanks.
    – joonho
    Jan 23, 2013 at 21:42
0

Here is the recipe that ensures that you will always have an uptodate tag file loaded automagically whenever and wherever you start emacs.

  1. Make an emacs_startup.bash file in your project directory that contains this:

    find . -name "*.yourCodeFileExtensionHere" -print | etags -
    cp TAGS ~/CurrentTagsCopy
    emacs 
    
  2. chmod u+x emacs_startup.bash

  3. In your main emacs configuration file, add this line:

    (setq tags-file-name "~/CurrentTagsCopy")
    
  4. To start work, cd to your project directory and do ./emacs_startup.bash.

1
  • It sounds like this will create a quite long startup time for emacs. Feb 28, 2019 at 10:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .