4

I use aquamacs 90% of the time to edit R files with ESS (Emacs Speaks Statistics). In this mode, I find it indispensable to have a split window, C-x 3 C-x 2, such that I can view simultaneously the source code and the R buffer (terminal window). Thus, every time I launch aquamacs, I need to perform the following steps: split the window, select the right one, switch buffer to *R*, go back to the file. How can I save this setup across sessions?

thanks.

baptiste
  • 75,767
  • 19
  • 198
  • 294
  • 1
    Use `C-h k` and issue the keybinding to see underlying commands, then add them to `.emacs` file. It shouldn't be too cumbersome... – aL3xa Jan 13 '12 at 03:03
  • nice, thanks. I added `(split-window-side-by-side)`, which works on its own, but somehow `(switch-to-buffer "*R*")` has a side-effect to revert the layout to one (small) window. – baptiste Jan 13 '12 at 03:31

3 Answers3

5

Try this:

(defun open-r-project ()
  (interactive)
  (delete-other-windows)
  (split-window-horizontally)
  (R)
  (ess-change-directory "~/projects/")
  (next-multiframe-window)
  (find-file "~/projects/")
  (previous-multiframe-window)
)

(global-set-key (kbd "C-c r") 'open-r-project)

Note, however, that this is my first LISP function. I have no idea how to make the project dir parameter working. Will try tomorrow. Oh, and note that I'm using SVN version of ESS.

aL3xa
  • 35,415
  • 18
  • 79
  • 112
  • Great piece of function, thanks! Could you figure out how to update the function to be able to pass parameters to it? – daroczig Apr 15 '12 at 14:00
  • @daroczig you mean passing folder path automagically via minibuffer? Hm, hm... It's in my TODO list. =) – aL3xa Apr 15 '12 at 18:01
  • Absolutely! Great, please report back if you'd have time to implement this (or have some ideas how to do it). – daroczig Apr 15 '12 at 19:11
4

There is C-c C-z (ess-switch-to-end-of-ESS) which does the splitting and switching to the end of ess inferior buffer. I am using it all the time.

VitoshKa
  • 8,387
  • 3
  • 35
  • 59
  • @baptiste what do you mean? If your R session has been started and the buffer is hidden it should switch to the end of it. It doesn't start the proc though. Might be good idea to add as a feature. – VitoshKa Feb 23 '12 at 13:55
  • @baptiste Yes, that is definitely useful, don't understand how it didn't occur to me before. It's in the latest SVN now. – VitoshKa Feb 23 '12 at 22:49
2

There are a number of packages that do this kind of thing. It seems that layout-restore is probably the closest fit, but you might want to look at all the entries in the Emacs wiki under the "Switching Window Configurations" heading of the Category Windows page.

Trey Jackson
  • 73,529
  • 11
  • 197
  • 229