Changing buffer focus control (pop-to-buffer vs display-buffer)

Is there an easy way (via defadvice or otherwise) to change the focus focus behavior of buffers like help, grep? In particular, I would like to change the behavior of Mx occur to directly send me to the * Occur * buffer. Some modes (such as ESS) provide finer control over the display of such "temporary" buffers, but is there a general strategy for buffers where such controls are not provided?

+4
source share
1 answer
 (add-hook 'occur-hook (lambda () (pop-to-buffer occur-buf))) (add-hook 'help-mode-hook (lambda () (pop-to-buffer (get-buffer "*Help*")))) (add-hook 'grep-mode-hook (lambda () (pop-to-buffer (get-buffer "*grep*")))) 

As an alternative, the general approach is to use special-display-regexps or special-display-buffer-names to create special-display buffers that put them in a separate frame (and select it). For instance:.

 (setq special-display-regexps '("[ ]?[*][^*]+[*]")) 
+3
source

Source: https://habr.com/ru/post/1388044/


All Articles