[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/tomelr ca9245038a 35/84: fix: Attempt to make tomelr--t
From: |
ELPA Syncer |
Subject: |
[elpa] externals/tomelr ca9245038a 35/84: fix: Attempt to make tomelr--toml-table-p more robust |
Date: |
Tue, 3 May 2022 09:58:10 -0400 (EDT) |
branch: externals/tomelr
commit ca9245038a74f272b246979271cbf2adef09eb89
Author: Kaushal Modi <kaushal.modi@gmail.com>
Commit: Kaushal Modi <kaushal.modi@gmail.com>
fix: Attempt to make tomelr--toml-table-p more robust
---
tomelr.el | 41 +++++++++++++++++++++++++++++++++++------
1 file changed, 35 insertions(+), 6 deletions(-)
diff --git a/tomelr.el b/tomelr.el
index 99fc776d99..fc504b5a29 100644
--- a/tomelr.el
+++ b/tomelr.el
@@ -250,12 +250,41 @@ Signal `tomelr-key-format' if it cannot be encoded as a
string."
;;;; Objects
(defun tomelr--toml-table-p (object)
- "Return non-nil if OBJECT can represent a TOML Table."
- ;; TODO: Need to find a robust way of detecting TOML tables.
- ;; (message "[tomelr--print-pair DBG] object type = %S" (type-of object))
- (and (mapp object)
- (consp object) ; object = ((KEY . VAL)) <- cons
- (consp (car object)))) ;(car object) = (KEY . VAL) <- also cons
+ "Return non-nil if OBJECT can represent a TOML Table.
+
+Definition of a TOML Table (TT):
+
+- OBJECT is TT if it is of type ((KEY1 . VAL1) (KEY2 . VAL2) ..)
+- If OBJECT if of type ((SYMBOL . (WHATEVER))), it's possible that
+ OBJECT is a nested TT. In that case, pass (WHATEVER) to
+ `tomelr--toml-table-p'."
+ (let (tablep)
+ ;; (message "[tomelr--toml-table-p DBG] object = %S, type = %S, mapp = %S,
length = %d"
+ ;; object (type-of object) (mapp object) (safe-length object))
+ (when (listp object)
+ ;; (message "[tomelr--toml-table-p DBG] first elem = %S, type = %S"
+ ;; (car object) (type-of (car object)))
+ (setq tablep
+ (cond
+ ((seq-every-p
+ ;; Ensure that every element in the `object' is a (KEY
+ ;; . VAL) kind of cons.
+ (lambda (elem)
+ ;; (message " [tomelr--toml-table-p DBG] elem = %S, type =
%S"
+ ;; elem (type-of elem))
+ ;; (when (listp elem)
+ ;; (message " [tomelr--toml-table-p DBG] sub-elem 0 = %S,
type = %S"
+ ;; (nth 0 elem) (type-of (nth 0 elem))))
+ (and (consp elem)
+ (= 1 (safe-length elem))))
+ object)
+ t)
+ ((and (listp (car object))
+ (symbolp (car (car object))))
+ (tomelr--toml-table-p (cdr (car object))))
+ (t
+ nil))))
+ tablep))
(defun tomelr--print-pair (key val)
"Insert TOML representation of KEY - VAL pair at point."
- [elpa] externals/tomelr a25d952a17 77/84: feat: Auto-coerce string to integers, (continued)
- [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
- [elpa] externals/tomelr 7d8d41f15b 19/84: feat: Encode to multi-line TOML string automatically, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 0ba5f2ff69 24/84: chore(readme): Move mixed type array example to the 'medley' example, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr ca9245038a 35/84: fix: Attempt to make tomelr--toml-table-p more robust,
ELPA Syncer <=
- [elpa] externals/tomelr 000067cf7d 14/84: chore(readme): Update, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 69217d47a6 22/84: feat: Skip converting keys whose values are nil, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr af40c0b40f 11/84: fix: Require subr-x for older Emacs versions, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 060c38b934 16/84: chore(readme): Limit up to 3 levels of headings for Org exports, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 20bf9e6c54 12/84: chore(doc): Add GHA and license badges, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr f37841cc78 25/84: test: Add test for TOML Array of Arrays, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr cedb75df72 29/84: feat: Support basic TOML tables, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 91800b26b8 21/84: feat: Recognize RFC 3339 formatted date-time + offset, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 83e924559e 13/84: chore(doc): Fix typo, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 98c9b8c1fc 26/84: fix: Use `=` and `length` separately instead of `length=`, ELPA Syncer, 2022/05/03