如何防止 Emacs 调整窗口大小?

发布于 2024-10-12 14:27:43 字数 430 浏览 2 评论 0原文

我的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

小伙你站住 2024-10-19 14:27:43

您可以在开始时使用命令 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).

节枝 2024-10-19 14:27:43

winner-mode 是一个救星,但是要使 pop-to-buffer 不首先调整窗口大小,请执行以下操作

(setq even-window-heights nil)

winner-mode is a lifesaver, but to make pop-to-buffer not resize the window in the first place, do

(setq even-window-heights nil)
半仙 2024-10-19 14:27:43

不幸的是,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.

生活了然无味 2024-10-19 14:27:43

如果您调用的某些代码更改了窗口配置,您可以
用 (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.

挽袖吟 2024-10-19 14:27:43

要禁用窗口缩小,shr​​ink-window-if-larger-than-buffer 需要是无操作。您可以将其重新定义为不执行任何操作,但如果您建议它,您就可以随意启用和禁用它。

;; never shrink windows
(defvar allow-window-shrinking nil
  "If non-nil, effectively disable shrinking windows by making `shrink-window-if-larger-than-buffer' a no-op.")
(advice-add 'shrink-window-if-larger-than-buffer
            :before-while
            (lambda (&rest args)
              "Do nothing if `allow-window-shrinking' is nil."
              allow-window-shrinking))

您可以建议其他调用 shr​​ink-window-if-larger-than-buffer 的函数来启用或禁用收缩:

(advice-add 'some-function-that-resizes-windows
            :around
            (lambda (orig &rest args)
              "enable shrinkage"
              (let ((allow-window-shrinking t))
                (apply orig args))))

我有一段旧代码,基本上就是上面的代码,并且我有 由于某些被遗忘的原因,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.

;; never shrink windows
(defvar allow-window-shrinking nil
  "If non-nil, effectively disable shrinking windows by making `shrink-window-if-larger-than-buffer' a no-op.")
(advice-add 'shrink-window-if-larger-than-buffer
            :before-while
            (lambda (&rest args)
              "Do nothing if `allow-window-shrinking' is nil."
              allow-window-shrinking))

You can advise other functions that call shrink-window-if-larger-than-buffer to enable or disable shrinking:

(advice-add 'some-function-that-resizes-windows
            :around
            (lambda (orig &rest args)
              "enable shrinkage"
              (let ((allow-window-shrinking t))
                (apply orig args))))

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.

雨的味道风的声音 2024-10-19 14:27:43

将“frame-inhibit-implied-resize”变量设置为“true”[1],通过配置文件(~/.emacs 等):

(自定义设置变量'(frame-inhibit-implied-resize t))

或通过 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.):

(custom-set-variables '(frame-inhibit-implied-resize t))

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. (..)"

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文