branch: externals/async
commit bd68cc1ab1ac6af890e250bdaa12ffb1cb9649be
Author: Thierry Volpiatto <[email protected]>
Commit: Thierry Volpiatto <[email protected]>
Handle dotted lists as well
This is limited though to dotted lists like (x . y)
and not (x . (x . y)).
* async.el (async--purecopy): Do it.
---
async.el | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/async.el b/async.el
index e20e373..d616b11 100644
--- a/async.el
+++ b/async.el
@@ -61,12 +61,28 @@ is returned unmodified."
(substring-no-properties object))
((consp object)
(cl-loop for elm in object
+ ;; A string.
if (stringp elm)
collect (substring-no-properties elm)
else
+ ;; Proper lists.
if (and (consp elm) (null (cdr (last elm))))
collect (async--purecopy elm)
else
+ ;; Dotted lists.
+ ;; We handle here only dotted list where car and cdr
+ ;; are atoms i.e. (x . y) and not (x . (x . y)) or
+ ;; (x . (x y)) which should fit most cases.
+ if (and (consp elm) (cdr (last elm)))
+ collect (let ((key (car elm))
+ (val (cdr elm)))
+ (cons (if (stringp key)
+ (substring-no-properties key)
+ key)
+ (if (stringp val)
+ (substring-no-properties val)
+ val)))
+ else
collect elm))
(t object)))