Emacs: Split post window horizontaly

Hi,

I am using the scel package for supercollider within prelude emacs and I am trying to figure out how to split the post buffer horizontally when calling (sclang-start). I haven’t found any workarounds yet while I don’t fully understand the post-buffer related code in the sclang package.

I tried to use the (sclang-start-right) and (sclang-move-post-buffer-right) functions from:

But I end up with three buffers instead, it seems like that first the sclang-show-post-buffer-right function from the github repo from above is successful but then the default behaviour of sclang-start is applied to the post buffer itself. And I end up with 3 buffers instead like in the attached picture.

The aim is to have .scd (or workspace) on the left and post buffer on the right.

Any help would be appreciated!

this is the default behaviour of sclang-start (at least on my system) so my guess is that you don-t want- to trigger sclang-move-post-buffer-right from:

Thanks for your reply

If I understood your reply right, is the default for you horizontal split ?

I need to overwrite the default behaviour (splitting windows vertically) with horizontal split

This is the result of M-X sclang-start on my system (vanilla emacs 28.2).

Oh, if that is the case I might have to look more carefully into my personal scel config, I have loads of things so there might be something overwriting the default behaviour.

Thanks again!

Yes that is correct, default behaviour is horizontally but only when Emacs (I use GUI not within terminal) window size is “large enough” as I understand it. I did not find any reference on this though neither understand what is the limit. Whenever I have Emacs on full screen either maximised it splits horizontally. However, whenever Emacs window is either left or right half split, post buffer splits vertically.

If I manage to tweak that behaviour I will report it here. Because I rarely split vertically with only 2 buffers.

Emacs has a user-option split-window-preferred-function:

it is set by default to split-window-sensibly:

there it says:

[split-window-sensibly] first tries to split by placing the new window below, subject to the restriction imposed by split-height-threshold […], in addition to any other restrictions. If that fails, it tries to split by placing the new window to the right, subject to split-width-threshold (see below). If that also fails, and the window is the only window on its frame, this function again tries to split and place the new window below, disregarding split-height-threshold. If this fails as well, this function gives up and returns nil.

there are also some helpful comments in the sourcefile:

2 Likes

Aha! That makes sense, read the function docs in Emacs. Thanks for looking into it. I am planning to tweak that in the future specifically for scel. I will come back here and post the function if I manage to adapt that to the sophisticated scel code :slight_smile: Cheers!

I wanted to replicate my scnvim setup, and this works for me:

(use-package sclang
  :defer
  :config
  (setq sclang-show-workspace-on-startup nil)
  (add-to-list 'display-buffer-alist
   '("*SCLang:PostBuffer*" display-buffer-in-side-window
     (side . right)
     (window-width . 60))))

Puts the post window nicely on the right side without eating up half my screen :slight_smile:

2 Likes