EprojectExamples
Cookbook goes here.
After you have defined ProjectTypes, you might want to setup additional Project Attributes.
If you want M-x compile to do the right thing for your project, you can do something like this:
(add-hook scala-project-file-visit-hook
(lambda (nil)
(set (make-local-variable 'compile-command)
(format "cd %s; make -f Makefile.scala" (eproject-root)))))
If you want to examine every file looking for “TODO” comments, a quick invocation of rgrep might work:
(rgrep "TODO" "*" (eproject-root))
If you wanted to be pedantic, you could consult eproject’s list of relevant and irrelevant files and include/exclude them accordingly. You could also open each file, load the syntax table, and only search inside of comments. I would be happy to accept such code into eproject-extras, but I am a little too lazy to write it myself :)
Edit: This is implemented now; just run M-x eproject-todo
!
I have a somewhat complex window configuration:
The screen is split three times vertically. The first third is usually split once horizontally and has an IRC window and a shell, and the other two thirds show the code for my current project. Sometimes, something (hello, Gnus) messes that up, and it’s a bit of work to restore. With eproject, I can find my most recently used project and find the two most-recently-visited buffers in that project. It’s then a simple matter of programming to setup my window configuration:
(defun first-matching-buffer (predicate)
"Return PREDICATE applied to the first buffer where PREDICATE applied to the buffer yields a non-nil value."
(loop for buf in (buffer-list)
when (with-current-buffer buf (funcall predicate buf))
return (with-current-buffer buf (funcall predicate buf))))
(defun fix-windows ()
"Setup my window config."
(interactive)
(let ((current-project
(first-matching-buffer (lambda (x) (ignore-errors (eproject-name)))))
(current-irc-window
(first-matching-buffer (lambda (x) (and (eq major-mode 'rcirc-mode)
x))))
(current-shell
(or (first-matching-buffer (lambda (x)
(and (or (eq major-mode 'eshell-mode)
(eq major-mode 'term-mode))
x)))
(eshell))))
(delete-other-windows)
(split-window-horizontally)
(split-window-horizontally)
(window-number-select 1)
(split-window-vertically)
(labels ((show (x) (set-window-buffer nil (or x (get-buffer-create "*scratch*")))))
(window-number-select 1)
(show current-irc-window)
(window-number-select 2)
(show current-shell)
(let ((cur))
(loop for i in '(3 4)
do
(window-number-select i)
(show (first-matching-buffer
(lambda (x) (and (equal (ignore-errors (eproject-name))
current-project)
(not (equal cur (buffer-name x)))
x))))
(setf cur (buffer-name (current-buffer))))))
(balance-windows)))
(On github, http://github.com/jrockway/elisp/blob/8de738e7c37c4b57aee0e777883a2aaf58c4035e/_local/windowing-extras.el#L22. Textile sucks!)
Anything.el is an enhanced version of find-file, switch-to-buffer, etc. It gives functionality like, e.g., when you call find-file, it shows your recentf and open buffers and lets you autocomplete on them.
http://www.emacswiki.org/emacs/anything.el
Obviously, we want to integrate this with eproject, so that find-file will search for files in the current eproject.
First we create anything sources, which are objects that anything.el does autocompletion on.
(defvar anything-c-source-eproject-files
'((name . "Files in eProject")
(init . (lambda () (if (buffer-file-name)
(setq anything-eproject-root-dir (eproject-maybe-turn-on))
(setq anything-eproject-root-dir 'nil)
)))
(candidates . (lambda () (if anything-eproject-root-dir
(eproject-list-project-files anything-eproject-root-dir))))
(type . file))
"Search for files in the current eProject.")
(defvar anything-c-source-eproject-buffers
'((name . "Buffers in this eProject")
(init . (lambda () (if (buffer-file-name)
(setq anything-eproject-root-dir (eproject-maybe-turn-on))
(setq anything-eproject-root-dir 'nil))))
(candidates . (lambda () (if anything-eproject-root-dir
(mapcar 'buffer-name ( cdr (assoc anything-eproject-root-dir (eproject--project-buffers)))))))
(volatile)
(type . buffer))
"Search for buffers in this project.")
Then you can add the sources to your anything functions:
(defun anything-for-buffers ()
"Preconfigured `anything' for opening buffers. Searches for buffers in the current project, then other buffers, also gives option of recentf. Replaces switch-to-buffer."
(interactive)
(anything '(anything-c-source-eproject-buffers
anything-c-source-buffers+
anything-c-source-buffer-not-found
anything-c-source-recentf)))
You can do something similar with anything-for-files (see anything-config.el).