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

org

#1

我用org-match-sparse-tree来匹配我之前打的一些标签

请问我怎么样才能将我的这些匹配标签的内容导出到一个独立的buffer中?

或者说有什么插件可以做到这一点?可以的话请推荐一下


#2
;;;###autoload
(defun dc|org-sparse-tree-to-buffer (todo-only match  &optional
                                            match-body parents-body)
"Output sparse tree to file only header note "
(org-export-with-buffer-copy
(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*")
    (yank))
    ))
)

;; https://emacs.stackexchange.com/questions/52057/export-only-visible-entries-of-sparse-tree/52117?noredirect=1#comment83577_52117

;;;###autoload
(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
                    (org-first-headline-recenter)
                    (- (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)
    (save-excursion
        (goto-char (overlay-start hl))
        ;; Unhide match.
        (outline-show-heading)
        (when match-body (outline-show-entry))
        ;; Unhide parents.
        (while (org-up-heading-safe)
        (outline-show-heading)
        (when parents-body (outline-show-entry))))))
;; Hide all archived subtrees again.
(org-hide-archived-subtrees (point-min) (point-max)))

#3

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