更新时间:2022-10-14 19:24:42
这样做:
(defadvice occurred(after occurrence-advice activate)
调整大小窗口
(save-selected-window
(pop-to-buffer * Occur *)
(fit-window-to-buffer nil 10))
I am trying to resize the occur-mode
buffer window to fit the contents of its buffer.
See Resize occur window in Emacs for more information.
I have added the following hook:
(add-hook 'occur-mode-hook
(lambda ()
(save-selected-window
(pop-to-buffer "*Occur*")
(message-box "ok")
(fit-window-to-buffer nil 10))))
Then I have the following buffer window:
and I now execute (occur "test")
which gives me first
and after pressing the "ok" button I get
Notice that the occur window has shrunk to a single line in height at the bottom of the frame. This was obviously not what I wanted..
I now enter (occur "test")
once more in the "t.txt" buffer, and after pressing "ok" to the message-box I get the following:
So now it suddenly works perfectly. Why is this not working the first time?
This works:
(defadvice occur (after occur-advice activate)
"Resize window."
(save-selected-window
(pop-to-buffer "*Occur*")
(fit-window-to-buffer nil 10)))