I would like to start emacs with a default window configuration. The 'vanilla' config just opens a single window. After installing 'sr-speedbar' and adding (sr-speedbar-open) to my init file, emacs starts two windows, split horizontally, the right one containing the speedbar. I can split the speedbar window vertically and open the buffer menu in the bottom window with M-x buffer-menu. My screen now looks something like this:

|    |a|
|    |-|
|    |b|

where 'a' is the speedbar and 'b' is the buffer menu. How can I get this configuration on startup? I've tried:

  1. (desktop-save-mode 1) Doesn't seem to affect window configuration.
  2. workgroups. This has some issues with splitting the speedbar window. It simply gives an error when loading. If I turn off the speedbar, it still doesn't work; the buffer menu is not loaded when I restart (the window locations are indeed saved correctly).
  3. Half of the things found here. As in #2, none of the packages actually load the buffer menu on startup.
  • Well, assuming point starts in the left-hand window, you could try adding (other-window) (buffer-menu) (other-window) to your init file; that should move point to the speedbar window, split it for the buffer menu (the second function call being identical to what happens when you M-x buffer-menu), and then move point back to the big window on the left. Adjust to taste (for example, OTHER-WINDOW can take an argument specifying how many windows to cycle through from the current one), but something like that can probably be made to work. Nov 28, 2013 at 1:31
  • If there are a certain number of maneuvers that you always do when opening Emacs to create your initial layout, then you can use something like this to automate the process: (add-hook 'emacs-startup-hook (lambda () (...user2407038-opening-sequence...one...)(...user2407038-opening-sequence...two...) (...user2407038-opening-sequence...three...) )) NOTE: desktop.el uses the after-init-hook, and the emacs-startup-hook runs subsequent to the after-init-hook. If you use desktop-save-mode, then you may need to adjust your startup sequence accordingly.
    – lawlist
    Nov 28, 2013 at 1:59

1 Answer 1

  1. With development snapshots of GNU Emacs, and the soon-to-be-released Emacs 24.4, desktop.el does restore frame and window configurations. It is not perfect, but it is about as good as it could be, given that some buffer states are dynamic etc. I would suggest you start by trying this, if you can.

  2. Aside from that, whatever you do normally (interactively or by batch code) to put your Emacs in a given state can, for the most part, put done in your init file. So starting Emacs by loading your init file should be able to restore whatever is significant to you. Yes, it might be complicated to get as much reproduced as you might want. But there is no inherent barrier, beyond the fact that time passes and the world changes: today is not tomorrow, of course.

  • I will try #1. As for #2, I understand I can write the code myself, but that would require learning elisp! I don't think I have that much free time. Nov 28, 2013 at 18:44
  • I agree: #1 is the answer, assuming you can get hold of and use a dev snapshot.
    – Drew
    Nov 28, 2013 at 23:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.