I want such functionality from emacs (gnu 25), I press key in any buffer with source code, and instead of one buffer I got 3 buffers on the screen:

source code buffer
------------------
*eshell* | *compilation*

*eshell* should be created if not exists, and if no *compilation* buffer around, should *scratch* be shown, but should be replaced with *compilation* after first compilation.

I read about sessions, but as I understand it was not I want. I want this windows split for any source code buffers, not for specific, that I save in session and restore from session.

How can I achieve, any known extension/package with such functionality?

  • @Dan I read about sessions, persp-mode.el and perspective-el. But all of them (according to documentation) are not what I want. They deal with existing buffers, and before get functionality that I want, you have to add buffers to session/perspective. While I want this functionality for any buffers. – user1244932 Jul 25 '17 at 0:43
  • Do you want a dedicated *eshell* session for each source file, or just one global one? (or one per folder, or one per "project", or ....?) – deprecated Jul 27 '17 at 3:01
  • @deprecated Global one *eshell* and global one *compilation* – user1244932 Jul 27 '17 at 7:00
up vote 4 down vote accepted
+50

Here is a bare-bones minimum viable function, which I hope does what you want.

(defun wjh3pane-create-3pane-layout ()
  "Create 3-pane layout of windows in the current frame.

Layout is as follows:

    |--------------------------------------|
    |          source code buffer          |
    |          source code buffer          |
    |          source code buffer          |
    |--------------------------------------|
    |     *eshell*     |   *compilation*   |
    |--------------------------------------|

The height of the bottom windows can be changed by customizing
the `compilation-window-height' variable.  The function does
nothing if selected buffer is not visiting a file.
"
  (interactive)
  (when (buffer-file-name)
    (delete-other-windows)
    (save-selected-window
      (split-window-vertically (- (or compilation-window-height 10)))
      (select-window (next-window) t)
      (switch-to-buffer (eshell))
      (split-window-horizontally)
      (select-window (next-window) t)
      (switch-to-buffer (or (get-buffer "*compilation*")
                            (get-buffer "*scratch*"))))))

(global-set-key (kbd "s-3") 'wjh3pane-create-3pane-layout)

I have bound it to "Super 3" (I have super mapped to the caps lock key), but you can adjust that to taste. As it stands, you need to invoke the function manually, before or after calling compile. That could be automated with a bit more effort, for example, using advice. (I tried using a compilation hook, but that looked like it would be tricky). Also, it currently does nothing to save/restore the previous window configuration.

  • great, thanks a lot, I will try it in the next hours. – user1244932 Jul 27 '17 at 16:56
  • It works, thanks again. – user1244932 Jul 27 '17 at 20:51

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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