在正则表达式上运行occur
时,帧会分成两个窗口,occur
缓冲区如下所示。但是,键盘焦点仍在原始缓冲区中。如何以编程方式更改此行为,以使occur
缓冲区成为当前缓冲区?我试过这个:
(defun test-occur ()
(interactive)
(occur "test")
(switch-to-buffer "*Occur*"))
但它不起作用..(即:现在occur
缓冲区显示在顶部和底部窗口中)
答案 0 :(得分:3)
您不必为此定义单独的功能。 只需添加一个钩子:
(add-hook 'occur-hook (lambda () (other-window 1)))
Alternatively,可能更可靠:
(add-hook 'occur-hook (lambda () (switch-to-buffer-other-window "*Occur*")))
答案 1 :(得分:1)
试试这个:
(defun test-occur ()
(interactive)
(occur "test")
(other-window 1))