emacs 以编程方式更改窗口大小
我想实现编译缓冲区自动折叠为小尺寸(但不在删除窗口时关闭),以便在成功编译到窗口后缩小到最小尺寸。
get-buffer-create
返回一个缓冲区。如何在与该缓冲区关联的窗口上shrink-window
?另外,有没有办法存储以前的窗口大小?
这是我第一次尝试 emacs lisp 编程,谢谢你的帮助。
I would like to implement automatic collapse of compilation buffer to small size (but not close at a delete windows), such that upon successful compilation to window is shrunk to minimum size.
get-buffer-create
returns a buffer. how can I shrink-window
on window associated with that buffer? also, is there a way to store previous window size?
It is my first foray into emacs lisp programming, thank you for your help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我相信有两种方法可以解决这个问题。
第一种是使用钩子“compilation-finish-functions”,它
是:
这导致了这样的解决方案:
我对该解决方案的唯一问题是它假设可以通过在结果字符串中查找字符串“finished”来确定成功。
另一种选择是建议
'compilation-handle-exit
- 其中明确地通过退出状态。我写了这个建议
当退出状态非零时缩小窗口。
注意:如果在进行第二次编译时
*compilation*
窗口仍然可见,则在失败时不会将其大小调整得更大。如果您希望调整其大小,则需要指定高度而不是nil
。也许这会符合您的喜好(更改第一个示例):将
nil
替换为(/ (frame-height) 2)
I believe there are two ways to solve this problem.
The first is to use the hook `'compilation-finish-functions', which
is:
Which leads to a solution like this:
The only problem I have with that solution is that it assumes that success can be determined by finding the string "finished" in the result string.
The other alternative is to advise
'compilation-handle-exit
- whichgets passed the exit-status explicitly. I wrote this advice which
shrinks the window when the exit status is non-zero.
Note: if the
*compilation*
window is still visible when you do your second compile, it will not be resized larger upon failure. If you want it to be resized, you'll need to specify a height instead ofnil
. Perhaps this would be to your liking (changing the first example):The
nil
was replaced with(/ (frame-height) 2)