使用 Emacs 进行大型项目

发布于 2024-08-27 03:12:34 字数 326 浏览 4 评论 0原文

也许这是一个经常重复的问题,但我在搜索中找不到类似的内容。 重点是,我喜欢在我的个人项目中使用 Emacs,通常是使用 C 或 python 的非常小的应用程序,但我想知道如何在我的工作中使用它,其中我们有大约 10k 源代码文件的项目,所以非常大(实际上我正在使用源洞察,这是非常好的工具,但仅适用于 Windows),问题是:

  • 搜索:在整个项目中搜索字符串的最方便的方法是什么?
  • 浏览函数:我的意思是像将光标放在函数、定义、var 上,然后转到定义
  • 重构

此外,如果您有这方面的经验并想分享您的想法,我会认为它非常有趣。

Maybe is a often repeated question here, but i can't find anything similar with the search.
The point is that i like to use Emacs for my personal projects, usually very small applications using C or python, but i was wondering how to use it also for my work, in which we have project with about 10k files of source code, so is veeeery big (actually i am using source insight, that is very nice tool, but only for windows), questions are:

  • Searching: Which is the most convenient way to search a string within the whole project?
  • Navigating throught the function: I mean something like putting the cursor over a function, define, var, and going to the definition
  • Refactoring

Also if you have any experience with this and want to share your thoughts i will consider it highly interesting.

Br

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(8

幽梦紫曦~ 2024-09-03 03:12:35

浏览 C 源文件的“传统”方法是使用“etags”创建一个名为 TAGS 的文件,然后使用 ALT-。跨文件转到函数。

为了在文件中搜索字符串,我通常使用“grep”。如果您厌倦了每次都输入它们,您可以使用您想要搜索的所有目录或其他内容制作一个 shell 脚本。

The "traditional" way of navigating C source files is to use "etags" to make a file called TAGS, then use ALT-. to go to functions across files.

For searching for strings in files, I usually use "grep". You could make a shell script with all the directories you want to search or something if you get tired of typing them in each time.

最美不过初阳 2024-09-03 03:12:35

我的项目通常位于 git 中,因此我将其放在一起以快速搜索它们:

;; There's something similar (but fancier) in vc-git.el: vc-git-grep
;; -I means don't search through binary files
(defcustom git-grep-switches "--extended-regexp -I -n --ignore-case"
  "Switches to pass to `git grep'."
  :type 'string)

(defun git-grep (command-args)
  (interactive
   (list (read-shell-command "Run git-grep (like this): "
                             (format "git grep %s -e "
                                     git-grep-switches)
                             'git-grep-history)))
  (let ((grep-use-null-device nil))
    (grep command-args)))

My projects typically live in git, so I put this together to quickly search them:

;; There's something similar (but fancier) in vc-git.el: vc-git-grep
;; -I means don't search through binary files
(defcustom git-grep-switches "--extended-regexp -I -n --ignore-case"
  "Switches to pass to `git grep'."
  :type 'string)

(defun git-grep (command-args)
  (interactive
   (list (read-shell-command "Run git-grep (like this): "
                             (format "git grep %s -e "
                                     git-grep-switches)
                             'git-grep-history)))
  (let ((grep-use-null-device nil))
    (grep command-args)))
第七度阳光i 2024-09-03 03:12:35

还有 Emacs 代码浏览器。它使探索项目变得更加简单。请参阅此处此处了解更多信息。

There is also the Emacs Code Browser. It makes exploring projects a lot simpler. See here and here for more information.

晨光如昨 2024-09-03 03:12:35

关于整个项目中的搜索,我发现 rgrep 命令非常有用。

此外,imenu 可以非常方便地跳转到同一文件中的函数定义。

这些是我的2p。

Regarding searches in the whole project, I find extremely useful the rgrep command.

Also, imenu is quite handy to jump to a function definition in the same file.

These are my 2p.

一紙繁鸢 2024-09-03 03:12:35

期待来自 CEDET 的 EDE - 它为项目提供基础支持......

look to EDE from CEDET - it provide base support for projects...

心在旅行 2024-09-03 03:12:35

欧洲央行对我来说太重量级了。我使用 xcscope 取得了很好的结果。不用说,它对 Python 没有太大帮助。

http://www.emacswiki.org/emacs/CScopeAndEmacs

ECB is too heavyweight for my taste. I have had good results with xcscope. Needless to say it doesn't help too much with Python.

http://www.emacswiki.org/emacs/CScopeAndEmacs

此岸叶落 2024-09-03 03:12:35

除了像其他人提到的那样使用标签之外,我还发现 igrep 和 igrep-find 非常有用。还有 Emacs 内置的 grep< /code>grep-find,但我发现它们的界面更笨拙。

我的标准搜索是:

M-x igrep-find some_regexp RET ~/work_area/*.cxx

它将查找 ~/work/area 下的所有 *.cxx 文件,并显示与 some_regexp 匹配的结果。与所有搜索实用程序一样,它会填充一个类似编译的缓冲区,您可以使用 Cx ` (又名 Mx next-error)进行导航。

In addition to using TAGS as others have mentioned, I find igrep and igrep-find very useful. There is also Emacs' built in grep and grep-find, but I find their interface more clumsy.

My standard search is:

M-x igrep-find some_regexp RET ~/work_area/*.cxx

Which will look for all *.cxx files under ~/work/area, and show results matching some_regexp. Like all the search utilities, it populates a compilation-like buffer you can navigate using C-x ` (aka M-x next-error).

青春有你 2024-09-03 03:12:35

Icicles 可以通过多种方式提供帮助项目。同样, Bookmark+ 甚至 Dired+

这些库可以帮助您创建、组织和管理项目,无论项目的文件和目录位于何处。它们可以帮助您以各种方式导航和搜索。

有些功能是独一无二的——与其他方法截然不同。我可以在这里列出一些项目支持,但这是开始的最佳位置。

There are many ways that Icicles can help with projects. Likewise, Bookmark+ and even Dired+.

These libraries can help you create, organize, and manage projects, wherever their files and directories might reside. And they can help you navigate and search in various ways.

Some of the features are unique -- quite different from other approaches. I could list some of the project support here, but this is the best place to start.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文