ahyatt / ekg

The emacs knowledge graph, app for notes and structured data.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Trashed tags are not completely removed?

qingshuizheng opened this issue · comments

Hi @ahyatt ,

Seems ekg-remove-unused-tags doesn't remove trashed tags completely (see sceenshot).

(ekg-tags) inside ekg-remove-unused-tags doesn't cover these trashed tags, since it contains a predicate (and (not (ekg-tag-trash-p tag)) (not (equal tag ekg-draft-tag))).

It should be replaced with (triples-subjects-of-type ekg-db 'tag), so that all tags are retrieved for ekg-tag-used-p to filter.

Thus:

Before:

(defun ekg-remove-unused-tags ()
  "Remove all tags that are not used and have no info."
  (cl-loop for tag in (seq-filter (lambda (tag) (not (ekg-tag-used-p tag))) (ekg-tags))
           do
           (ekg-tag-delete tag)))

After:

(defun ekg-remove-unused-tags ()
  "Remove all tags that are not used and have no info."
  (ekg-connect)
  (cl-loop for tag in (seq-filter
                       (lambda (tag) (not (ekg-tag-used-p tag)))
                       (triples-subjects-of-type ekg-db 'tag))
           do
           (ekg-tag-delete tag)))

Screenshot: remaining trashed tags right after a fresh ekg-clean-db.
iShot_2024-01-05_18 54 38