![](/img/trans.png)
[英]How can I open a new frame which always displays the active buffer of its parent frame in emacs?
[英]How do I make this Emacs frame keep its buffer and not get resized?
我的Emacs框架看起来像这样:
+---------------------------+
| | |
| | |
| | B |
| A | |
| | |
| | |
| |-------------|
| | C |
+---------------------------+
C
通常是一个具有某种长时间运行过程的终端,如Web服务器或守护进程。 不幸的是,各种各样的事情都喜欢在那个窗口中切换缓冲区,偶尔会调整大小。 如何锁定窗口C
的缓冲区和高度?
一种可能性是将所述窗口专用于它的缓冲液,使用set-window-dedicated-p
这不会阻止窗口手动调整大小,只能防止窗口被display-buffer
破坏。 例如,
(add-hook 'shell-mode-hook (lambda () (interactive) (set-window-dedicated-p (selected-window) 1)))
根据需要替换shell-mode-hook
。
如果您不希望被窗口窃取和调整大小烦恼,请在.emacs中添加以下行以获得最终解决方案,该解决方案甚至可以用于gud之类的库,当他们无法窃取您的窗口时尝试打开新框架 :
(有关以下advice
信息,请参阅此答案 )
(defadvice pop-to-buffer (before cancel-other-window first)
(ad-set-arg 1 nil))
(ad-activate 'pop-to-buffer)
;; Toggle window dedication
(defun toggle-window-dedicated ()
"Toggle whether the current active window is dedicated or not"
(interactive)
(message
(if (let (window (get-buffer-window (current-buffer)))
(set-window-dedicated-p window
(not (window-dedicated-p window))))
"Window '%s' is dedicated"
"Window '%s' is normal")
(current-buffer)))
;; Press [pause] key in each window you want to "freeze"
(global-set-key [pause] 'toggle-window-dedicated)
并将pop-up-windows
变量自定义为nil
。
您也可以使用StickyWindows而不是窗口专用功能。
这个也很好(对于emacs 24) https://lists.gnu.org/archive/html/help-gnu-emacs/2007-05/msg00975.html
(define-minor-mode sticky-buffer-mode
"Make the current window always display this buffer."
nil " sticky" nil
(set-window-dedicated-p (selected-window) sticky-buffer-mode))
您可以使用winner-mode来将更改撤消为窗口大小。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.