;; 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)))))
Bu komutun yanı sıra, seçilen pencere çerçevesinde yalnız ise hiçbir şey yapmaz, kitaplıkta kullanılabilir 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)))