Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can i make the spacemacs compilation buffer split horizontally?

Tags:

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.

like image 676
Jostein Avatar asked Jun 26 '17 13:06

Jostein


2 Answers

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.

like image 89
nert Avatar answered Sep 22 '22 11:09

nert


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).

like image 35
Croad Langshan Avatar answered Sep 25 '22 11:09

Croad Langshan