emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/denote ea7d079c2d 1/3: Handle all keywords in front mat


From: ELPA Syncer
Subject: [elpa] externals/denote ea7d079c2d 1/3: Handle all keywords in front matter extraction
Date: Mon, 1 Aug 2022 02:57:32 -0400 (EDT)

branch: externals/denote
commit ea7d079c2d2f1d1ab932c5b1147a8492a703ddc1
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>

    Handle all keywords in front matter extraction
    
    This is an attempt to address our TODO item on the matter.  Right now we
    insert filetags separated by two spaces, though the Org manual only
    shows tags that are separated by the colon sign.  Perhaps we should do
    the same in Denote to avoid possible confusion.
---
 denote.el | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/denote.el b/denote.el
index abe508ca58..3fde6125e3 100644
--- a/denote.el
+++ b/denote.el
@@ -670,19 +670,19 @@ treatment)."
         (denote--format-markdown-keywords kw)
       (mapconcat #'downcase kw "  "))))
 
-;; TODO 2022-07-29: For now, for Org files, this functions only supports
-;; keywords separated with 2 spaces (as created by
-;; `denote--file-meta-keywords'), but we should try to handle all valid
-;; Org syntaxes.
 (defun denote--extract-keywords-from-front-matter (file &optional type)
   "Extract keywords from front matter of FILE with TYPE.
 This is the reverse operation of `denote--file-meta-keywords'."
   (let ((fm-keywords (denote--retrieve-value-keywords file)))
-    (if (or (eq type 'markdown-toml) (eq type 'markdown-yaml) (eq type 'md))
-        (split-string
-         (string-trim-right (string-trim-left fm-keywords "\\[") "\\]")
-         ", " t "\s*\"\s*")
-      (split-string fm-keywords "  " t " "))))
+    (cond
+     ((or (eq type 'markdown-toml) (eq type 'markdown-yaml) (eq type 'md))
+      (split-string
+       (string-trim-right (string-trim-left fm-keywords "\\[") "\\]")
+       ", " t "\s*\"\s*"))
+     ((eq type 'text)
+      (split-string fm-keywords "  " t " "))
+     (t
+      (split-string fm-keywords "\\([:]\\|\s\s\\)" t "\\([:]\\|\s\\)")))))
 
 (defvar denote-toml-front-matter
   "+++



reply via email to

[Prev in Thread] Current Thread [Next in Thread]