How to programmatically create/update a TAGS file with emacs?

后端 未结 7 1171
我在风中等你
我在风中等你 2021-01-31 11:20

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?

7条回答
  •  轮回少年
    2021-01-31 11:23

    Here is how I generate a TAGS file for a C project:

    1. M-x cd YOUR_DIRECTORY
    2. M-x compile
    3. 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\bin is in your path so that you get find in your path. Also make sure the emacs bin directory is in your path so that you can get etags as well.

提交回复
热议问题