1

I like to create a small ansi-term window at the bottom of my emacs frame, so if I'm editing two files "A" and "B", my emacs frame would look like this:

+------+------+
|      |      |
|  A   |  B   |
|      |      |
+------+------+
|  ansi-term  |
+-------------+

I have a function & keybinding to create / remove the ansi-term window as needed. When I have it open, however, emacs has an annoying tendency split the ansi-term window in particular when creating a new window. For example, if I try to use C-h f to describe a function, emacs decides the best way to split my windows is to make it look like:

+------+------+
|      |      |
|  A   |  B   |
|      |      |
+------+------+
| ansi | help |
+-------------+

Which is the worst possible outcome. I'd be happy if either "A" or "B" were split, or if it simply opened "help" in which ever "A" or "B" I'm not working in. Is there any way to alert emacs that I never want the "ansi-term" window split? I assume this must be possible, since NeoTree seems to create an un-splittable window.

So far, I've found the following related functions, that don't quite do what I want:

  • (set-window-dedicated-p window t) - This makes it so emacs can't take over the window, but doesn't affect whether or not it's splittable
  • (set-frame-parameter nil 'unsplittable t) - This seems like it makes all windows in a frame unsplittable, not just the one I want.
  • split-window-preferred-function - Would allow me to write my own algorithm for determining how to split windows. I could probably force this to do what I want, but I don't really want to override this behavior for all of emacs, just this one window.

Is there a simple way to make it so my ansi-term window in particular is never split?

3
  • The docstring links quickly got me to window-splittable-p. Does the information there solve your problem?
    – phils
    Jan 2 at 3:51
  • That's a function that emacs calls every time it wants to split a window, passing in candidate windows as a parameter. I suppose I could override it to detect if it's looking at my ansi-term window, but I feel like that might be tricky to program correctly.
    – Wilduck
    Jan 2 at 16:55
  • What I meant was: the docstring tells you the criteria it uses to decide whether the window is splittable, all of which are based on variables you can control for the buffer in question.
    – phils
    Jan 2 at 23:37

1 Answer 1

1

Try

(display-buffer-in-side-window (get-buffer "*ansi-term*")
                                     '((side . bottom) (slot . 0))

See Displaying Buffers in Side Windows.

1
  • This works, and it looks like that's what NeoTree is doing as well. Thanks!
    – Wilduck
    Jan 2 at 20:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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