如何防止 Emacs 调整窗口大小?
我的 Lisp 工作环境将框架分为两个窗口,前者用于主要编码,后者用于我的 slime 评估。
不幸的是,当我犯了一些错误时(因为我还在学习 Lisp :P),slime 调试器会警告我,这样做它会显示在自动调整大小的底部窗口中。 更明确地说:
之前:
_______
| |
| |
_______
|_____|
之后:
_______
| | <- decreased in size!
_______
|_____| <- increased in size!
如何防止 Emacs 调整窗口大小?我希望 Emacs 保持窗口大小不变。
我怎样才能做到这一点?
谢谢!再见!
阿尔弗雷多
my Lisp-working-environment has the frame split into two windows, the former for the main coding, the latter for my slime evaluation.
Unfortunately, when I made some mistakes (cause I'm still learning Lisp :P) the slime debugger warns me, and doing this it shows up into the bottom window that is automatically resized.
Just to be more explicit:
BEFORE:
_______
| |
| |
_______
|_____|
AFTER:
_______
| | <- decreased in size!
_______
|_____| <- increased in size!
How can I prevent Emacs resizing my windows? I want Emacs to leave my window sizes the same.
How can I accomplish that?
Thanks! Bye!
Alfredo
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
您可以在开始时使用命令 Mx window-configuration-to-register (或 Cx rw)记住您的窗口配置。
之后您可以随时使用 Mx 跳转到寄存器(或 Cx rj)恢复您的配置。
You can remember your window configuration using the command M-x window-configuration-to-register (or C-x r w) at the beginning.
After you can always restore your configurations using M-x jump-to-register (or C-x r j).
winner-mode
是一个救星,但是要使pop-to-buffer
不首先调整窗口大小,请执行以下操作winner-mode
is a lifesaver, but to makepop-to-buffer
not resize the window in the first place, do不幸的是,emacs 中几乎每个程序都使用主命令
pop-to-buffer
来切换到不同窗口中的缓冲区,它具有您所描述的副作用。除了到目前为止的所有其他解决方案之外,还有一个获胜者模式来撤消/重做任何更改随时进行窗口配置。
Unfortunately the main command
pop-to-buffer
, which is used by almost every program in emacs to switch to a buffer in a different window, has the side-effect you described.In adition to all other solutions so far, there is a winner mode to undo/redo any changes in window configuration, at any moment of time.
如果您调用的某些代码更改了窗口配置,您可以
用 (save-window-excursion BODY ...) 包装你的代码
如果是调试器更改了配置 - 点击“q”,旧的配置将被恢复。
如果您希望调试器不更改大小,请尝试添加调试器模式挂钩来恢复窗口大小。
If some code you call changes the window configuration you can
wrap your code with (save-window-excursion BODY ...)
If it is the debugger that changes the configuration - hit "q" and the old configuration will be resotred.
If you want the debugger not to change size try adding a debugger-mode-hook to restore your window size.
要禁用窗口缩小,
shrink-window-if-larger-than-buffer
需要是无操作。您可以将其重新定义为不执行任何操作,但如果您建议它,您就可以随意启用和禁用它。您可以建议其他调用
shrink-window-if-larger-than-buffer
的函数来启用或禁用收缩:我有一段旧代码,基本上就是上面的代码,并且我有
由于某些被遗忘的原因,ignore-errors 包裹在
(apply orig args)
周围,但它可能不是普遍需要的。注意,这使用了 Emacs 24.4 中添加的新建议 API。如果您需要使用旧的 Emacs 版本,旧的建议 API 可以使用不同的语法执行相同的操作。
To disable window shrinking,
shrink-window-if-larger-than-buffer
needs to be a no-op. You could just redefine it to do nothing, but if you advise it, you get the ability to enable and disable it at will.You can advise other functions that call
shrink-window-if-larger-than-buffer
to enable or disable shrinking:I had an old piece of code that was essentially the above, and I had
ignore-errors
wrapped around(apply orig args)
for some forgotten reason, but it probably isn't universally needed.N.B. this uses the new advice API, which was added in Emacs 24.4. The old advice API can do the same thing with different syntax if you need to use an old Emacs version.
将“frame-inhibit-implied-resize”变量设置为“true”[1],通过配置文件(~/.emacs 等):
或通过 GUI 使用:
Options >自定义 Emacs >具体选项> '帧禁止隐式调整大小'>值菜单 = '始终' &应用并保存
在后一种方法的情况下,“自定义选项:帧禁止隐式调整大小”缓冲区中的“状态”应指示“已保存并设置”,而不是“标准”。
来自 [1]:
“如果{Frame Inhibit Implied Resize}为零,则设置特定框架的字体、菜单栏、工具栏、内部边框、边缘或滚动条可能会调整框架的大小,以保留其显示的列数或行数。是 t,没有完成这样的大小调整(..)”
Set the 'frame-inhibit-implied-resize' variable to 'true' [1], either via the configuration file (~/.emacs etc.):
or via the GUI with:
Options > Customize Emacs > Specific Option > 'frame-inhibit-implied-resize' > Value Menu = 'Always' & Apply and Save
In case of the latter method the 'STATE' in the 'Customize Option: Frame Inhibit Implied Resize' buffer should indicate 'SAVED and set', as opposed to 'STANDARD'.
From [1]:
"If {Frame Inhibit Implied Resize} is nil, setting font, menu bar, tool bar, internal borders, fringes or scroll bars of a specific frame may resize the frame in order to preserve the number of columns or lines it displays. If this option is t, no such resizing is done. (..)"