[英]Maximize Emacs Windows Horizonatally or Vertically
我知道 Cx 1,它將水平和垂直最大化當前窗口。
但是,我的問題是,是否可以僅在一個方向上將當前窗口擴展到框架的邊緣?
所以在下面我想將窗口 A 擴展到框架的右邊界,占用 B 和 C 當前占用的空間。但我希望 D 和 E 保持不變......我想在一個單個命令。
請原諒對 ASCII 藝術的可怕嘗試!
_______________________
| AAAAAA |BBBBBB |CCCC |
|________|_______|______|
| DDDDD | EEEEEEEEEE |
|________|______________|
我知道你可以一次水平移動 1 個字符,並且你可以使用重復 n 次命令多次執行此操作,但兩者都很笨重,當我真正想說的是擴展到右手邊時,我不知道不管那有多遠。
最近我想出了這個去每個幀占用你想要的空間並調用 CX 0,但這仍然有點笨拙。
我需要它在終端模式 (emacs -nw) 而不是圖形/X-Windows 模式下工作。
有任何想法嗎?
您可以使用庫frame-cmds.el
( description ) 執行此操作。
它提供了這些命令:
maximize-frame-horizontally
、 maximize-frame-vertically
和max-frame
restore-frame-horizontally
、 restore-frame-vertically
和restore-frame
“恢復”命令實際上是在最大化和恢復之間交替切換。 (它們是命令toggle-max-frame*
的別名。)
命令maximize-frame
和restore-frame
是通用的,可以通過給它們一個前綴 arg 來像水平和垂直命令一樣工作:水平為負數,垂直為非負數。
我有同樣的問題:我想水平而不是垂直最大化窗口。 在網上搜索無果后,我決定自己寫一個函數。 我想在這里分享它,以防將來對某人有所幫助。
(require 'cl-lib)
(defun durand-maximize-window-horizontally (&optional window)
"Make WINDOW have the same width as the frame.
WINDOW defaults to the selected window.
Other windows are retained, but moved to the top."
(let* ((window (or window (selected-window)))
;; the list of windows to the left
(left-windows-list (let ((temp-window window)
window-list)
(cl-loop while (window-in-direction
'left temp-window t)
do (let ((left-win
(window-in-direction
'left temp-window t)))
(push left-win window-list)
(setf temp-window left-win)))
window-list))
;; the list of windows to the right
(right-windows-list (let ((temp-window window)
window-list)
(cl-loop while (window-in-direction
'right temp-window t)
do (let ((right-win
(window-in-direction
'right temp-window t)))
(setf window-list
(append window-list
(list right-win)))
(setf temp-window right-win)))
window-list))
;; the list of windows to the left and to the right
;; the order is from left to the right.
(same-level-list (append left-windows-list right-windows-list))
;; save all parameters: the car is the buffer, and the cadr is a list
;; of parameters.
(window-parameters-list
(cl-loop for win in same-level-list
collect (list (window-buffer win)
;; (window-width win)
(window-parameters win)))))
(cl-loop for win in same-level-list
do (delete-window win))
;; now our window is the only window horizontally speaking.
;; now we shall create them once again, if they exist.
(when same-level-list
(let* ((split-base-window
(split-window window nil 'above))
(new-windows (list split-base-window))
newly-created-window)
(cl-loop
for ind from 1 to (1- (length same-level-list))
do
(setf newly-created-window
(split-window split-base-window
nil 'right)
;; NOTE: it is important this list also follows the order
;; of going from the left to the right
new-windows (append new-windows
(list newly-created-window))
split-base-window newly-created-window))
(cl-loop for index from 0 to (1- (length same-level-list))
do
(let ((buf (car (nth index window-parameters-list)))
(paras (cadr (nth index window-parameters-list))))
(set-window-buffer
(nth index new-windows) buf)
(cl-loop for para-pair in paras
do (set-window-parameter
(nth index new-windows)
(car para-pair)
(cdr para-pair)))))))))
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.