Skip to content

Commit 3f93aab

Browse files
plexusbbatsov
authored andcommitted
Remove the a.el dependency
Necessary for inclusing in ELPA. See also clojure-emacs/parseclj#29
1 parent 7b9ca20 commit 3f93aab

File tree

3 files changed

+18
-17
lines changed

3 files changed

+18
-17
lines changed

parseedn.el

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
;; Author: Arne Brasseur <arne@arnebrasseur.net>
66
;; Keywords: lisp clojure edn parser
7-
;; Package-Requires: ((emacs "25") (a "0.1.0alpha4") (parseclj "0.1.0"))
7+
;; Package-Requires: ((emacs "25") (parseclj "0.2.0") (map "2"))
88
;; Version: 0.1.0
99

1010
;; This file is not part of GNU Emacs.
@@ -47,18 +47,18 @@
4747
;; Note that this is kind of broken, we don't correctly detect if \u or \o forms
4848
;; don't have the right forms.
4949

50-
(require 'a)
5150
(require 'cl-lib)
51+
(require 'map)
5252
(require 'parseclj-parser)
5353

5454
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
5555
;; Reader
5656

5757
(defvar parseedn-default-tag-readers
58-
(a-list 'inst (lambda (s)
59-
(cl-list* 'edn-inst (date-to-time s)))
60-
'uuid (lambda (s)
61-
(list 'edn-uuid s)))
58+
(list (cons 'inst (lambda (s)
59+
(cl-list* 'edn-inst (date-to-time s))))
60+
(cons 'uuid (lambda (s)
61+
(list 'edn-uuid s))))
6262
"Default reader functions for handling tagged literals in EDN.
6363
These are the ones defined in the EDN spec, #inst and #uuid. It
6464
is not recommended you change this variable, as this globally
@@ -84,7 +84,7 @@ CHILDREN is a collection elisp values to be reduced into an elisp
8484
sequence.
8585
OPTIONS is an association list. See `parseclj-parse' for more information
8686
on available options."
87-
(let ((tag-readers (a-merge parseedn-default-tag-readers (a-get options :tag-readers)))
87+
(let ((tag-readers (map-merge 'alist parseedn-default-tag-readers (alist-get :tag-readers options)))
8888
(token-type (parseclj-lex-token-type opening-token)))
8989
(if (eq token-type :discard)
9090
stack
@@ -100,10 +100,10 @@ on available options."
100100
(puthash (car pair) (cadr pair) hash-map))
101101
kvs)
102102
hash-map))
103-
(:tag (let* ((tag (intern (substring (a-get opening-token :form) 1)))
104-
(reader (a-get tag-readers tag :missing)))
103+
(:tag (let* ((tag (intern (substring (alist-get :form opening-token) 1)))
104+
(reader (alist-get tag tag-readers :missing)))
105105
(when (eq :missing reader)
106-
(user-error "No reader for tag #%S in %S" tag (a-keys tag-readers)))
106+
(user-error "No reader for tag #%S in %S" tag (map-keys tag-readers)))
107107
(funcall reader (car children)))))
108108
stack))))
109109

@@ -116,7 +116,7 @@ identifying *tags*, and values are tag handler functions that receive one
116116
argument: *the tagged element*, and specify how to interpret it."
117117
(parseclj-parser #'parseedn-reduce-leaf
118118
#'parseedn-reduce-branch
119-
(a-list :tag-readers tag-readers)))
119+
(list (cons :tag-readers tag-readers))))
120120

121121
(defun parseedn-read-str (s &optional tag-readers)
122122
"Parse string S as EDN.
@@ -142,11 +142,12 @@ TAG-READERS is an optional association list. For more information, see
142142
(parseedn-print-seq next))))
143143

144144
(defun parseedn-print-hash-or-alist (map &optional ks)
145-
"Insert hash table MAP or elisp a-list as an EDN map into the current buffer."
146-
(let ((keys (or ks (a-keys map))))
145+
"Insert hash table MAP or elisp alist as an EDN map into the current buffer."
146+
(let ((alist? (listp map))
147+
(keys (or ks (map-keys map))))
147148
(parseedn-print (car keys))
148149
(insert " ")
149-
(parseedn-print (a-get map (car keys)))
150+
(parseedn-print (map-elt map (car keys)))
150151
(let ((next (cdr keys)))
151152
(when (not (seq-empty-p next))
152153
(insert ", ")

test/parseedn-el-parity-test.el

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,8 @@
204204
1)
205205

206206
(setq parseedn-test-extra-handlers
207-
(a-list
208-
'my/type #'test-val-passed-to-handler
209-
'my/other-type (lambda (val) 2)))
207+
(list (cons 'my/type #'test-val-passed-to-handler)
208+
(cons 'my/other-type (lambda (val) 2))))
210209

211210
(ert-deftest tags ()
212211
:tags '(edn tags)

test/parseedn-test.el

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
;;; Code
2929

30+
(require 'a)
3031
(require 'ert)
3132
(require 'parseedn)
3233

0 commit comments

Comments
 (0)