Emacs 强制组织模式捕获缓冲区在新窗口中打开

2024-05-08

如何强制组织模式的捕获缓冲区在新窗口中打开?我试过

(setq special-display-regexps
    '("^\\*Capture\\*$"))

但它不起作用 - 我立即看到一个新窗口,然后 org-mode 进行两个垂直分割(我使用 3 个垂直分割),并将捕获缓冲区放入右侧分割中。当我完成任一C-c C-c or C-c C-k,恢复原来的分割设置。


我也喜欢使用许多并排分割(通常是 4 个——我分布在多个显示器上),所以org-capture将 4 个普通窗户变成 2 个非常宽的窗户的行为每次都让我头疼——这往往会让我脱离我的流程。

+---+---+---+---+     +-------+-------+
| 1 | 2 | 3 | 4 | --> |   1   |capture| = head explosion
+---+---+---+---+     +-------+-------+

所以这里有一个方法可以防止org-capture修改您的窗口配置。

经过一番搜索后,似乎没有一种简单的方法来自定义此行为(或者至少不是一个明显的方法)。跟踪源代码中的函数调用使我们发现org-capture-place-template,这会保存您的原始窗口配置,然后删除其他窗口,然后给你两个窗口的分割。当然,当您完成捕获后,您可以稍后恢复窗口配置,但是摆脱“让我们在没有您的同意的情况下更改窗口布局”的步骤肯定会很好。

事实证明这很简单。只是重新评估org-capture-place-template注释掉单行调用后(delete-other-windows):

(defun org-capture-place-template ()
  "Insert the template at the target location, and display the buffer."
  (org-capture-put :return-to-wconf (current-window-configuration))
  ;; (delete-other-windows)                ; this is the culprit!
  (org-switch-to-buffer-other-window
   (org-capture-get-indirect-buffer (org-capture-get :buffer) "CAPTURE"))
  (widen)
  (show-all)
  (goto-char (org-capture-get :pos))
  (org-set-local 'org-capture-target-marker
         (point-marker))
  (org-set-local 'outline-level 'org-outline-level)
  (let* ((template (org-capture-get :template))
     (type (org-capture-get :type)))
    (case type
      ((nil entry) (org-capture-place-entry))
      (table-line (org-capture-place-table-line))
      (plain (org-capture-place-plain-text))
      (item (org-capture-place-item))
      (checkitem (org-capture-place-item))))
  (org-capture-mode 1)
  (org-set-local 'org-capture-current-plist org-capture-plist))

啊啊啊。它就像org-capture每次我用它的时候都会打我的脸,但现在它停止了。


(编辑:以下内容适用于较新版本的组织模式)

(defun org-capture-place-template (&optional inhibit-wconf-store)
  "Insert the template at the target location, and display the buffer.
When `inhibit-wconf-store', don't store the window configuration, as it
may have been stored before."
  (unless inhibit-wconf-store
    (org-capture-put :return-to-wconf (current-window-configuration)))
  ;(delete-other-windows)
  (org-switch-to-buffer-other-window
   (org-capture-get-indirect-buffer (org-capture-get :buffer) "CAPTURE"))
  (widen)
  (show-all)
  (goto-char (org-capture-get :pos))
  (org-set-local 'org-capture-target-marker
         (point-marker))
  (org-set-local 'outline-level 'org-outline-level)
  (let* ((template (org-capture-get :template))
     (type (org-capture-get :type)))
    (case type
      ((nil entry) (org-capture-place-entry))
      (table-line (org-capture-place-table-line))
      (plain (org-capture-place-plain-text))
      (item (org-capture-place-item))
      (checkitem (org-capture-place-item))))
  (org-capture-mode 1)
  (org-set-local 'org-capture-current-plist org-capture-plist))
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Emacs 强制组织模式捕获缓冲区在新窗口中打开 的相关文章

  • Emacs C++,打开相应的头文件

    我是 emacs 新手 我想知道 是否有在头文件 源文件和相应的源文件 头文件之间切换的快捷方式 是否有像通用 emacs 参考卡那样的参考卡 Thanks There s ff find other file 您可以使用以下方法将其绑定到
  • emacs 去掉 shell 中的所有 ansi 颜色代码

    我在 OS X 上使用 emacs 24 但遇到了一个奇怪的问题 我看不到任何颜色代码 Emacs 似乎只是忽略它们 我的动机是查看 C 项目的 cmake llvm 和 googletest 框架的彩色输出 我想在编译模式下查看颜色 但是
  • Emacs 正则表达式:什么 \< 和 \> 可以做 \b 不能做的事情?

    正则表达式反斜杠 GNU Emacs 手册 http www gnu org software emacs manual html node emacs Regexp Backslash html说 lt 匹配单词的开头 gt 匹配单词末尾
  • Mac OS High Sierra 下无法打开 pty

    我的问题的本质是 用户程序如何在 Mac OS High Sierra 上打开 pty 例如 dev ptyp0 设备名称的标准 open 似乎不起作用 尽管它的保护是 crw rw rw 上下文是在 Mac OS 下运行 Emacs 在
  • Emacs 启动时出现 24 错误

    我已经使用 emacs snapshot 一段时间了 但最近它崩溃了很多 所以我切换到 Emacs 24 但是一旦我安装并启动它 它就开始显示错误并且不会在我的 init el 中加载任何内容 当我在调试模式下运行它时 我得到了这个 Deb
  • 永久启用所有禁用的命令

    我想启用 Emacs 中所有禁用的命令 例如downcase region 也就是说 当调用时 它们不会要求用户确认 不幸的是 Emacs 手册的 48 3 11 禁用命令 部分没有提及启用all禁用命令永久 Emacs版本 24 0 95
  • Emacs 打字骨架对插入也许

    在 Eclipse 中 编辑 Java 代码时 如果我输入一个左括号 我会得到一对括号 如果我然后 输入 第二个括号 它不会插入额外的括号 我如何在 emacs 中得到它 Eclipse 编辑器足够聪明 当我输入闭括号时 它知道我刚刚完成了
  • 在 Slime 中复制/猛拉整个 Lisp 表单

    有没有办法在 Slime Emacs 中复制 猛拉整个表单 例如 如果我有以下功能 myfunc lst myotherfunc lst 我想复制 复制 myotherfunc lst 当我的光标位于该表单的左括号或右括号时 在 Slime
  • 无法在 Emacs 中打开 plantuml 模式

    我使用的是 Emacs 24 3 1 我安装了MELPA http melpa milkbox net 的版本plantuml mode https github com zwz plantuml mode via M x package
  • ess-rdired:我收到此错误“现在没有 ESS 进程与此缓冲区关联”

    To use ess rdired为了浏览对象 我按照 ESS 手册并将以下内容添加到我的 emacs autoload ess rdired ess rdired View R objects in a dired like buffer
  • 为什么 clojure-mode 用一些卷曲的 f 字符替换 fn ?

    我刚刚开始使用 emacs 入门套件和 clojure 模式 现在 当我输入或粘贴 fn 在 Clojure 模式下进入缓冲区 fn 字符在窗口中被替换为稍微卷曲的小写字母 f 缓冲区已正确保存 但这非常烦人 尤其是当我以艰难的方式发现该功
  • 如何在组织模式下关闭公司模式?

    我正在使用 spacemacs 并尝试在组织模式下关闭公司模式 同时将其保留在其他主要模式中 我尝试过以下方法 global company mode not org mode 但它不起作用 禁用自org mode hook 此方法几乎适用
  • 设置自动完成以处理语义

    我在 Emacs 中的自动完成包方面遇到问题 目前我已经启动并运行了 cedet 并具有适当的自动完成功能 但自动完成包有一些奇怪的行为 它不会使用语义 参议员 的数据库 直到我显式访问包含文件并创建 C u M x bovinate 然后
  • 减少通过管道传输至 Emacs

    当查看 Less 的管道输出时 有时我希望能够在 Emacs 中查看它 以便获得语法突出显示并使用 emacs 命令进行搜索 标记 复制等 我看到 Less 有一个v可用于打开当前查看的文件的命令 EDITOR 不幸的是 这在查看管道输入时
  • Lisp:CHAR 既未声明也未绑定

    几天前我决定学习 通用 Lisp 我意识到这是一个相当新手的问题 对于至少有一点经验的人来说可能非常微不足道 所以基本上发生的事情是我加载 Emacs Slime 通过 Lisp in a Box 并编写我的程序 包括在下面 defun l
  • Org LaTeX 预览在视网膜显示屏上模糊

    我所有的数学 科学笔记都使用 Emacs 24 4 org latex preview太棒了 但最近 我升级到了配备视网膜显示屏的 MacBook Pro 现在我发现组织模式下的所有方程都 模糊了 有什么设置可以更改为高分辨率吗 这是一个屏
  • 如何在 Emacs 中保存所有文件(或保存所有缓冲区)?

    C x C s saves only the current buffer 如何保存所有文件 或所有缓冲区 Press C x s and then choose for saving all buffers
  • 从 org-mode 导出 html:自定义日期格式

    我正在将 org 文件导出为 html 我在 Emacs 24 中使用 Org mode 7 9 3f 如何在帖子中获得自定义时间格式 我尝试将变量 org export html postamble format 设置为 setq org
  • 通过链接进入 git-repo,无需冗长的对话框

    In a directory I have symbolic links into a git administered directory all under Linux Every time I want to e dit such a
  • 组织模式下的内联代码

    Markdown 允许embedded code 这怎么能在org mode 我了解源代码块 begin example blah blah end example 但我想要的是这样的 显然 具有正确的语法 我不知道 This is emb

随机推荐