5

I am setting (setq split-width-threshold 100) in my dotspacemacs/user-config, in order to make various buffers split horizontally when the window is wide enough. This works as intended for magit status etc.

However, the compilation log buffer seems to disregard this, and always opens on the bottom.

How can i make the compilation buffer adhere to the split-width-threshold? Alternatively, how can get it to always split horizontally?

I am quite new to both emacs and spacemacs.

Jostein
  • 3,124
  • 1
  • 22
  • 27

3 Answers3

2

The reason for the compilation not to obey your settings is because spacemacs comes with purpose-mode enabled by default. If you use that, then it is a matter of modifying the purpose layouts as you wish. However if you are not using the purpose-mode, then disabling it fixes the issue for me. To just try it out you can do SPC SPC purpose-mode RET and then (with only one window opened) run the compilation.

nert
  • 942
  • 6
  • 17
  • Thanks for the answer, however this did not work for me either. I do not have the purpose layer installed, and there is no purpose-mode available in SPC SPC. – Jostein Nov 07 '17 at 21:23
  • @Jostein So now I'm wondering. I managed to fix it for myself this way, so I immediately jumped to a conclusion that it's the root cause. However, since then I removed the purpose-mode package and it doesn't work for me again. So I guess it just worked that one time. I should've put some points to my "luck" property when starting this incarnation, I guess. Welp. Sorry for the misleading answer then. – nert Nov 07 '17 at 22:52
  • This just saved my day :). – Dominik Schrempf Apr 12 '18 at 21:29
2

Here's one way to do it (SPC f e d to get to your config file, then you could put this in the existing dotspacemacs-user-config function) -- here I've shown how to get both grep and compilation buffers popping up on the right:

(require 'dash)

(defun my/popwin-on-right (alist-item)
  (let ((props-alist (seq-partition (cdr alist-item) 2)))
    (setf (alist-get :position props-alist) '(right))
    (setf (alist-get :height props-alist) '(1.0))
    (setf (alist-get :width props-alist) '(0.5))
    (let ((flattened (apply #'append props-alist)))
      (cons (car alist-item) flattened))))

(custom-set-variables
  '(popwin:special-display-config
    (--map-when (-contains? '("*compilation*" "*grep*") (car it))
                (my/popwin-on-right it)
                popwin:special-display-config)))

or you could just set popwin:special-display-config more directly, replacing the --map-when call there with a literal list. Just view the variable's existing value e.g. using SPC SPC ielm <RET> to get nice formatting, then cut and paste it in (you'll need to quote the list using '). Or you could do what I do when I want to set a customizable variable as a literal value: use SPC SPC customize, let that update the end of your spacemacs config file with its blob of generated code, then copy out the custom-set-variables it generates into your dotspacemacs-user-config, and delete the blob of code that customize generated).

Croad Langshan
  • 2,646
  • 3
  • 24
  • 37
0

From another answer

(setq split-height-threshold nil)
(setq split-width-threshold 0)

If you want these settings to only affect compile

(defadvice compile (around split-horizontally activate)
  (let ((split-width-threshold 0)
        (split-height-threshold nil))
    ad-do-it))
Tim Miller
  • 566
  • 5
  • 17
  • 1
    As i wrote i already do that, but it is not having the intended effect. That's the problem i'm trying to solve. I am guessing this has to do with Spacemacs (i believe the other answer concerns vanilla emacs), but i could be wrong. – Jostein Jun 29 '17 at 10:40
  • You say in your post that you're setting split-width-threshold to 100, not 0, correct? Have you tried setting it to 0? It might be that Spacemacs does something screwy with buffer placement, but I'm not aware of any such behavior. You could try it in a vanilla emacs configuration to see what's going on. – Tim Miller Jun 29 '17 at 12:04
  • Yes i did indeed try both 0 and 100, and it should not matter anyway, as my width is more than 100, and that does work as intended with the magit buffer. But for some reason the compilation buffer seems to be exempt from the thresholds. I could go digging in spacemacs itself or try to learn more about emacs configuration, but i was hoping someone might have had the same problem.. – Jostein Jun 29 '17 at 13:13