views:

233

answers:

5

Hello,

I am working with Ruby on Rails projects most of the time so I need a way to save projects and the state of the buffers/windows I am working on, mostly because I often find myself switching to a different project for a few minutes and then going back to the project I was working on. Desktop.el seems to be very close except for the window configuration saving.

For those familiar with TextMate, I'm looking for something like the textmate project files that you can open and they open a different instance of the editor that only opens the files in that project.

Thanks, Cezar

A: 

http://www.emacswiki.org/emacs/WindowsMode - Saves and restores Window configuration.

Johnny
this only saves windows, not files/buffers based on project root
Cezar
+2  A: 

I tried to put myself in your shoes and conjure up my preferred Emacs solution. Best I can come up with is that I do occasionally get into a mode where I don't want my windows mucked with by dealing with an Emacs interrupt, one that requires different Emacs resources (buffers/windows). Say for example I have an ediff going on and I want to go to the scratch buffer to test out an idea without mucking with my ediff perspective, to borrow the Eclipse notion. In such a case I generally do C-x 5 2 to bring up a new frame. If I've already got multiple frames up on the monitor I will do C-x 5 f to select a named frame.

In your case, you might have one set of frames with a "proj-x" prefix and another with a "proj-y" prefix. In this case C-x f proj-x-foo provides a quick switch to handle your interrupt C-x f proj-y-fee switches you back. In most cases, I think you talking about two frames, which is even easier: C-x f o to switch between the two frames.

I think the take-home point is that with Emacs, one can "drop" what you're doing without the need to close anything, do something else and then come back to your original environment with little fuss or muss. This is a corollary to the notion that with Emacs you can have hundreds of files open simultaneously, i.e. you do not need to close a file and then open another. Open 'em all and have a ball. :-) And when you embrace this style, C-x s is your friend.

pajato0
I don't want a new frame, I just want to be able to have a set of files I am working on in one frame and multipe windows (usually 2-3) one of which should be dired (that doesn't close)
Cezar
+1  A: 

Maybe you're trying to get emacs to work like an IDE, which it isn't. I often have multiple projects open in emacs and just never close emacs, not for weeks. This is one of the main reasons I ended up on emacs years ago. On my current project I switch between java, ruby and Lisp. I also need features to edit jsp, erb, html and css, the only thing I haven't sorted out yet is javascript. As well as the ability to completely customize my environment, this is the power of emacs.

I do use ECB all the time, and typically as I move around files, it follows me, I don't work from a 'windows' perspective, but from an 'Im here' perspective. A particular buffer being open or not is actually unimportant. I also use IDO, so switching buffers is really easy and intuitive. I generally have two buffers displayed max (but potentially lots open). M-X s is also useful to ensure you've saved as it will enumerate all the unsaved buffers and prompt you about them.

When I do have to close emacs, I generally get back to where I was very quickly by cd'ing to that folder and type emacs app/controllers/my_controller.rb. From there the rails navigation is very helpful. M-Shift-down arrow and we're off ...

wentbackward
when working with ruby on rails, you usually have a lot of inde.html files separated only by directory path which is a drag to find the right files especially when having over 1000 files in your project, not to mention opening more than one project
Cezar
You want "uniquify" enabled. If you have foo/index.html and bar/index.html open, it will name the buffers `foo/index.html` and `bar/index.html` instead of `index.html` and `index.html <1>`
jrockway
@jrockway - That's a great tip!
wentbackward
A: 

I like window-configuration-to-register (C-x r w <register_name>) for situations similar to what you're describing. Once you've save a window configuration to a register, it's just C-x r j <register_name> to get back to your saved configuration.

Evan
A: 

eproject has eproject-open-all-project-files, which ensures all files in the current project are opened (or invoke it with the prefix arg to choose an arbitrary project) and eproject-kill-project-buffers which closes all the files in the current project. This lets you easily get started with a project and lets you clean up when you are done.

jrockway
heya jrockway, your solution only works for a relatively small number of files (not thousands as in my case)
Cezar
Opening thousands of files with eproject is no slower than opening them manually. Of course, why do your projects contain thousands of files?
jrockway