branch: externals/tomelr commit a33dbd1286cd1f539c1e07bd21dc60464dd2f667 Author: Kaushal Modi <kaushal.m...@gmail.com> Commit: Kaushal Modi <kaushal.m...@gmail.com>
fix: Detect nested TTA correctly when not present in first TT key --- test/tinternal.el | 4 ++++ test/ttable-array.el | 12 +++++++++++- tomelr.el | 24 ++++++++++++++++++------ 3 files changed, 33 insertions(+), 7 deletions(-) diff --git a/test/tinternal.el b/test/tinternal.el index 29346b43bf..63e58a7fab 100644 --- a/test/tinternal.el +++ b/test/tinternal.el @@ -35,6 +35,10 @@ ((a . 1) (b . ((c . 3) (d . 4)))) + ;; Nested TTA + ((a . 1) + (b . (((c . 3)) + ((c . 300))))) ))) (dolist (el inp) (should (equal t (tomelr--toml-table-p el)))))) diff --git a/test/ttable-array.el b/test/ttable-array.el index 740cf10de9..7247f9d132 100644 --- a/test/ttable-array.el +++ b/test/ttable-array.el @@ -83,6 +83,9 @@ See [org#Drawers](https://www.gnu.org/software/emacs/manual/html_mono/org.html#D (let ((inp '( ((fruits . (((varieties . (((name . "red delicious")) ((name . "granny smith")))))))) + ((fruits . (((name . "apple") + (varieties . (((name . "red delicious")) + ((name . "granny smith")))))))) ;; ((fruits . (((name . "apple") ;; (physical . ((color . "red") ;; (shape . "round"))) @@ -91,7 +94,14 @@ See [org#Drawers](https://www.gnu.org/software/emacs/manual/html_mono/org.html#D ;; ((name . "banana") ;; (varieties . (((name . "plantain")))))))) )) - (ref '("[[fruits]] + (ref '( + "[[fruits]] + [[fruits.varieties]] + name = \"red delicious\" + [[fruits.varieties]] + name = \"granny smith\"" + "[[fruits]] + name = \"apple\" [[fruits.varieties]] name = \"red delicious\" [[fruits.varieties]] diff --git a/tomelr.el b/tomelr.el index 01b652b0f4..0c97552b62 100644 --- a/tomelr.el +++ b/tomelr.el @@ -292,12 +292,24 @@ Definition of a TOML Table (TT): ;; (when (listp elem) ;; (message " [tomelr--toml-table-p DBG] sub-elem 0 = %S, type = %S, len = %d" ;; (car elem) (type-of (car elem)) (safe-length (car elem)))) - (or (and (consp elem) - (= 1 (safe-length elem)) - (not (consp (car elem)))) - (and (listp elem) - (symbolp (car elem)) - (tomelr--toml-table-p (cdr elem))))) + (or + ;; Basic TT case + ;; ((a . 1) + ;; (b . 2)) + (and (consp elem) + (= 1 (safe-length elem)) + (not (consp (car elem)))) + (and (listp elem) + (symbolp (car elem)) + (or + ;; Nested TT case + ;; ((b . ((c . 3) + ;; (d . 4)))) + (tomelr--toml-table-p (cdr elem)) + ;; Nested TTA case + ;; ((b . (((c . 3)) + ;; ((c . 300))))) + (tomelr--toml-table-array-p (cdr elem)))))) object) t) (t