3

I often split my windows into two with C-x 2. The window in the bottom tends to be the SLIME's REPL or Magit and the one at the top is usually the common lisp file being edited.

I like to have more space for the file to be edited. Thus, every time, I keep doing:

(i) - C-x 2; (ii) - Put the cursor on the window at the top (it is the default position); (iii) - C-x ^ enlarges the window. In order to do it multiple times, I use C-u 7 to repeat it 7 times. Thus, I press C-u 7 C-x ^

Is there a way to automate this? Maybe adding a hook to my config files so that every time I press C-X 2 then C-u 7 C-x ^ happens?

Drew
  • 77,472
  • 10
  • 114
  • 243
Pedro Delfino
  • 1,489
  • 3
  • 16
  • 1
    I believe this is a duplicate of https://stackoverflow.com/questions/10240192/emacs-slime-hard-code-vertical-split-ratio/10240378 (but we can't close questions as duplicates across sites). – phils Aug 13 '21 at 00:44
  • 2
    A simple shortcut would be to create a keyboard macro that records the keys you're using now, then just use that keyboard macro. You can bind that to a key (even C-x 2). – Drew Aug 13 '21 at 04:22
  • 1
    you might want to have a look at the golden-ratio package which provides some more control over how windows are split. – zzkt Aug 13 '21 at 09:20

1 Answers1

1

This old answer in stackoverflow pointed out by @phils really helped me.

The following code in my init file did the trick:

(defun my-split-window-below (&optional arg)
  "Split the current window 70/30 rather than 50/50.
A single-digit prefix argument gives the top window arg*10%."
  (interactive "P")
  (let ((proportion (* (or arg 7) 0.1)))
    (split-window-below (round (* proportion (window-height))))))

(global-set-key (kbd "C-x 2") 'my-split-window-below)

Pedro Delfino
  • 1,489
  • 3
  • 16