文章目录
<2022-08-25 周四>
在emacs
中如何将窗口的垂直分割改为水平分割
emacs
没有原生支持,所以抄了一个函数,如下:
emacs-lisp
;;; https://www.emacswiki.org/emacs/ToggleWindowSplit
(defun toggle-window-split ()
(interactive)
(if (= (count-windows) 2)
(let* ((this-win-buffer (window-buffer))
(next-win-buffer (window-buffer (next-window)))
(this-win-edges (window-edges (selected-window)))
(next-win-edges (window-edges (next-window)))
(this-win-2nd (not (and (<= (car this-win-edges)
(car next-win-edges))
(<= (cadr this-win-edges)
(cadr next-win-edges)))))
(splitter
(if (= (car this-win-edges)
(car (window-edges (next-window))))
'split-window-horizontally
'split-window-vertically)))
(delete-other-windows)
(let ((first-win (other-window 1)))
(funcall splitter)
(if this-win-2nd
(other-window 1))
(set-window-buffer (selected-window) this-win-buffer)
(set-window-buffer (next-window) next-win-buffer)
(if this-win-2nd
(other-window 1))))))
另emacs
如何将两个窗口的内容交换?调用M-x window-swap-states
即可。