如何用emacs以编程方式创建/更新TAGS文件? [英] How to programmatically create/update a TAGS file with emacs?

查看:243
本文介绍了如何用emacs以编程方式创建/更新TAGS文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有任何插件可以自动更新C项目中的TAGS文件(例如缓冲区保存或访问),或者如果没有TAGS文件,请创建一个新的?



我在Windows上运行(没有Cygwin),所以所有的花哨的shell脚本都没有帮助。我希望可以使用不使用任何外部脚本的本机emacs解决方案。



我已经尝试过 build-tags.el etags-table.el ,但没有一个真的有效(我想要的方式)。



任何其他想法? / p>

解决方案

以下是为C项目生成TAGS文件的方法:



<
  • Mx cd YOUR_DIRECTORY

  • Mx编译

  • find。 -name*。[chCH]-print | etags -

  • 这将为当前目录中的所有子目录和文件创建一个TAGS文件。



    这是一个完全相同的功能的emacs函数:

     (defun compile-tags() 
    为当前项目编译
    (interactive)
    (cdYOUR_DIRECTORY)
    (编译find。-name \*。[chCH] \ -print | etags - ))

    注意:如果你在Windows上,安装cygwin,并确保 c:\cygwin\bin 在您的路径,以便您得到找到在您的路径。还要确保emacs bin目录在您的路径中,以便您也可以获得 etags


    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?

    解决方案

    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.

    这篇关于如何用emacs以编程方式创建/更新TAGS文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆