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

Emacs组织模式-如何将子树重新填充到新文件?,emacs,elisp,org-mode,Emacs,Elisp,Org Mode,我维护一个包含大量草稿帖子的组织文件()。我的工作流程是写一篇草稿文章,一旦它准备好发表,我就把它复制到一个新的组织文件中,然后推送到我的鹈鹕网站上 我想做的是,使用refile命令帮助我将表示帖子的子树移动到新的帖子文件中 我的研究让我在stack overflow找到了一些答案。我实现了这个功能: (require 'org-element) (defun me/org-file-from-subtree (&optional name) "Cut the subtree curr

我维护一个包含大量草稿帖子的组织文件()。我的工作流程是写一篇草稿文章,一旦它准备好发表,我就把它复制到一个新的组织文件中,然后推送到我的鹈鹕网站上

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

我的研究让我在stack overflow找到了一些答案。我实现了这个功能:

(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))))
资料来源:乔纳森·利奇·佩平的回答

这个函数可以工作,但它不包含我试图重新填充的子树中定义的脚注。你知道我怎样才能把脚注和子树剪在一起吗

更新: 为我试图实现的目标添加一个示例。给定此组织文件:

* 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
现在,我想做的是将第一篇文章连同它的脚注(fn:1)一起移动到一个新文件中

谢谢。亚尼夫


(我应该说,我是emacs新手,仍然不太理解我在init中输入的lisp代码……所以我可能缺少一些非常基本的东西)

请参阅以下详细示例,了解如何以编程方式使用
org archive子树
/
org archive location
/
org archive save context info
将子树移动到您想要的任何位置:我不使用脚注,因此,您需要查看
org archive subtree
是否以满足您需求的方式处理它们。如果只是一个扩展被选中的区域的问题,那么考虑修改你的帖子,以提供一个详细的例子,说明你试图剪切/移动的是什么,这样人们就可以使用你的测试数据来创建一个工作解决方案。不幸的是,
org archive子树
没有选择带有子树的脚注。我建议建议
org archive子树
在末尾运行一个函数,将脚注信息粘贴到目标文件中所需的位置
(let(footnote)(保存偏移(org返回标题t)(org缩小到子树)(while(向前搜索“\\[fn:[0-9]+\\]”nil t)(push(cons(缓冲子串无属性(匹配开始0)(匹配结束0))nil)脚注)(加宽)(子树的组织结束t t)(setq脚注(mapcar(lambda(x)(和(向前搜索(car x)nil t nil)(cons(car x)(缓冲子串无属性(匹配开始0)(eol处的点))脚注)))脚注)
谢谢@lawlist。我不确定我是否知道如何修复
组织存档子树。您是否有机会建议如何将代码片段添加到我用于重新填充到新文件的函数中(请参见我的原始问题-
me/org file from subtree
)?