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:
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With