[英]In Emacs, how can I open a buffer/file in “ibuffer/dired mode” in another frame?
当我使用多个帧时,我想决定Emacs应该在哪个框架中打开文件/缓冲区。
你无法开箱即用。
有find-buffer-other-frame
等,但是它们打开了一个新的框架。
你能做的就是写下你自己的函数:
(defun find-file-in-frame ()
(interactive)
(call-interactively 'select-frame-by-name)
(call-interactively 'find-file))
这会切换帧然后请求文件,如果你想这样做,否则你必须做更多的工作。
编辑:这是在当前框架中询问并在另一个窗口中打开文件的版本:
(defun find-file-in-frame (noselect)
(interactive "P")
(let ((current-frame (selected-frame))
(frame (completing-read "Frame: " (make-frame-names-alist)))
(buffer (save-window-excursion
(call-interactively 'find-file))))
(select-frame-set-input-focus (assoc-default frame
(make-frame-names-alist)
nil current-frame))
(switch-to-buffer buffer)
(when noselect
(select-frame-set-input-focus current-frame))))
如果你只是提到find-file
,那么我建议使用windmove
和framemove
的组合,切换到你想打开文件的框架是如此微不足道和快速,你可能不需要任何更好的东西。
OTOH如果您希望能够以任何方式打开文件时选择一个框架,这显然不适用。
不确定你真正在问什么。 但是对于在另一帧中打开Dired文件,只需在Dired +中使用Co或M-mouse-2 。 这些命令绑定到这些命令,以防您因某些原因不想加载Dired + :
(defun diredp-find-file-other-frame () ; Bound to `C-o' "In Dired, visit this file or directory in another frame." (interactive) (find-file-other-frame (file-name-sans-versions (dired-get-filename nil t) t))) (defun diredp-mouse-find-file-other-frame (event) ; Bound to `M-mouse-2' "In Dired, visit file or directory clicked on in another frame." (interactive "e") (let ((pop-up-frames t)) (dired-mouse-find-file-other-window event)))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.