调整Emacs中出现的窗口大小 [英] Resize occur window in Emacs

查看:175
本文介绍了调整Emacs中出现的窗口大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

进入模式时,例如(发生test),框架分为两个窗口,如下所示:

When entering occur mode for example (occur "test") the frame splits into two windows as shown below:

看到Occur缓冲区占用了太多的空间,因为只有两个匹配(文本test)。我想缩小窗口。

As seen the Occur buffer is taking up too much space on the frame, since there is only two matches (for the text "test"). I would like to shrink that window accordingly.

我尝试了以下代码:

(defun test-occur ()
  (interactive)
  (occur "test")
  (save-window-excursion
    (other-window 1)
    (let (( win (selected-window))
      (n (count-lines (point-min) (point-max)))
      (h (window-body-height)))
      (let ((delta (- (- h n) 3)))
    (window-resize win (- 0 delta) nil)))))

但它不起作用(没有发生在Occur窗口)..

But it does not work (nothing happens with the Occur window)..

推荐答案

只要这样做:

 (add-hook 'occur-hook
       (lambda ()
         (save-selected-window
           (pop-to-buffer "*Occur*")
           (fit-window-to-buffer))))

这篇关于调整Emacs中出现的窗口大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆