开发者

Using Emacs for big big projects

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 applicati开发者_运维问答ons 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


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.


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)))


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


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.


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


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


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).


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜