org-mode怎么将spare tree匹配的所有内容导出到一个新的buffer里面






(defun dc|org-sparse-tree-to-buffer (todo-only match  &optional
                                            match-body parents-body)
"Output sparse tree to file only header note "
(let* ((match match))
    (dc|org-sparse-tree todo-only match match-body parents-body)
    (org-copy-visible 1 (point-max))
    (with-current-buffer (generate-new-buffer "*sparse tree*")


(defun dc|org-sparse-tree (todo-only match &optional
                                            match-body parents-body)
"Create a custom sparse tree that only shows matched headings and parents.
For TODO-ONLY and MATCH see `org-match-sparse-tree'.
If MATCH-BODY is non-nil the bodies of the matches are shown.
If PARENTS-BODY is non-nil the bodies of the parents are shown."
;; Create the sparse tree.
(let ((org-highlight-sparse-tree-matches t))
    (org-match-sparse-tree todo-only match))
(let ((pt-first (save-excursion
                    (- (point) 2)))
        (hls org-occur-highlights))
    ;; Hide everything.
    (outline-flag-region pt-first (point-max) t)
    ;; For each occur highlight overlay (the matches).
    (dolist (hl hls)
        (goto-char (overlay-start hl))
        ;; Unhide match.
        (when match-body (outline-show-entry))
        ;; Unhide parents.
        (while (org-up-heading-safe)
        (when parents-body (outline-show-entry))))))
;; Hide all archived subtrees again.
(org-hide-archived-subtrees (point-min) (point-max)))


你可以使用扩展 org-ql绝对很好用, 就是为了这个目的而生的。配合相应差的插件 org-sidebar 就是你要的。