加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Windows > 正文

emacs以编程方式更改窗口大小

发布时间:2020-12-14 01:48:35 所属栏目:Windows 来源:网络整理
导读:我想实现编译缓冲区自动折叠到小尺寸(但不能在删除窗口关闭),这样成功编译到窗口后缩小到最小尺寸. get-buffer-create返回一个缓冲区.如何在与该缓冲区关联的窗口上缩小窗口?还有,有没有办法存储以前的窗口大小? 这是我第一次涉足emacs lisp编程,谢谢你的
我想实现编译缓冲区自动折叠到小尺寸(但不能在删除窗口关闭),这样成功编译到窗口后缩小到最小尺寸.

get-buffer-create返回一个缓冲区.如何在与该缓冲区关联的窗口上缩小窗口?还有,有没有办法存储以前的窗口大小?

这是我第一次涉足emacs lisp编程,谢谢你的帮助.

我相信有两种方法可以解决这个问题.

第一种是使用钩子”compilation-finish-functions’,它
是:

[A list of f]unctions to call when a compilation process finishes.
Each function is called with two arguments: the compilation buffer,
and a string describing how the process finished.

这导致了这样的解决方案:

(add-hook 'compilation-finish-functions 'my-compilation-finish-function)
(defun my-compilation-finish-function (buffer resstring)
  "Shrink the window if the process finished successfully."
  (let ((compilation-window-height (if (string-match-p "finished" resstring) 5 nil)))
    (compilation-set-window-height (get-buffer-window buffer 0))))

我对该解决方案的唯一问题是它假定可以通过在结果字符串中找到字符串“finished”来确定成功.

另一种方法是建议’编译 – 处理 – 退出 – 哪个
明确地传递退出状态.我写了这个建议
退出状态为非零时缩小窗口.

(defadvice compilation-handle-exit (around my-compilation-handle-exit-shrink-height activate)
  (let ((compilation-window-height (if (zerop (car (ad-get-args 1))) 5 nil)))
    (compilation-set-window-height (get-buffer-window (current-buffer) 0))
    ad-do-it))

注意:如果在第二次编译时仍然可以看到* compilation *窗口,则在失败时不会调整大小.如果要调整大小,则需要指定高度而不是nil.也许这是你喜欢的(改变第一个例子):

(if (string-match-p "finished" resstring) 5 (/ (frame-height) 2))

nil被替换为(/(frame-height)2)

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读