ahyatt / ekg

The emacs knowledge graph, app for notes and structured data.
GNU General Public License v3.0
230 stars 19 forks source link

Trashed tags are not completely removed? #128

Closed qingshuizheng closed 9 months ago

qingshuizheng commented 9 months ago

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