2

I run Emacs locally on my Windows machine, but edit everything remotely, via tramp & plink (PuTTY's implementation of ssh). This all works just fine, but, as I found out today, TAGS files for large projects do not work. It's not that these files are that large - 12 Mb, in my case, a few thousand .cpp files, but still.

 

If I load TAGS file with visit-tags-table remotely, with /plink:user@host:/home/user/project/TAGS path, my Emacs just hangs forever, eating 100% of one of the CPU cores. It does not happen for smaller files, these work just fine, but for larger ones in happened every time I tried.

If I load it remotely, but with pscp, /pscp:user@host:/home/user/project/TAGS, it just does not load, tags-apropos shows no tags loaded.

If I copy the TAGS file to my local machine, visit-tags-table load tags just fine, but when I use them, Emacs expects the files mentioned there to be where the TAGS file is, i.e. on my local machine. If I generate TAGS with relative paths, it would try to open c:/emacs/home/path/file.h, if I use --tag-relative=no when generating TAGS to obtain absolute paths, the path changes to c:/home/user/project/path/file.h.

 

Of these three fails the last one looks the most 'fixable' (for the first two I suspect some shady network configuration issues), but I have yet to find how to make a local TAGS file work for remote projects.

Dirty hacks like changing all paths in TAGS with sed from /home/... to /plink:user@host:/home/... don't work, I tried (Emacs just tries to open c:/plink!user@host!/home/... file in this case).

In this question someone offered rewriting a etags-file-of-tag function from etags.el - this looks promising, but that does not work for me either (either this is a wrong function, or I'm doing something very wrong: no matter how I change that one, it doesn't seem to affect anything). Unfortunately, I have a quite limited understanding of elisp and how Emacs works in general, so I am stuck at the moment.

 

I really want TAGS to work for this project, so any ideas or advice will be appreciated.

  • Experiment: visit-tags-table your copied-locally TAGS file (generated with relative paths). Now switch to the TAGS buffer and use M-x eval-expression -- key binding M-: -- and type (setq default-directory "/plink:user@host:/home/user/project/") and then see whether you can find tags successfully? – phils Oct 12 '16 at 5:26
1

create multiple smaller TAGS in sub-directory instead of one big TAGS in root directory,

insert below code into ~/.emacs,

(setq tags-table-list "~/proj/sub-dir1/TAGS" "~/proj/sub-dir2/TAGS")

That's all you need to do.

BTW, I don't like visit-tags-table which basically just (setq tags-file-name "~/proj/TAGS"). To use tags-table-list, tags-file-name should be nil.

  • ...I will probably do this, but only if nothing else works. To follow this path, I will have to maintain these multiple TAGS files all over the source tree, to add new ones if new subdirs appear, to import the list to emacs somehow, and to pray that no single folder with no subdirs ever appears which has enough code to generate TAGS file big enough to break all that again. This is all possible and scriptable, but looks... wrong. – Artyom V. Kireev Jul 14 '16 at 0:17
  • check my plugin find-and-ctags. – chen bin Jul 14 '16 at 0:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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