1

Basically that. I need a function that would do this when I open a buffer in a frame with many other windows. Maybe Emacs has one by default.

1
  • Does this question and answer help any ("How to intercept a file before it opens and decide which frame")? stackoverflow.com/questions/18346785/… If you want to get rid of the other windows in the target frame, just add (delete-other-windows) after the target window has acquired focus. The answer in the linked thread targets the largest window in the frame, but that is a custom function and can be changed to do anything under the sun.
    – lawlist
    Commented Feb 5, 2021 at 18:15

2 Answers 2

1

What about

(defun switch-buffer-delete-other-windows ()
  (interactive)
  (call-interactively 'switch-to-buffer)
  (delete-other-windows))

(defun find-file-delete-other-windows ()
  (interactive)
  (call-interactively 'find-file)
  (delete-other-windows))

and so on…?

0

C-x 5 2 does what you request: it opens the current buffer in a separate frame. But it does not delete the original window showing the buffer in the original frame.

Command tear-off-window does both: opens the buffer in a separate frame and deletes its window from the original frame.

Personally, I bind tear-off-window to C-x 5 1. (I don't use that key's original binding of delete-other-frames.)

5
  • Thanks, when I do tear-off-window (in a split vertically window), it opens a new frame with my buffer, but inside two windows. What I need is a one window, in one frame solution :) Commented Feb 5, 2021 at 19:57
  • Sorry; I don't understand. A frame inside two windows? Maybe you're reversing the meanings of "frame" and "window"? No idea what you're saying now.
    – Drew
    Commented Feb 5, 2021 at 21:15
  • My apologies. I meant: "when I do tear-off-window (in a split vertically window), it opens a new frame with my buffer, but inside THERE ARE two windows. What I need is a one window, in one frame solution :)" Commented Feb 6, 2021 at 20:58
  • Do you see that if you start Emacs with emacs -Q (no init file). I don't. I don't see that with either a vertically split window (C-x 3) or a horizontally split window (C-x 2). If you don't see that with emacs -Q then bisect your init file to find the culprit.
    – Drew
    Commented Feb 6, 2021 at 23:03
  • Yes, I must have something in my init. Thanks! Commented Feb 7, 2021 at 14:11

Your Answer

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

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