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?
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 ;)