[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/tomelr 10a1994aed 51/84: feat: Support (lightly tested)
From: |
ELPA Syncer |
Subject: |
[elpa] externals/tomelr 10a1994aed 51/84: feat: Support (lightly tested) nested TOML Table Arrays |
Date: |
Tue, 3 May 2022 09:58:13 -0400 (EDT) |
branch: externals/tomelr
commit 10a1994aedcbd95c35096b257cf1e9e6fd4554cb
Author: Kaushal Modi <kaushal.modi@gmail.com>
Commit: Kaushal Modi <kaushal.modi@gmail.com>
feat: Support (lightly tested) nested TOML Table Arrays
---
README.org | 14 ++++++++------
test/ttable-array.el | 40 ++++++++++++++++++++--------------------
tomelr.el | 23 +++++++++++++++--------
3 files changed, 43 insertions(+), 34 deletions(-)
diff --git a/README.org b/README.org
index e44d71aea8..7a03d4bd7d 100644
--- a/README.org
+++ b/README.org
@@ -18,7 +18,7 @@ the Emacs core library
[[https://git.savannah.gnu.org/cgit/emacs.git/tree/lisp/j
It will then be gradually refactored so that it meets the
specification defined below.
-* Library Completion Status [5/7]
+* Library Completion Status [6/7]
- [X] Scalar
- [X] Boolean
- [X] Integer
@@ -32,9 +32,9 @@ specification defined below.
- [X] Tables
- [X] Basic Tables
- [X] Nested Tables
-- [-] Array of Tables
+- [X] Array of Tables
- [X] Basic Array of Tables
- - [ ] Nested Array of Tables
+ - [X] Nested Array of Tables
- [ ] Property Lists
* Specification and Conversion Examples
[[https://scripter.co/defining-tomelr/][Companion blog post]]
@@ -567,7 +567,8 @@ See
[org#Drawers](https://www.gnu.org/software/emacs/manual/html_mono/org.html#D
]
}
#+end_example
-*** Nested Array of Tables
+*** DONE Nested Array of Tables
+CLOSED: [2022-04-30 Sat 01:32]
**** S-expression
#+begin_src emacs-lisp :eval no :noweb-ref nested-table-arrays
'((fruits . (((name . "apple")
@@ -584,13 +585,14 @@ See
[org#Drawers](https://www.gnu.org/software/emacs/manual/html_mono/org.html#D
<<nested-table-arrays>>)
#+end_src
+#+RESULTS:
#+begin_src toml
[[fruits]]
name = "apple"
- [fruits.physical] # subtable
+ [fruits.physical]
color = "red"
shape = "round"
- [[fruits.varieties]] # nested array of tables
+ [[fruits.varieties]]
name = "red delicious"
[[fruits.varieties]]
name = "granny smith"
diff --git a/test/ttable-array.el b/test/ttable-array.el
index 7247f9d132..2b3deb3851 100644
--- a/test/ttable-array.el
+++ b/test/ttable-array.el
@@ -86,13 +86,13 @@ See
[org#Drawers](https://www.gnu.org/software/emacs/manual/html_mono/org.html#D
((fruits . (((name . "apple")
(varieties . (((name . "red delicious"))
((name . "granny smith"))))))))
- ;; ((fruits . (((name . "apple")
- ;; (physical . ((color . "red")
- ;; (shape . "round")))
- ;; (varieties . (((name . "red delicious"))
- ;; ((name . "granny smith")))))
- ;; ((name . "banana")
- ;; (varieties . (((name . "plantain"))))))))
+ ((fruits . (((name . "apple")
+ (physical . ((color . "red")
+ (shape . "round")))
+ (varieties . (((name . "red delicious"))
+ ((name . "granny smith")))))
+ ((name . "banana")
+ (varieties . (((name . "plantain"))))))))
))
(ref '(
"[[fruits]]
@@ -106,19 +106,19 @@ See
[org#Drawers](https://www.gnu.org/software/emacs/manual/html_mono/org.html#D
name = \"red delicious\"
[[fruits.varieties]]
name = \"granny smith\""
- ;; "[[fruits]]
- ;; name = \"apple\"
- ;; [fruits.physical]
- ;; color = \"red\"
- ;; shape = \"round\"
- ;; [[fruits.varieties]]
- ;; name = \"red delicious\"
- ;; [[fruits.varieties]]
- ;; name = \"granny smith\"
- ;; [[fruits]]
- ;; name = \"banana\"
- ;; [[fruits.varieties]]
- ;; name = \"plantain\""
+ "[[fruits]]
+ name = \"apple\"
+ [fruits.physical]
+ color = \"red\"
+ shape = \"round\"
+ [[fruits.varieties]]
+ name = \"red delicious\"
+ [[fruits.varieties]]
+ name = \"granny smith\"
+[[fruits]]
+ name = \"banana\"
+ [[fruits.varieties]]
+ name = \"plantain\""
))
out)
(dolist (el inp)
diff --git a/tomelr.el b/tomelr.el
index 0c97552b62..4611a92b31 100644
--- a/tomelr.el
+++ b/tomelr.el
@@ -58,9 +58,6 @@ Dictates repetitions of
`tomelr-encoding-default-indentation'.")
This variable is used for both TOML Tables and Arrays of TOML
Tables.")
-(defvar tomelr--print-table-array-key ""
- "Internal variable used to save the TOML Table Array name.")
-
(defvar tomelr--print-keyval-separator " = "
"String used to separate key-value pairs during encoding.")
@@ -242,9 +239,7 @@ Return nil if OBJECT cannot be encoded as a TOML string."
((equal type 'table)
(princ (format "[%s]" (string-join tomelr--print-table-hierarchy "."))))
((equal type 'table-array)
- (let ((tta-name (format "[[%s]]" (string-join
tomelr--print-table-hierarchy "."))))
- (setq tomelr--print-table-array-key tta-name)
- (princ tta-name)))
+ (princ (format "[[%s]]" (string-join tomelr--print-table-hierarchy
"."))))
((stringp object)
;; (message "[tomelr--print-stringlike DBG] %S is string" object)
(tomelr--print-string sym-name))
@@ -423,6 +418,19 @@ Definition of a TOML Table Array (TTA):
nil))))
ttap))
+(defun tomelr--print-tta-key ()
+ "Print TOML Table Array key."
+ ;; (message "[tomelr--print-array DBG] depth = %d"
tomelr--print-indentation-depth)
+ ;; Throw away table keys collected at higher depths, if
+ ;; any, from earlier runs of this function.
+ (setq tomelr--print-table-hierarchy
+ (seq-take tomelr--print-table-hierarchy
+ (1+ tomelr--print-indentation-depth)))
+
+ (tomelr--print-indentation)
+ (insert
+ (format "[[%s]]" (string-join tomelr--print-table-hierarchy "."))))
+
(defun tomelr--print-array (array)
"Insert a TOML representation of ARRAY at point.
See `tomelr-encode-array' that returns the same as a string."
@@ -435,8 +443,7 @@ See `tomelr-encode-array' that returns the same as a
string."
(mapc (lambda (elt)
(if first
(setq first nil)
- (tomelr--print-indentation)
- (insert tomelr--print-table-array-key))
+ (tomelr--print-tta-key))
(tomelr--print elt))
array))))
(t
- [elpa] externals/tomelr cff1f8aa89 38/84: fix: Support TOML tables arrays specified as plist vector, (continued)
- [elpa] externals/tomelr cff1f8aa89 38/84: fix: Support TOML tables arrays specified as plist vector, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 4c419bcee2 37/84: fix: Support TOML tables specified as plists, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr baf81228bc 45/84: fix: Correct the spec for nested array of tables, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 4dda8e6be3 46/84: chore: Style edits in a test, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 5959b90ffa 44/84: fix: Don't let TOML tables be recognized as TOML tables arrays, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr b64eb07e99 49/84: fix: Detect TT with sub-tables correctly, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 4386d99a85 65/84: refactor(minor): Use `tomelr--toml-table-p`, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 26f1fc2f3c 55/84: doc: Update the medley example, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr e2b313ca3b 52/84: feat: Implement everything planned in the initial spec, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 4434ccc64b 70/84: chore: Bump version, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 10a1994aed 51/84: feat: Support (lightly tested) nested TOML Table Arrays,
ELPA Syncer <=
- [elpa] externals/tomelr df0e73334f 59/84: Revert "doc: Update the medley example", ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr ec381fd723 79/84: fix: Auto-stringify and auto-quote symbol values, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr a25d952a17 77/84: feat: Auto-coerce string to integers, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr b2ba4c46b5 82/84: refactor: Minor code reorg, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr d86fd721ce 63/84: fix: Compatibility for emacs 26.3, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr a1fa47379e 84/84: chore: Add CHANGELOG generated using git cliff tool, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr ae983711be 78/84: fix: Auto-stringify symbols like 1.10.1, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 61397410af 01/84: Initial empty commit, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 846676a172 06/84: feat: Add plist example, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 8bc506af5a 02/84: Add s-exp->toml examples and spec, ELPA Syncer, 2022/05/03