我维护了一个包含很多草稿帖子的组织文件(这是该文件的链接)。我的工作流程是处理草稿,准备发布后,将其复制到新的组织文件中,然后将其推送到基于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 …Run Code Online (Sandbox Code Playgroud)