1

I like using the following setup for development:

+--------+---------------------------------+
|    .   |                                 |
|        |         Python or JS            |
| Dired+ |             buffer              |  
|        |       (with centaur-tabs)       |
|        |                                 |
|        +---------------------------------+
|    .   |    Shell, Eshell, or iPython    |
+------------------------------------------+

I'm looking for ways to make this setup more "static" and intuitive. By "static", I mean that, for instance, I'd like the Shell and the Dired buffer not to be replaced nor resized by any action.

Here are examples of problematic use cases that I'm trying to solve:

  • when I open a file from the Dired+ buffer, with o, I want it opened on the top right window. By default, one time out of two, it gets opened in the "Shell" window, sometimes resizing it at the same time. I don't want that. I found a hack at the post Controlling window locations fo files visited by Dired, but it only works as long as the file in question is above the frame separation on the left (e.g. it works for the first point on the picture above, not for the second)

  • When I do C-h m, I'd like the *Help* buffer to always open in the largest window;

  • When using Magit, I'd like the Magit buffer to alway appear in the largest window.

Can anyone suggest a way to solve these problems, or, in a broader sense, an efficient way to use this configuration on Emacs?

  • 2
    There are numerous ways you could potentially achieve the ends you want. One may be Shackle. Another could be ECB. depp.brause.cc/shackle ecb.sourceforge.net – Lorem Ipsum Jun 3 at 13:34
  • 1
    If you want to keep the same buffer in a given window, consider making the window dedicated to that buffer. See (elisp) Dedicated Windows. – Drew Jun 3 at 16:28
  • Thank you for these really helpful answers! Following Drew 's suggestion I also found this post which gives a way to easily dedicate a buffer to a window. – kotchwane Jun 3 at 19:31
0

I achieve something similar by letting tmux handle the window splitting, and telling emacs to only split windows for certain transitory functions like undo tree. Note that this means switching to the terminal version of emacs.

To stop emacs from splitting windows I originally used

(setq pop-up-windows nil)

and

(setq split-window-preferred-function 'no-split-window)

and popwin to allow certain windows to appear in the same frame. However not everything plays nicely with popwin and I found that setting a fairly wide window limit achieved the same effect but allowed more things to work.

(setq split-window-preferred-function 'split-window-sensibly)
(setq split-width-threshold 100)

treemacs can be used in place of dired to give the behaviour you desire. I don't currently use it so I'm not sure of precisely how it interacts with popwin and the split-window functions but it looks ok in my (fairly wide) default emacs window with the above settings.

| improve this answer | |

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.