Emacs组织模式-如何将子树重新归档到新文件?

yan*_*niv 5 emacs elisp org-mode

我维护了一个包含很多草稿帖子的组织文件(这是该文件的链接)。我的工作流程是处理草稿,准备发布后,将其复制到新的组织文件中,然后将其推送到基于Pelican的博客中

我想做的是使用refile命令来帮助我将代表帖子的子树移动到新的帖子文件中。

我的研究使我对堆栈溢出的答案不多。我实现了这个功能:

(require 'org-element)

(defun me/org-file-from-subtree (&optional name)
"Cut the subtree currently being edited and create a new file
from it.

If called with the universal argument, prompt for new filename,
otherwise use the subtree title."
(interactive "P")
(org-back-to-heading)
(let ((filename (cond
               (current-prefix-arg
                (expand-file-name
                 (read-file-name "New file name: ")))
               (t
                (concat
                 (expand-file-name
                  (org-element-property :title
                                        (org-element-at-point))
                  default-directory)
                 ".org")))))
(org-cut-subtree)
(find-file-noselect filename)
(with-temp-file filename
  (org-mode)
  (yank))))
Run Code Online (Sandbox Code Playgroud)

资料来源:乔纳森·里奇·佩平在这里的回答。

此函数有效,但不包含我要重新归档的子树中定义的脚注。知道如何与子树一起删除脚注吗?

更新: 添加一个示例,我正在尝试实现。鉴于此组织文件:

* Drafts
** First Post
Lorem ipsum dolor sit amet, fermentum vulputate laoreet eligendi,[fn:1]
magna wisi elit scelerisque

** Second Post
Ultrices natoque sollicitudin duis curabitur, 
quam pellentesque ante aliquam nulla aenean, 
dui egestas ipsum adipiscing, sem nulla sit nisl, 
parturient[fn:2] habitasse ac amet at eget suspendisse.

* Footnotes

[fn:1] This is a footnote for the first post 

[fn:2] This is a footnote for the second post
Run Code Online (Sandbox Code Playgroud)

现在,我想做的是将第一篇文章及其脚注(fn:1)移到一个新文件中。

谢谢。亚尼夫

(我应该说我是emacs的新手,但仍然不真正理解我在init中放入的lisp代码……因此我可能会错过一些非常基本的东西)