Answers:
尝试以下方法:
(defun my-turn-current-window-into-frame ()
(interactive)
(let ((buffer (current-buffer)))
(unless (one-window-p)
(delete-window))
(display-buffer-pop-up-frame buffer nil)))
;; Inspired from `mouse-tear-off-window'.
(defun tear-off-window ()
"Create a new frame displaying buffer of selected window.
If window is not the only one in frame, then delete it.
Otherwise, this command effectively clones the frame and window."
(interactive)
(let ((owin (selected-window))
(buf (window-buffer))
(fr (make-frame)))
(select-frame fr)
(switch-to-buffer buf)
(save-window-excursion
(select-window owin)
(unless (one-window-p) (delete-window owin)))))
库中提供了此命令以及以下命令(如果所选窗口单独位于其框架中,则不执行任何操作)frame-cmds.el
。
(defun tear-off-window-if-not-alone ()
"Move selected window to a new frame, unless it is alone in its frame.
If it is alone, do nothing. Otherwise, delete it and create a new
frame showing the same buffer."
(interactive)
(if (one-window-p 'NOMINI)
(message "Sole window in frame")
(tear-off-window)))
(select-frame-set-input-focus fr)
有效。
select-frame-set-input-focus
。例如,在MS Windows中,它确实获得了焦点,因此不需要这样做。另外,命令描述并没有说框架变得聚焦。如果需要,可以创建一个不同的命令来调用它,然后聚焦框架。