branch: externals/denote
commit e711b1610fb6186734d13b0a444162e6c243c472
Author: Protesilaos Stavrou <[email protected]>
Commit: Protesilaos Stavrou <[email protected]>
Add TEMPORARY command to migrate YAML tags
This is due to the changes we made to the format of the YAML front
matter where tags are now written as a standard comma-separated list of
strings (per commit cb9af65).
Same idea as with commit 5c2237e.
---
denote.el | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/denote.el b/denote.el
index 6dec2bdedd..7d858d7b34 100644
--- a/denote.el
+++ b/denote.el
@@ -2248,5 +2248,36 @@ of Denote. Written on 2022-08-10 for version 0.5.0."
((denote--edit-front-matter-p file)))
(denote--rewrite-keywords file kw)))))
+;;;###autoload
+(defun denote-migrate-old-markdown-yaml-tags ()
+ "Rewrite Markdown YAML tags value as comma-separated strings.
+
+Change the tags from:
+
+ tags: one two
+
+To the standard format of:
+
+ tags: [\"one\", \"two\"]
+
+Denote used to format filetags with two spaces between them, but
+this is not supported by YAML.
+
+The rewrite DOES NOT SAVE BUFFERS. The user is expected to
+review the changes, such as by using `diff-buffer-with-file'.
+Multiple buffers can be saved with `save-some-buffers' (check its
+doc string).
+
+This command is provided for the convenience of the user. It
+shall be deprecated and eventually removed from future versions
+of Denote. Written on 2022-08-10 for version 0.5.0."
+ (interactive)
+ (when-let (((yes-or-no-p "Rewrite filetags in Org files to use colons
(buffers are NOT saved)?"))
+ (files (denote--migrate-type-files "md")))
+ (dolist (file files)
+ (when-let* ((kw (denote--front-matter-keywords-to-list file))
+ ((denote--edit-front-matter-p file)))
+ (denote--rewrite-keywords file kw)))))
+
(provide 'denote)
;;; denote.el ends here