Add a function to extract headlines by tags
This commit is contained in:
parent
b3766d804a
commit
5fb99b5180
1 changed files with 15 additions and 0 deletions
|
@ -535,3 +535,18 @@
|
||||||
;; :after org
|
;; :after org
|
||||||
;; :config
|
;; :config
|
||||||
;; (append '((restclient . t)) org-babel-load-languages))
|
;; (append '((restclient . t)) org-babel-load-languages))
|
||||||
|
|
||||||
|
(defun mk/extract-headlines-by-tag (tag)
|
||||||
|
"Extract headlines from current buffer by TAG."
|
||||||
|
(interactive "sEnter tag: ")
|
||||||
|
(save-excursion
|
||||||
|
(let ((result-buffer (generate-new-buffer (concat "*Extracted Headlines " tag "*"))))
|
||||||
|
(with-current-buffer result-buffer
|
||||||
|
(org-mode)
|
||||||
|
(insert "* Extracted Headlines by Tag: " tag " *\n\n"))
|
||||||
|
(goto-char (point-min))
|
||||||
|
(while (re-search-forward (concat "^\\*+\\s-+\\(.*?\\)\\s-+:\\(" tag "\\):") nil t)
|
||||||
|
(let ((headline (match-string 0)))
|
||||||
|
(with-current-buffer result-buffer
|
||||||
|
(insert headline "\n\n"))))
|
||||||
|
(switch-to-buffer result-buffer))))
|
||||||
|
|
Loading…
Add table
Reference in a new issue