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?
Install find-and-ctags (https://github.com/redguardtoo/find-and-ctags), then insert below code into ~/.emacs,
(defun my-setup-develop-environment ()
(interactive)
;; you can use `find-and-ctags-current-full-filename-match-pattern-p' instead
(when (find-and-ctags-current-path-match-pattern-p "/MYPROJ")
(setq-local tags-table-list
(list (find-and-ctags-run-ctags-if-needed "~/workspace/MYPROJ" ; project directory
'(("-not -size +64k" "--exclude=*.min.js") ; (find-opts ctags-opts)
;; you may add more find-opts ctags-opts pair HERE to run find&ctags again to APPEND to same TAGS file
;; ctags-opts must contain "-a" to append
;; (find-opts "-a")
)))))
;; for other projects
;; insert NEW `when' statements here
)
(add-hook 'prog-mode-hook 'my-setup-develop-environment) ; prog-mode require emacs24+
(add-hook 'lua-mode-hook 'my-setup-develop-environment) ; lua-mode does NOT inherit from prog-mode
;; OPTIONAL
(add-hook 'after-save-hook 'find-and-ctags-auto-update-tags)
It works on windows, all you need is replace "~/workspace/MYPROJ" with "C:/workspace/MYPROJ". CTags executable could be any version, because produced TAGS contains only relative path.