2

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.

N.N.
  • 8,336
  • 12
  • 54
  • 94
jiluo
  • 2,296
  • 3
  • 21
  • 34
  • [see this question](http://stackoverflow.com/questions/9396967/emacs-what-are-good-tactics-for-navigating-directories-and-opening-files) for some general tips for effective file finding – Tom Mar 11 '12 at 16:33
  • check out [the answer for this question](http://stackoverflow.com/questions/7970537/emacs-find-file-in-project-on-a-big-project/) too. – Tom Mar 12 '12 at 07:46

6 Answers6

13

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.

Bozhidar Batsov
  • 55,802
  • 13
  • 100
  • 117
  • 1
    @Bozhidar have you tried anything completion package? I find it weird how so many people are so enchanted by ido. Yep. *Enchanted* is the best word I can think of for it. Now that I'm used to anything. I just tried your `projectile` project, and ido is basically unusable for large lists (i.e. 3k files in my project). – event_jr Mar 12 '12 at 13:12
  • Yes, I have. I do find ido to be less intrusive, though, and with flex matching enabled it's very easy to sift though many options presented by ido. – Bozhidar Batsov Mar 12 '12 at 14:13
  • I agree with @event_jr, projectile is slow for large project, so I will try event_jr's solution – jiluo Mar 12 '12 at 14:38
  • 1
    @BozhidarBatsov I enjoy your blog, and would love to carry on this correspondence in e-mail. re #intrusive, that's just not true. It does open a window, but cleans up after itself very well, and you can use as much or as little of the functionality as you like. The thing with long lists of long strings is that the extra window actually is really helpful. – event_jr Mar 12 '12 at 14:50
  • @MartinLuo [my project](https://github.com/lewang/anything-project-files) does have external dependencies on Unix tools, namely `find` and `ruby if you use the included script. Cygwin will work fine. – event_jr Mar 12 '12 at 14:56
  • @event_jr, yes, I found these things. But I've encountered some strange problem with cygwin bash. – jiluo Mar 12 '12 at 15:16
  • @MartinLuo, while the initial indexing of a large project is certainly slower in projectile than in something using an external tool such as find, this is largely compensated by caching the results of the indexing. – Bozhidar Batsov Mar 12 '12 at 15:20
  • @event_jr, feel free to take the discussion of `anything` to e-mail. I do love a good discussion. :-) – Bozhidar Batsov Mar 12 '12 at 15:21
  • @BozhidarBatsov, I do think that projectile is a wonderful package, and it is the fastest "find file in project" kind package I used util now. I dont want to use any package that relies on tools outside the emacs itself, such as "find" and "ruby". But I have to find something faster than pure elisp tools. So I will try event_jr's solution. – jiluo Mar 12 '12 at 15:50
4

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.

Praveen Kumar
  • 1,280
  • 1
  • 8
  • 14
  • I want something integrated with emacs, not the software outside emacs. So I don't prefer to something like "find" or "gtags". Anyway, thank you! If I can't find any solution, I will try gtags – jiluo Mar 12 '12 at 05:50
  • Marmalde link seems down *(also per Emacs Wiki Marmalade seems to be down since 2021 year)*. I think the new link is supposed to be this https://melpa.org/#/global-tags – Hi-Angel Jan 20 '23 at 06:12
  • Given gtags is just one of many implementations for the TAGS file formats, I recommend [using instead `universal ctags`](https://github.com/universal-ctags/ctags). As of writing this comment latest version in my distro `5.9.20220828` claims to support *(`--list-languages`)* 146 programming languages, which is faaar more than gtags does. – Hi-Angel Jan 20 '23 at 06:19
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.

Eric
  • 3,959
  • 17
  • 15
  • @Eric - Thanks! Your advice helped me get basic file finding up and running on a large project. Any chance I can tempt you into having a look at a follow-up question I've posted here?: [Quickly finding project files using emacs EDE](http://stackoverflow.com/questions/23950534/quickly-finding-project-files-using-emacs-ede) – Rob May 30 '14 at 08:53
2

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.

emish
  • 2,813
  • 5
  • 28
  • 34
  • 2
    I want something like sublime text 2 "Goto file" function, that means I could find some file by just type several characters, no matter the file is in current dir or subdirs. Ido can only show files in current dir. Or is there some way to configure it so that Ido can give me suggestion for files in subdirs? – jiluo Mar 12 '12 at 05:43
  • [For anything.el](http://metasandwich.wordpress.com/2010/07/30/what-can-i-get-for-10-dolla-anything-el/) someone created [project file support](http://metasandwich.com/2010/08/10/anything-project-files-el/). You may want to check it out. – Tom Mar 12 '12 at 07:41
  • 1
    @MartinLuo I'm glad you found something useful, but I can tell you anything is heads and shoulders better than ido which is what `projectile` uses. @Tom hmmm I was completely unaware of that the project support for anything you linked to. In fact, I made my own command-T replacement for anything [here](https://github.com/lewang/anything-project-files). The idea is identical, but mine is a little more sophisticated. – event_jr Mar 12 '12 at 13:24
  • Great job! @event_jr. Are u Chinese? – jiluo Mar 12 '12 at 14:31
  • @MartinLuo ido will let you find files in other directories, but I have not figured out why this works only sometimes. I think it's for files you open frequently, and I'm sure it can be configured. For instance, when I type .emacs.d in ido from any other directory on the system, it takes me to ~/.emacs.d/ without fail. – emish Mar 29 '12 at 18:17
0

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.

user994572
  • 139
  • 1
  • 11
0

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.