gpt4 book ai didi

org-mode - 枚举 org-mode 下的所有标签

转载 作者:行者123 更新时间:2023-12-02 21:44:32 27 4
gpt4 key购买 nike

如何在组织模式文件中生成所有标签的枚举列表(例如 :tag:)?假设我有一个以下形式的列表:

* Head1        :foo:bar:
** Subhead1 :foo:
* Head2
** Subhead2 :foo:bar:

我想生成此文件中所有标签的列表以及每个标签的使用次数。说一些类似的话,

:foo:    3
:bar: 2

最佳答案

这是一个较短的版本。

(defun get-tag-counts ()
(let ((all-tags '()))
(org-map-entries
(lambda ()
(let ((tag-string (car (last (org-heading-components)))))
(when tag-string
(setq all-tags
(append all-tags (split-string tag-string ":" t)))))))


;; now get counts
(loop for tag in (-uniq all-tags)
collect (cons tag (cl-count tag all-tags :test 'string=)))))

关于org-mode - 枚举 org-mode 下的所有标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24330980/

27 4 0