Emacs组织模式删除树的内容(或复制没有内容的树结构)

Emacs组织模式删除树的内容(或复制没有内容的树结构),emacs,org-mode,Emacs,Org Mode,我正在尝试制作一棵自然规划树(遵循David Allen的“完成事情”建议),它看起来像: * Natural Planning Model ** ITEM 1 *** Purpose and Principles (Why) *** Outcome Visioning *** Brainstorming *** Organizing *** Identifying next actions ** ITEM 2... ** ITEM 3... 我想将项目1的大纲结构复制到新项目中。但问题是

我正在尝试制作一棵自然规划树(遵循David Allen的“完成事情”建议),它看起来像:

* Natural Planning Model

** ITEM 1
*** Purpose and Principles (Why)
*** Outcome Visioning
*** Brainstorming
*** Organizing
*** Identifying next actions

** ITEM 2...
** ITEM 3...
我想将项目1的大纲结构复制到新项目中。但问题是,我已经在项目1的子树中填充了大量信息


我的一般问题是:有没有一种方法可以删除树的内容而不是它的标题(以*开头的行)?类似地,有没有一种方法可以复制树的结构而不复制其内容?

我不记得在Org中有这样的命令,但您可以 你自己的很容易

(defun org-copy-subtree-headings-as-kill ()
  "Copy headings of current subtree as kill."
  (interactive)
  (save-excursion
    (org-back-to-heading)
    (let* ((el (org-element-at-point))
           (beg (org-element-property :begin el))
           (end (org-element-property :end el))
           (tree (buffer-substring-no-properties beg end)))
      (with-temp-buffer
        (insert tree)
        (goto-char (point-min))
        (while (not (eobp))
          (if (looking-at-p "^\\*")
              (forward-line)
            (delete-region (point-at-bol) (1+ (point-at-eol)))))
        (kill-new (buffer-string))))))
此外,如果这些标题通常是同一组标题,您可以 使用yasnippet模板


要从当前树中删除内容(而不是复制标题),您只需缩小到子树,并使用
^\*

调用
keep lines
,也许您正在寻找M-x org copy visible,此时只显示子树标题,而不显示内容。这确实有效。谢谢