当进入occur
模式,例如(occur "test")
时,框架会分成两个窗口,如下所示:
正如所见,Occur缓冲区在帧上占用了太多空间,因为只有两个匹配(对于文本“test”)。我想相应缩小那个窗口。
我尝试了以下代码:
(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窗口没有任何反应)..
答案 0 :(得分:2)
这样做:
(add-hook 'occur-hook
(lambda ()
(save-selected-window
(pop-to-buffer "*Occur*")
(fit-window-to-buffer))))