I have two tags tables that I would like to be searched/visited when I'm working on one of my R packages. I am able to set them globally with the following code in my .emacs config file:

(setq tags-table-list '("/R/Source/R-devel-SVN/TAGS" "/gitRepos/DADS/TAGS"))

But I cannot for the life of me figure out how to get the equivalent effect by directives placed in the project's .dir-locals.el. I've tried each the following (one at a time, of course), and many others, without success:

(nil (tags-table-list ("/R/Source/R-devel-SVN/" "/gitRepos/DADS/"))
((nil (tags-table-list ("/R/Source/R-devel-SVN/" "/gitRepos/DADS/")))
(nil (tags-table-list ("/R/Source/R-devel-SVN/TAGS" "/gitRepos/DADS/TAGS"))
(nil (tags-table-list '("/R/Source/R-devel-SVN/" "/gitRepos/DADS/"))
(nil (tags-table-list . ('("/R/Source/R-devel-SVN/" "/gitRepos/DADS/"))))
(nil . ((tags-table-list . (("/R/Source/R-devel-SVN/" "/gitRepos/DADS/")))))

Perhaps relevant is that setting the following variable does work as expected, which makes me suspect that I'm just missing the right incantation for setting tags-table-list -- not that the mechanism underlying .dir-locals.el is broken:

((nil (tags-file-name . "/gitRepos/DADS/TAGS")))

How can I set the value of tags-table-list using the notation required by .dir-locals.el?

1 Answer 1


All your attempts to set tags-table-list are errorneous.

All cases except the second one do not define a mapping of modes to alists of settings and are therefore wrong.

Only the second case remains to be discussed. In the following I add the missing closing parenthesis ):

((nil (tags-table-list ("/R/Source/R-devel-SVN/" "/gitRepos/DADS/"))))

Nevertheless, also this setting for tags-table-list is wrong. The elements of the alist mapping variables to values are cons, so it is better to write the setting using dotted-pair notation:

((nil (tags-table-list . (("/R/Source/R-devel-SVN/" "/gitRepos/DADS/")))))

This shows that you assign a list of a list to tags-table-list. But you should assign a list of directory names. One simple solution is adding a dot behind tags-table-list:

((nil (tags-table-list . ("/R/Source/R-devel-SVN/" "/gitRepos/DADS/"))))

I have just tested it with

emacs-version: GNU Emacs 26.2 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.22.30) of 2019-04-12

Contents of file ~/tmp/.dir-locals.el:

((nil (tags-table-list . ("~/tmp/DADS/"))))

Contents of file ~/tmp/DADS//TAGS:

int main(^?1,0

Contents of file ~/tmp/test/test.c:

int main() {
    return 0; /* \f$\sqrt{x^2+y^2}\f$. */

The command tags-search called with interactive argument main works like expected when the buffer for file ~/tmp/test/test.c is active and point is at the start of that file. It places point at the end of main in file ~/tmp/test/test.c.

  • Personally I would recommend using dotted-pair notation for the (MODE . ALIST) pairs as well.
    – phils
    Commented Aug 9, 2019 at 8:35
  • @phils Yes, you are perfectly right. But, I wanted to do a minimal edit indicating the OP his error. The first omitted dot did not induce the problem. So a discussion about that other dot is more a comment than an answer. I am actually happy that you addressed this topic in a comment;-).
    – Tobias
    Commented Aug 9, 2019 at 8:40
  • @phils By that do you mean that you would recommend (in my case) writing ((nil . ((tags-table-list . ("/R/Source/R-devel-SVN/" "/gitRepos/DADS/"))))) ? Commented Aug 9, 2019 at 15:16
  • @JoshO'Brien Yes, exactly so.
    – phils
    Commented Aug 10, 2019 at 6:18
  • Thanks, Tobias, for your answer. Really appreciate your taking the time to explain it as well. Commented Aug 12, 2019 at 22:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.