1

Say I have two frames open. Frame A is visiting a file foo.org. Calling (pop-to-buffer "foo.org") in the other frame (B) opens foo.org in frame B instead of moving the focus to frame A where that buffer is already open. Can this be configured (and how) to "jump" to frame A?

I appreciate that there are other functions that allow me to jump "across frames" but I'd like to adapt the behaviour of pop-to-buffer specifically.

1 Answer 1

1

pop-to-buffer is essentially display-buffer with selecting the chosen window afterwards.

You can influence the behavior of display-buffer with display actions specified in several variables. See the corresponding info page for a complete list of actions and variables.

I think you should configure display-buffer-base-action with your preferred display behavior.

display-buffer-reuse-window with the alist (reusable-frames . 0) avoids popping up the buffer in the already selected frame if it is shown on another frame.

Configure it with the following Elisp snippet in your config files or use M-x customize-option RET display-buffer-base-action RET.

(setq display-buffer-base-action '(display-buffer-reuse-window (reusable-frames . 0)))

The list of available options for the reusable-frames entry of the alist is:

  • nil: the selected frame (actually the last non-minibuffer frame)
  • A frame : just that frame
  • ‘visible’: all visible frames
  • 0 : all frames on the current terminal
  • t : all frames.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.