我在Emacs打开了2个窗户,我要放弃其立场。
Ie 考虑在源文档上安装一个REPL,而我则要放弃其位置,使REPL低于源档案。
我还愿保留窗户的大小。
我在Emacs打开了2个窗户,我要放弃其立场。
Ie 考虑在源文档上安装一个REPL,而我则要放弃其位置,使REPL低于源档案。
我还愿保留窗户的大小。
(defun swap-windows ()
"If you have 2 windows, it swaps them."
(interactive)
(cond ((not (= (count-windows) 2)) (message "You need exactly 2 windows to do this."))
(t
(let* ((w1 (first (window-list)))
(w2 (second (window-list)))
(b1 (window-buffer w1))
(b2 (window-buffer w2))
(s1 (window-start w1))
(s2 (window-start w2)))
(set-window-buffer w1 b2)
(set-window-buffer w2 b1)
(set-window-start w1 s2)
(set-window-start w2 s1)))))
在基因too的Emacs 23.1.1上测试。 这确实保护了窗户大小。
我也认为,这不太清洁。
(defun transpose-windows ()
(interactive)
(let ((this-buffer (window-buffer (selected-window)))
(other-buffer (prog2
(other-window +1)
(window-buffer (selected-window))
(other-window -1))))
(switch-to-buffer other-buffer)
(switch-to-buffer-other-window this-buffer)
(other-window -1)))
还对Emacs23.1.1进行了测试。
下面的版本与任何几个窗口有关。 当有两个以上窗口时,反复援引将使选定的缓冲出现在每一个窗口。
(defun swap-buffer () (interactive) (cond ((one-window-p) (display-buffer (other-buffer))) ((let* ((buffer-a (current-buffer)) (window-b (cadr (window-list))) (buffer-b (window-buffer window-b))) (set-window-buffer window-b buffer-a) (switch-to-buffer buffer-b) (other-window 1)))))
我发现
跟踪各种转变的图象。