diff options
author | Nic Ferrier <nferrier@ferrier.me.uk> | 2014-01-08 15:34:20 +0000 |
---|---|---|
committer | Nic Ferrier <nferrier@ferrier.me.uk> | 2014-01-08 15:34:20 +0000 |
commit | 721148475bce38a70e0b678ba8aa923652e8900e (patch) | |
tree | 33f47d6940bf7f62016226bab9429b6c72ed4474 | |
parent | d2aebad841c14e8216c9ee9db1d1228adc0e6822 (diff) |
allow keywords to be retained in a plist->alist
-rw-r--r-- | kv.el | 14 |
1 files changed, 10 insertions, 4 deletions
@@ -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." |