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

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

[elpa] externals/tomelr ae983711be 78/84: fix: Auto-stringify symbols li


From: ELPA Syncer
Subject: [elpa] externals/tomelr ae983711be 78/84: fix: Auto-stringify symbols like 1.10.1
Date: Tue, 3 May 2022 09:58:16 -0400 (EDT)

branch: externals/tomelr
commit ae983711be15d95abd22ae4d7b8c116031de60a0
Author: Kaushal Modi <kaushal.modi@gmail.com>
Commit: Kaushal Modi <kaushal.modi@gmail.com>

    fix: Auto-stringify symbols like 1.10.1
---
 test/tscalar.el |  4 ++++
 tomelr.el       | 11 ++++++++++-
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/test/tscalar.el b/test/tscalar.el
index e6ede6d85a..cb93af2c27 100644
--- a/test/tscalar.el
+++ b/test/tscalar.el
@@ -83,6 +83,8 @@
                ((string2 . "Roses are red\nViolets are blue")) ;Newline in 
string
                ((string3 . "\"Hello!\"")) ;Quote in string
                ((string4 . "Line 1\n\nLine 3\n\n  Line 5 with 2 space 
indentation\n\nLine 7")) ;Blank lines in string
+               ((audio . "audio path with space.mp3")) ;String with 
non-alphameric chars like space and period
+               ((version . 1.10.1))
                ))
         (ref '(
                "string1 = \"Roses are red\""
@@ -99,6 +101,8 @@ Line 3
   Line 5 with 2 space indentation
 
 Line 7\"\"\""
+               "audio = \"audio path with space.mp3\""
+               "version = \"1.10.1\""
                ))
         out)
     (dolist (el inp)
diff --git a/tomelr.el b/tomelr.el
index 3a93c750c8..35cfd1f142 100644
--- a/tomelr.el
+++ b/tomelr.el
@@ -201,6 +201,7 @@ Possible values of TYPE are `normal-key', `table-key',
 `table-array-key', `keyword', or nil.
 
 Return nil if OBJECT cannot be encoded as a TOML string."
+  ;; (message "[tomelr--print-stringlike DBG] object = %S" object)
   (let ((sym-name (cond ((and type (stringp object))
                          ;; https://toml.io/en/v1.0.0#keys
                          ;; Bare keys may only contain ASCII letters, ASCII 
digits,
@@ -216,7 +217,15 @@ Return nil if OBJECT cannot be encoded as a TOML string."
                         ((keywordp object)
                          (string-trim-left (symbol-name object) ":"))
                         ((symbolp object)
-                         (symbol-name object)))))
+                         (let ((str (symbol-name object)))
+                           (unless (or ;; RFC 3339 formatted date-time with 
offset
+                                       (string-match-p 
tomelr--date-time-regexp str)
+                                       (string-match-p "\\`[A-Za-z0-9_-]+\\'" 
str))
+                             ;; Wrap string in double-quotes if it's
+                             ;; neither a date-time symbol not
+                             ;; contains only A-Za-z0-9_- chars.
+                             (setq str (format "\"%s\"" str)))
+                           str)))))
     (when (member type '(table-key table-array-key))
       ;; (message "[tomelr--print-stringlike DBG] %S is symbol, type = %S, 
depth = %d"
       ;;          object type tomelr--print-indentation-depth)



reply via email to

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