问题
I've recently started using EDE (via CEDET via ECB) in an attempt to get Emacs set up as a reasonable IDE for development on a largish C/C++/Python project.
Something that was a bit fiddly to get set up (as I'm an Emacs and Lisp novice) was rapid file finding. The solution I currently have is to set up a raw/blank project (one EDE doesn't need to know how to manage makefiles or builds for) like so in my .emacs
file:
;; Enable EDE mode
(global-ede-mode 1)
;; EDE knows nothing of my project type, so use CSCope to inform it of the project
;; and its files
(setq ede-locate-setup-options
'(ede-locate-cscope
ede-locate-base))
;; This is probably a dubious shortcut allocation,
;; but it's what I'm using at the mo.
(global-set-key (kbd "C-f") 'ede-find-file)
;; Set up the project for EDE
(ede-cpp-root-project "LargeApp" :file "/workspace/me/LargeApp/SConstruct")
M-x ede-find-file
used to not work at all, because EDE didn't know anything of the files in the project directory and sub-directories. Setting up the files in an EDE project would have taken ages (10000+ files), but luckily EDE understands CSCope output, so it was a matter of doing this in my project root directory using a little bash script (based on information linked from the main CScope project page):
#! /usr/bin/env bash
cd /workspace/me/LargeApp
find /workspace/me/LargeApp \
-type d -name '.git*' -prune -o \
-type d -name '.svn*' -prune -o \
-type d -name 'build' -prune -o \
-type d -name 'bin' -prune -o \
-type d -name 'lib' -prune -o \
-name '*.h' -print -o \
-name '*.hpp' -print -o \
-name '*.c' -print -o \
-name '*.cpp' -print -o \
-name '*.cc' -print -o \
-name '*.py' -print -o \
-name '*.lua' -print -o \
-name '*.xml' -print >./cscope.files
cscope -b -q -k
EDE then picks up the cscope.out
in the project root folder, and kazam!, M-x ede-find-file
works.
However, there are one major niggle I'm struggling to sort out:
I need to type the full, case sensitive file name.
This is less than ideal on a project this size, because you often only remember part of the filename, and not necessarily the case. It would be great if I could get it set up so I only have to type a case-insensitive substring of the filename, and then get an IDO buffer or similar I can tab through until I get the file I'm looking for.
回答1:
I've resorted to using M-x cscope-find-this-file
instead. It forces me to choose from likely filepath options in a buffer, but it does a reasonable job of getting me the right file quickly and isn't hampered by case-sensitivity. If I can get this hooked up into IDO, then it should do exactly what I want.
For Python, CScope/xcscope.el is good, but not perfect for navigating Python tags. So I've started using Elpy. M-x elpy-goto-definition
works very well for Python files, and for the rest (C/C++) I'm using M-x cscope-find-this-symbol
.
来源:https://stackoverflow.com/questions/23950534/quickly-finding-project-files-using-emacs-ede