开发者

Tags in emacs with a large codebase

I was wondering how people use tags in emacs when working on a large codebase (approx. 50000 cpp|.h|.cs files). Some of my colleagues use indexing tools (names escape me) which return all the results over the codebase in seconds. I can't seem to get anywhere near that sort of performance on emacs and tags, but it's essentially the same thing!

Some approaches I've tried:

  1. Create one TAGS file for the whole repository. This is usually quite large and generally awkward to use (sometimes too many tags match).
  2. Create seperate TAGS files for cpp|h|cs. A bit more focused if I know (roughly (at least the programming language that will have been used)) what I happen to be looking for.
  3. Smaller tags files on a section of the repository. These are great when I'm pretty sure of the area but the management overhead is a pain. I'll usually开发者_如何学运维 generate these as and when needed.

Any suggestions \ examples of your workflow is appreciated.


Here is a script I use:

#!/usr/bin/bash
echo "Creating list of files to build tags..."
find `pwd` -name '*.c' -o -name '*.h' > cscope_files

echo "Building cscope and ctags databases..."
cscope -bqki cscope_files
ctags -eL cscope_files

> cat cscope_files | wc -l
10700

For 10700 files which is comparable to your project, jumps between tags are instantaneous. As you'd notice this builds both cscope and etags databases. I start this script at the top of the tree. Also if this is of any help, these are the keybindings in my .emacs.el file.

(defun hide-cscope-buffer ()
  "Turn off the display of cscope buffer"
   (interactive)
   (if (not cscope-display-cscope-buffer)
       (progn
         (set-variable 'cscope-display-cscope-buffer t)
         (message "Turning ON display of cscope results buffer."))
     (set-variable 'cscope-display-cscope-buffer nil)
     (message "Toggling OFF display of cscope results buffer.")))


(global-set-key [f9] 'cscope-find-this-symbol)
(global-set-key [f10] 'cscope-find-global-definition-no-prompting)
(global-set-key [f11] 'cscope-find-functions-calling-this-function)
(global-set-key [f12] 'cscope-find-this-file)
(global-set-key (kbd "C-t") 'cscope-pop-mark)
(global-set-key (kbd "C-n") 'cscope-next-symbol)
(global-set-key (kbd "C-p") 'cscope-prev-symbol)
(global-set-key (kbd "C-b") 'hide-cscope-buffer)
(global-set-key [S-f7] 'cscope-next-file)
(global-set-key [S-f8] 'cscope-prev-file)
(global-set-key [S-f9] 'cscope-find-this-text-string)
(global-set-key [S-f10] 'cscope-find-global-definition)
(global-set-key [S-f11] 'cscope-find-egrep-pattern)                                                                                                                           
(global-set-key [S-f12] 'cscope-find-files-including-file)

I am not a regular emacs user though. These were used by me when I was trying to switch to emacs, but then reverted to vim, where I found ways to do all the things that I was happy doing in emacs.

Update: For multiple tags files in a directory hierarchy, take a look at the Multiple tags files section of this article.


I wrote some packages to help with managing multiple tag hits and many TAGS files:

http://www.emacswiki.org/emacs/EtagsSelect

http://www.emacswiki.org/emacs/EtagsTable


You might want to have a look at GNU Global as well. It supports C and C++ (along with Yacc, Java, PHP4 and assembly), so it might work acceptably well for C# (I've not written any C#, though, so I might also be talking utter nonsense).

If it works, it ought to be dramatically faster than a regular TAGS file.


As mentioned, GNU Global is pretty good. Here's a short introduction for using it from within emacs.

Note, if your project is really 50K files (and 50K locs), the first run (to index all that stuff) could be a bit slow.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜