(fix)tags: fix tags migration (#1653)

- prevent botching of existing filetags
- insert new tag list using `org-make-tag-string` (colon-delimited) for resilience

Fixes #1642.
This commit is contained in:
Jethro Kuan
2021-07-21 23:25:04 +08:00
committed by GitHub
parent 2fe233ffa0
commit 1aba91eacd

View File

@ -130,7 +130,11 @@ This will take a while. Are you sure you want to do this?")
;; Replace #+roam_tags into #+filetags ;; Replace #+roam_tags into #+filetags
(org-with-point-at 1 (org-with-point-at 1
(let* ((roam-tags (org-roam-migrate-get-prop-list "ROAM_TAGS")) (let* ((roam-tags (org-roam-migrate-get-prop-list "ROAM_TAGS"))
(file-tags (org-roam-migrate-get-prop-list "FILETAGS")) (file-tags (cl-mapcan (lambda (value)
(cl-mapcan
(lambda (k) (org-split-string k ":"))
(split-string value)))
(org-roam-migrate-get-prop-list "FILETAGS")))
(tags (append roam-tags file-tags)) (tags (append roam-tags file-tags))
(tags (seq-map (lambda (tag) (tags (seq-map (lambda (tag)
(replace-regexp-in-string (replace-regexp-in-string
@ -139,7 +143,7 @@ This will take a while. Are you sure you want to do this?")
tag)) tags)) tag)) tags))
(tags (seq-uniq tags))) (tags (seq-uniq tags)))
(when tags (when tags
(org-roam-migrate-prop-set "filetags" (string-join tags " ")))) (org-roam-migrate-prop-set "filetags" (org-make-tag-string tags))))
(let ((case-fold-search t)) (let ((case-fold-search t))
(org-with-point-at 1 (org-with-point-at 1
(while (re-search-forward "^#\\+roam_tags:" (point-max) t) (while (re-search-forward "^#\\+roam_tags:" (point-max) t)