【问题标题】:ISO transclusion in emacs org-modeemacs org-mode 中的 ISO 嵌入
【发布时间】:2013-02-26 00:50:34
【问题描述】:

问:有什么办法可以在 emacs org-mode 中进行嵌入?

通过“嵌入”,我的意思是,在 fileA.org 和 fileB.org 中的某个位置,“包括”fileInc.org - 并让来自 fileInc.org 的树出现在这两个地方。其实出现,不只是挂。 (可能有条件包含、转换,例如嵌套深度(***数)。

我知道#setupfile,但这似乎只适用于模式,而不适用于真实文本。

我知道http://orgmode.org/manual/Include-files.html, 但 AFAIK 他们只在出口时工作。

我正在寻找可以在普通 emacs 组织模式缓冲区中工作的东西。 (实际上,在非 org-mode 缓冲区中工作的东西可能会很好。)

我有想要包含在多个文件中的样板。

这样的东西存在吗?

【问题讨论】:

    标签: emacs include org-mode transclusion


    【解决方案1】:

    嗯...我不认为有这样的东西存在,但是编写一个动态块来做到这一点很容易。以下 elisp 对我有用:

    (defun org-dblock-write:transclusion (params)
      (progn
        (with-temp-buffer
          (insert-file-contents (plist-get params :filename))
          (let ((range-start (or (plist-get params :min) (line-number-at-pos (point-min))))
                (range-end (or (plist-get params :max) (line-number-at-pos (point-max)))))
            (copy-region-as-kill (line-beginning-position range-start)
                                 (line-end-position range-end))))
        (yank)))
    

    然后要包含给定文件的行范围,您可以像这样创建一个动态块:

     #+BEGIN: transclusion :filename "~/testfile.org" :min 2 :max 4
     #+END:
    

    并使用C-c C-x C-u 自动填充。跳过最小和最大参数以包含整个文件。请注意,您可以将 org-update-all-dblocks 绑定到挂钩,以便在您访问文件或保存时更新此范围。

    有关动态块的更多信息,请访问http://orgmode.org/org.html#Dynamic-blocks。希望这会有所帮助!

    【讨论】:

    • 有没有人调整这个来占据特定的头条新闻?我还没有发现任何公开的东西(如果有人确实找到或制作了类似的东西,我在这里发布了一个相关问题emacs.stackexchange.com/questions/12562/…
    • 如果能像#+INCLUDE 那样使用标签会很好。
    • 能否请您解释一下,函数名称中的列是什么意思?
    【解决方案2】:

    您可能对 org-transclusion 包感兴趣。你可以找到 Github 仓库here

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-01-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-07-10
      相关资源
      最近更新 更多