2013-07-01 108 views
7

如果我在(端子)的Emacs使用水平分割改進,並有2個緩衝器在屏幕上:Emacs的重新排列拆分窗格

+--------------------------+ 
|       | 
|       | 
|       | 
|       | 
+--------------------------+ 
|       | 
|       | 
|       | 
|       | 
+--------------------------+ 

然後我決定打開煤泥REPL,Emacs會分裂的那些中的一個水平垂直窗格:

+--------------------------+ 
|       | 
|       | 
|       | 
|       | 
+-------------+------------+ 
|    |   | 
|    | slime  | 
|    |   | 
|    |   | 
+-------------+------------+ 

但我想要的是有正確的煤泥,使用窗口的最大高度:

+-------------+------------+ 
|    |   | 
|    |   | 
|    |   | 
|    |   | 
+-------------+ slime  | 
|    |   | 
|    |   | 
|    |   | 
|    |   | 
+-------------+------------+ 

有沒有什麼簡單的方法可以從Emacs自動給我,到我想要的(例如一個旋轉安排),還是我明確地關閉和重新拆分窗戶自己?

編輯|如果我目前正在使用完整的水平分割,或者如果實際上不可能,我也可以直接打開完整的垂直分割。

回答

3

肯定有用於轉換幀的窗口配置(翻轉,旋轉等等)的庫以及用於通過可用窗口旋轉可見緩衝區的其他庫。將這些結合起來可以達到你的目標。

我喜歡TransposeFrame對於前者,我至少可以看到一對夫婦的選擇後者:

一般來說,CategoryWindows Wiki上應對你有用。

請注意,窗口配置轉換需要刪除並重新創建拆分,所以原來的窗口對象並不都是存活的過程。在這方面,它是而不是實際上可以做你正在問的東西;但對於大多數目的而言,「僞造」就足夠了。

4

如果你喜歡預先設置窗口配置,看看在「工作空間管理」 pakages:

EmacsWiki上有更多關於project management的頁面。

你的第二個問題,這裏是我在我的配置翻轉水平/垂直分割(來源:https://github.com/yyr/emacs.d):

+0

我找不到'split-window-func-with-other-buffer'?是來自[這裏](https://github.com/yyr/emacs.d/blob/master/init-windows.el)嗎? –

+0

對不起,我忘了包含該功能。它確實來自您提到的來源。查看編輯後的版本。 –

1

這裏有一個功能,你想要做什麼。加載到emacs後,選擇你想重新排列的緩衝區並執行M-x my-shift-window-right。您還可以將其綁定到global-set-key的密鑰。

(defun my-shift-window-right (&optional start-window) 
    "Reset the current window configuration with START-WINDOW 
on the right and the rest of the windows on the left. START-WINDOW defaults to 
the selected window. Return START-WINDOW, or nil if START-WINDOW isn't live or 
if there is only one visible window." 
    (interactive (list (selected-window))) 
    (if (or (one-window-p) 
      (and start-window 
       (not (window-live-p start-window)))) nil 
    (let ((other-buffers '()) 
      (start-window (or start-window (selected-window)))) 
     ;; add all visible buffers other than the current one to other-buffers list 
     (walk-windows #'(lambda (window) 
         (when (not (eq window start-window)) 
          (add-to-list 'other-buffers (window-buffer window))))) 
     (delete-other-windows) 
     ;; pop the first "other buffer" into a split window on the left 
     (set-window-buffer (select-window (split-window start-window nil 'left)) 
         (pop other-buffers)) 
     ;; make a split window for each buffer in the "other-buffers" list 
     ;; select the start-window and return it when finished 
     (dolist (buffer other-buffers (select-window start-window)) 
     (set-window-buffer (split-window (selected-window) nil 'above) buffer))))) 

此功能循環通過其他可見窗口和他們的每一個緩衝區存儲在一個名爲列表other-buffers。然後按照您所描述的方式重新排列窗口,方法是遍歷other-buffers列表。