[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/tomelr f9d670e165 56/84: refactor: Clean up unused code
From: |
ELPA Syncer |
Subject: |
[elpa] externals/tomelr f9d670e165 56/84: refactor: Clean up unused code |
Date: |
Tue, 3 May 2022 09:58:13 -0400 (EDT) |
branch: externals/tomelr
commit f9d670e1656f1400b544ff27980657cbf5f8357b
Author: Kaushal Modi <kaushal.modi@gmail.com>
Commit: Kaushal Modi <kaushal.modi@gmail.com>
refactor: Clean up unused code
Use json-alist-p and json-plist-p directly where applicable.
---
tomelr.el | 69 +++++----------------------------------------------------------
1 file changed, 5 insertions(+), 64 deletions(-)
diff --git a/tomelr.el b/tomelr.el
index 520b702cf5..b7112771f0 100644
--- a/tomelr.el
+++ b/tomelr.el
@@ -42,13 +42,6 @@
"String used for a single indentation level during encoding.
This value is repeated for each further nested element.")
-(defvar tomelr-encoding-object-sort-predicate nil
- "Sorting predicate for TOML object keys during encoding.
-If nil, no sorting is performed. Else, TOML object keys are
-ordered by the specified sort predicate during encoding. For
-instance, setting this to `string<' will have TOML object keys
-ordered alphabetically.")
-
;;;; Internal Variables
(defvar tomelr--print-indentation-prefix "\n"
"String used to start indentation during encoding.")
@@ -92,22 +85,6 @@ Examples:
;;; Utilities
-(defun tomelr-alist-p (list)
- "Non-nil if and only if LIST is an alist with simple keys."
- (declare (pure t) (side-effect-free error-free))
- (while (and (consp (car-safe list))
- (atom (caar list))
- (setq list (cdr list))))
- (null list))
-
-(defun tomelr-plist-p (list)
- "Non-nil if and only if LIST is a plist with keyword keys."
- (declare (pure t) (side-effect-free error-free))
- (while (and (keywordp (car-safe list))
- (consp (cdr list))
- (setq list (cddr list))))
- (null list))
-
(defmacro tomelr--with-output-to-string (&rest body)
"Eval BODY in a temporary buffer bound to `standard-output'.
Return the resulting buffer contents as a string."
@@ -342,49 +319,14 @@ This works for any MAP satisfying `mapp'."
(tomelr--with-indentation
(map-do #'tomelr--print-pair map))))
-(defun tomelr--print-unordered-map (map)
- "Insert a TOML representation of MAP at point, but optionally sort MAP first.
-
-If `tomelr-encoding-object-sort-predicate' is non-nil, this first
-transforms an unsortable MAP into a sortable alist.
-
-See `tomelr-encode-plist' that returns the same as a string."
- (if (and tomelr-encoding-object-sort-predicate
- (not (map-empty-p map)))
- (tomelr--print-alist (map-pairs map) t)
- (tomelr--print-map map)))
-
;;;; Lists (including alists and plists)
-(defun tomelr--print-alist (alist &optional destructive)
- "Insert a TOML representation of ALIST at point.
-
-Sort ALIST first if `tomelr-encoding-object-sort-predicate' is
-non-nil. Sorting can optionally be DESTRUCTIVE for speed.
-
-See `tomelr-encode-alist' that returns the same as a string."
- (tomelr--print-map (if (and tomelr-encoding-object-sort-predicate alist)
- (sort (if destructive alist (copy-sequence alist))
- (lambda (a b)
- (funcall tomelr-encoding-object-sort-predicate
- (car a) (car b))))
- alist)))
-
-;; The following two are unused but useful to keep around due to the
-;; inherent ambiguity of lists.
-(defun tomelr-encode-alist (alist)
- "Return a TOML representation of ALIST."
- (tomelr--with-output-to-string (tomelr--print-alist alist)))
-
-(defun tomelr-encode-plist (plist)
- "Return a TOML representation of PLIST."
- (tomelr--with-output-to-string (tomelr--print-unordered-map plist)))
-;;
-
(defun tomelr--print-list (list)
"Insert a TOML representation of LIST at point."
- (cond ((tomelr-alist-p list) (tomelr--print-alist list))
- ((tomelr-plist-p list) (tomelr--print-unordered-map list))
- ((listp list) (tomelr--print-array list))
+ (cond ((or (json-alist-p list)
+ (json-plist-p list))
+ (tomelr--print-map list))
+ ((listp list)
+ (tomelr--print-array list))
((signal 'tomelr-error (list list)))))
;;;; Arrays
@@ -482,7 +424,6 @@ See `tomelr-encode' that returns the same as a string."
((tomelr--print-stringlike object))
((numberp object) (prin1 object))
((arrayp object) (tomelr--print-array object))
- ((hash-table-p object) (tomelr--print-unordered-map object))
((signal 'tomelr-error (list object)))))
- [elpa] externals/tomelr 55fefb0fa8 40/84: doc: Add few links, (continued)
- [elpa] externals/tomelr 55fefb0fa8 40/84: doc: Add few links, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 38160ef271 41/84: fix: Stricter condition before starting TOML table array check, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr a7b3a57037 48/84: feat: Make a very basic nested array of TTA work, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 3aa4dc1dbd 54/84: chore: Add Package-Requires and other info in the header comment, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr f3b6951cfe 53/84: doc: Add note that the scalars need to be earlier in the order, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 192cb06a23 57/84: chore(style): Whitespace change only, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 6d2be83669 69/84: chore: package-lint fixes, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 41ccea4ebe 64/84: refactor: Remove unnecessary tomelr-encode-keyword, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 406f4922a8 58/84: test: Add tests for json.el functions used in tomelr, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr b3b6a28d15 68/84: doc: Add more examples, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr f9d670e165 56/84: refactor: Clean up unused code,
ELPA Syncer <=
- [elpa] externals/tomelr 511240765b 71/84: chore: Ignore .elc files, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr ed13b73e9b 74/84: feat: Support string keys, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr de661716af 72/84: style: Remove space from after and before [ and ] brackets, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 334b7cba54 76/84: refactor: Don't attempt to triple-quote TOML keys, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr c2d1328c44 80/84: fix: Boolean coercing when value is a symbol true or false, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr ebe5959174 75/84: feat: Auto-coerce string to boolean, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr a676192b43 81/84: fix: Integer coercing of a number strings with underscores, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 8da825067b 15/84: chore(readme): Update, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 65653d53ee 30/84: chore(doc): M-x checkdoc fixes, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr bcaea16ec0 39/84: chore(doc): Clean up old code block, ELPA Syncer, 2022/05/03