summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNic Ferrier <nferrier@ferrier.me.uk>2014-01-08 15:34:20 +0000
committerNic Ferrier <nferrier@ferrier.me.uk>2014-01-08 15:34:20 +0000
commit721148475bce38a70e0b678ba8aa923652e8900e (patch)
tree33f47d6940bf7f62016226bab9429b6c72ed4474
parentd2aebad841c14e8216c9ee9db1d1228adc0e6822 (diff)
allow keywords to be retained in a plist->alist
-rw-r--r--kv.el14
1 files changed, 10 insertions, 4 deletions
diff --git a/kv.el b/kv.el
index d06f10d..5427c4e 100644
--- a/kv.el
+++ b/kv.el
@@ -209,14 +209,20 @@ Converting to a symbol means dropping the :."
(intern (substring (symbol-name keyword) 1))
keyword))
-(defun kvplist->alist (plist)
+(defun kvplist->alist (plist &optional keys-are-keywords)
"Convert PLIST to an alist.
-The keys are expected to be :prefixed and the colons are removed.
-The keys in the resulting alist are symbols."
+The keys are expected to be :prefixed and the colons are removed
+unless KEYS-ARE-KEYWORDS is `t'.
+
+The keys in the resulting alist are always symbols."
(when plist
(loop for (key value . rest) on plist by 'cddr
- collect (cons (keyword->symbol key) value))))
+ collect
+ (cons (if keys-are-keywords
+ key
+ (keyword->symbol key))
+ value))))
(defun kvalist2->plist (alist2)
"Convert a list of alists too a list of plists."