3

I want my emacs frame to be permanently split into two (or sometimes 3 - with a different monitor - but let's talk two for now) columns of windows.

E.g., C-x 0 and C-x 1 may only affect the windows in the same "window column" as this one. Deleting a window column should be very hard (require a confirmation or a separate command).

Basically, this is functionally equivalent to having two frames side by side, except that I save on window decorations and the menu bar is re-used &c.

How do I get this without writing too much code?

2
  • Maybe you'd like to take a look at the source code of neotree, and then post an answer. (I want to know the answer to this question, too.)
    – shynur
    Commented Aug 16, 2023 at 16:11
  • @shynur: neotree appears to be similar to sr-speedbar and is thus a completely orthogonal issue: it creates a special window dedicated to the neotree buffer while I want both windows to be usable for all buffers and be splittable.
    – sds
    Commented Aug 17, 2023 at 13:32

1 Answer 1

1

Here is what I have been using for quite some time. It's small and simple, but quite imperfect.

(defun sds-split-window (size)
  "Split the window (sideways if it is wide) and switch buffer.
Pass SIZE to `split-window-right' or `split-window-below'."
  (interactive "P")
  (if (< split-width-threshold (window-width))
      (split-window-right size)
    (split-window-below size))
  (unrecord-window-buffer)
  (switch-to-buffer (other-buffer)))
(define-key global-map [f2] 'sds-split-window) ; use C-x 6 for 2C-command

(defun sds-delete-other-windows ()
  "Delete other windows first vertically, then all."
  (interactive)
  (if (eq last-command 'sds-delete-other-windows)
      (delete-other-windows)
    (delete-other-windows-vertically)))
(define-key ctl-x-map "1" 'sds-delete-other-windows)

(defun sds-swap-buf ()
  "Change the buffer to `other-buffer'."
  (interactive)
  (switch-to-buffer (other-buffer)))
(define-key global-map [f8] 'sds-swap-buf) ; same as C-x b RET

I would love to see something more robust (even at an expense of large code base - as long as it is maintained by someone else ;-).

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.