Dell 27 MonitorになってからEmacsを左右二画面分割して使うことが多くなった。
横長だからだけど、それでも時々、上下二分割にしたいことがある。しかも左右二分割した画面を、上下に切り替えたい。そんなコマンドはないものか、と探してみたけれど、見つけることができなかった。いちいちCtrl+x,1で全画面化して二分割して……ああ、面倒臭い。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require 'dash) | |
(defun y-swap-screen-tateyoko () | |
"windowを縦横変換する。" | |
(interactive) | |
(let* ((windows (window-list)) | |
(buffers (loop for x in windows | |
collect (window-buffer x)))) | |
(when (= (length windows) 2) | |
(if (= (window-top-line (nth 0 windows)) | |
(window-top-line (nth 1 windows))) | |
(progn (delete-other-windows) | |
(split-window-vertically) | |
(loop for x in (window-list) | |
for y in buffers | |
do (set-window-buffer x y))) | |
(progn (delete-other-windows) | |
(split-window-horizontally) | |
(loop for x in (window-list) | |
for y in (-rotate 1 buffers) | |
do (set-window-buffer x y))))))) |
つくる。
適当に配置をrotateさせるのでたぶん、4回、呼び出すと、元の位置に戻るはず。
それにしてもダサいな、このコード……。