mirror of
https://github.com/org-roam/org-roam
synced 2025-08-01 12:17:21 -05:00
(fix)tags: splitting and joining of multiple filetags (#1705)
Current, when fetching file level org tags (from the #+filetags property), multiple tags are split based on the default `split-string` separator. This is incorrect because the org documentation says that multiple file-level tags should be separated by `:` (like headline level tags). This results in a improper splitting (aka no split) of the tag string into multiple tags. This leads to the inability to delete tags that are there. Similarly, when writing multiple filetags, the tags are joined by " " instead instead of ":" as mentioned in the org docs. This leads to improperly added tags where newly added tags would not be recognized by org. This PR fixes both problems, parsing is done by string splitting on ":" (with the `OMIT-NULLS` parameter set to true so you don't get a null values from the fact tags start and end with `:`). Joining multiple tags is now done with the `org-make-tag-string` function instead of manually joining on space. These changes result in the ability to add and remove file level tags such that the resulting value of the `#+filetags` property is a valid tag string.
This commit is contained in:
@ -1038,8 +1038,8 @@ If the property is already set, it's value is replaced."
|
||||
(if (= (org-outline-level) 0)
|
||||
(let ((current-tags (split-string (or (cadr (assoc "FILETAGS"
|
||||
(org-collect-keywords '("filetags"))))
|
||||
""))))
|
||||
(org-roam-set-keyword "filetags" (string-join (seq-uniq (append tags current-tags)) " ")))
|
||||
"") ":" 't)))
|
||||
(org-roam-set-keyword "filetags" (org-make-tag-string (seq-uniq (append tags current-tags)))))
|
||||
(org-set-tags (seq-uniq (append tags (org-get-tags)))))
|
||||
tags)))
|
||||
|
||||
@ -1052,10 +1052,10 @@ If the property is already set, it's value is replaced."
|
||||
(if (= (org-outline-level) 0)
|
||||
(let* ((current-tags (split-string (or (cadr (assoc "FILETAGS"
|
||||
(org-collect-keywords '("filetags"))))
|
||||
(user-error "No tag to remove"))))
|
||||
(user-error "No tag to remove")) ":" 't))
|
||||
(tags (or tags (completing-read-multiple "Tag: " current-tags))))
|
||||
(org-roam-set-keyword "filetags"
|
||||
(string-join (seq-difference current-tags tags #'string-equal) " ")))
|
||||
(org-make-tag-string (seq-difference current-tags tags #'string-equal))))
|
||||
(let* ((current-tags (or (org-get-tags)
|
||||
(user-error "No tag to remove")))
|
||||
(tags (completing-read-multiple "Tag: " current-tags)))
|
||||
|
Reference in New Issue
Block a user