在Emacs的org-mode中,如何让org-capture在全屏窗口中打开?

11
在Emacs的org-mode中,如何使org-capture在全屏窗口中打开,而不是首先分割窗口?
4个回答

10
你可以将 (add-hook 'org-capture-mode-hook 'delete-other-windows) 或者 (add-hook 'org-capture-mode-hook 'make-frame) 添加到你的 .emacs 文件中。(测试时,你可以使用 M-: 来评估这些内容)。第一个命令会删除其他窗口,第二个命令会在新框架中打开窗口。但是这些操作都是在你选择捕获模板之后才生效。

2
我修改了你的代码为(add-hook 'org-capture-mode-hook 'sticky-window-delete-other-windows),现在它完美地运行了。谢谢! - incandescentman

2

对我来说,已接受的答案在emacs 24中似乎无法正常工作。我找到的唯一解决方案涉及使用emacs-noflet和(感谢Alex Vorobiev)在您的emacs文件中:

 (defun make-capture-frame ()
     "Create a new frame and run org-capture."
     (interactive)
     (make-frame '((name . "capture")))
     (select-frame-by-name "capture")
     (delete-other-windows)
     (noflet ((switch-to-buffer-other-window (buf) (switch-to-buffer buf)))
       (org-capture)))

并绑定make-capture-frame到一个快捷键。


它对我有效,我使用的是Emacs 24.3.1。我指的是整个窗口,而不是分割窗口。(不是maximize-frame框架。)它对你无效吗? - incandescentman
这对我有效,我在Emacs 24.3.1上。我指的是完整的Emacs窗口,而不是将框架分成两个窗口。(我不是指全屏maximize-frame框架。)它对你无效吗? - incandescentman
有趣的是,它在一个分割窗口中打开,与org-capture上面的草稿缓冲区。这是我在24.3.1版本中使它工作的唯一方法。 - cazgp

0

对我来说,我需要确保 org-capture 在一个新的框架中打开,并且在完成后关闭该框架。以下方法可以很好地实现这一点:

    ; close capture frames when finished capturing
    (add-hook 'org-capture-after-finalize-hook (lambda () (delete-frame)))

    ; make org-capture open up as sole window in a new frame
    (defadvice org-capture (around my-org-capture activate)
       (progn
          (select-frame (make-frame))
          (delete-other-windows)
          (noflet
             ((switch-to-buffer-other-window (buf) (switch-to-buffer buf)))
             ad-do-it)))

1
在 spacemacs 中不起作用,"switch-to-buffer-other-window" 给出 "无效函数"。 - Rotkiv

0
没有一个答案对我在doom emacs 28.2(2023年6月)上有效,所以org-gtd.el和sqlup.el的作者昨天在reddit上解决了它。以下是他的片段:
*如果你使用doom emacs,请确保将其添加到(after! org ...)块中。
(defun stag-misanthropic-capture (&rest r)
  (delete-other-windows))

(advice-add  #'org-capture-place-template :after 'stag-misanthropic-capture)

如何从命令行调用它(对于“todo模板”):
emacsclient -e '(org-capture nil "t")' --create-frame

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接