Is there any plugin for emacs to automatically update the TAGS file in my C project (for example on buffer save or access) or create a new one if there is no TAGS file present?
I am running on Windows (without Cygwin), so all the fancy shell scripting does not help. I was hoping for a native emacs solution not using any external scripting.
I already tried build-tags.el and etags-table.el but none of these really worked (the way I wanted).
Any other ideas?
-
Why not add an execution of ctags to your build script? You really only need a new tags file when you compile (at the most). I tend to just write a scheduled task to build the tags file every night. Seems to work pretty well.
cschol : I want the TAGS file updated as soon as new symbols are introduced in the source. I extensively use TAGS browsing capabilities when developing to jump from file to file. Once a night is not often enough. Personal build script mods are not possible in our multi developer environment.Steve Rowe : How do you build your code? Wrap that command with a script that does the build, then runs the ctags command.jrockway : I disagree -- you want tags immediately after editing the buffer.cschol : @Steve Rowe: Yeah, I could probably script something together. But I dont like it. @jrockway: I agree. I NEED it immediately and not necessarily want to build every time. -
I use combination of semantic + gnu global for my day-to-day work. GNU Global's databases are updated once per day, while semantic use them for basic navigation, and re-parse changed files on the fly.
You can find more about these packages in my article about Cedet
-
Here is how I generate a TAGS file for a C project:
- M-x cd ( to the root of your project )
- M-x compile
- find . -name "*.[chCH]" -print | etags -
That will create a TAGS file in the current directory for all sub directories and files.
Here is a emacs function that does the exact same thing:
(defun compile-tags () "compile etags for the current project" (interactive) (cd "YOUR_DIRECTORY") (compile "find . -name \"*.[chCH]\" -print | etags -"))NOTE: if you are on windows you'll need to install cygwin and make sure
c:\cygwin\binis in your path so that you getfindin your path. Also make sure the emacs bin directory is in your path so that you can getetagsas well.justinhj : You can also use the native windows version of gnu utils including find and so on. I find them faster than cygwin. http://gnuwin32.sourceforge.net/ -
This might get you close (untested):
(defvar my-auto-update-tags-alist (list '("/some/path/to/TAGS" "command_to_build_tags") '("/another/path/to/TAGS" "another_build_command"))) (defun my-auto-update-tags () "Automatically update TAGS files" (tags-table-check-computed-list) (let ((filename (buffer-file-name)) build-cmd) (mapc (lambda (tag-file) (set-buffer tag-file) (when (member filename (tags-table-files)) (setq build-cmd (cdr (assoc tag-file my-auto-update-tags-alist))) (when build-cmd (call-process build-cmd nil 0)))) tags-table-computed-list))) (add-hook 'after-save-hook 'my-auto-update-tags)It will only work (did I mention it's untested?) on files that are in TAGS files already. If you add a new file you'd have to regenerate the TAGS file the first time yourself. The call-process part should work asynchronously, so it might be a few moments until the TAGS file is actually rebuilt (if this even works ;)
Török Gábor : Would you make an effort to test it? -
etags-update may help in your case. I didn't test it but as of the readme:
etags-update.el is a Emacs global minor mode that updates your TAGS when saving a file.I found it from the emacswiki on this page: http://www.emacswiki.org/emacs/BuildTags
0 comments:
Post a Comment