Emacs: How can I find a file in my project quickly?

假如想象 提交于 2020-02-02 14:14:12

问题


Now, I'm using ede to manage my cpp project, and I try to find a file in my project quickly, but I failed. I used ede-find-file to find "db.h", it sits in "d:/projects/leveldb/include/db.h", unfortunately, it said cannot find.

My config is put below

(setq leveldb_root "d:/projects/leveldb/")

(ede-cpp-root-project
  "leveldb"
  :file (concat leveldb_root ".gitignore")
  :system-include-path '("C:/Program Files/Microsoft SDKs/Windows/v7.1/Include"
                       "C:/Program Files (x86)/Microsoft Visual Studio 9.0/VC/include")
  :include-path '("/"
                "/include"))

And, is there any suggestion for project management and file find solution? (I also tried find-file-in-project).

I use ede because I need the ede-cpp-root-project to automatically set semanticdb.


回答1:


Have a look at projectile. Projectile is a project interaction library for Emacs. Its goal is to provide a nice set of features operating on a project level without introducing external dependencies. For instance - finding project files is done in pure elisp without the use of GNU find.

This library provides easy project management and navigation. The concept of a project is pretty basic - just a folder containing special file. Currently git, mercurial and bazaar repos are considered projects by default. If you want to mark a folder manually as a project just create an empty .projectile file in it.




回答2:


One of the solutions that I use for my C/C++ projects is using GNU Global. You can use gtags module with Emacs, which is superior than the built-in tag system. Once you have GNU Global installed, and Emacs gtags configured, you can run gtags from the top level of your source tree to generate the tags. Now, if you run the M-x gtags-find-file to open a file that was indexed by Global. For usability, you can bind this command with a keystroke that is convenient for you.




回答3:


For the original ede project types, such as the ones that generate or read Automake files, EDE knows all the files and where they are if they are being compiled into your program.

For ede-cpp-root, it has no list of files to use, so it will only really search in the current directory or include path. The include path is key since it is needed for smart completion.

If you would like to use ede-find-file for general file discovery, you can integrate in an external tool such as GNU Global, or idutils as a backend database for both files. You could also enable the use of your system's locate command.

Customize ede-locate-setup-options to include whichever tool you would like to use, and then it should work as desired.




回答4:


Well, I don't really know how to solve your particular problem, but I can try to remedy it. If you install the ido package (http://www.emacswiki.org/emacs/InteractivelyDoThings), you can usually find files quickly that way. It's a find-file solution for everything in my opinion.




回答5:


Or you can try xcscope.el, it is blazingly fast to find the files you want(+more) provided you have setup your cscope database properly.




回答6:


The one more alternative is gpicker. It's actually an external tool, but there's an integration plugin for emacs. It provides fuzzy search for project files regarding its relative paths and makes it pretty fast. I'm using it for about three years and strongly recommend trying gpicker other emacs users.



来源:https://stackoverflow.com/questions/9656096/emacs-how-can-i-find-a-file-in-my-project-quickly

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!