summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNic Ferier <nic@ferrier.me.uk>2012-10-26 09:38:07 +0100
committerNic Ferier <nic@ferrier.me.uk>2012-10-26 09:38:07 +0100
commitf8c11b10b140efbc02c6eaf2a174df870adc790b (patch)
treeb78d5975296f97615c2377b245149c24e2d74527
parent6ea2bae0e0be6767c638c5d1954c158b4070c87d (diff)
make kvplist->filter-keys accept keyword key syms for filters
-rw-r--r--kv.el15
1 files changed, 9 insertions, 6 deletions
diff --git a/kv.el b/kv.el
index 0cce41d..d6fa327 100644
--- a/kv.el
+++ b/kv.el
@@ -189,13 +189,16 @@ Only pairs where the car is a `member' of KEYS will be returned."
(defun kvplist->filter-keys (plist &rest keys)
"Filter the plist to just those matching KEYS.
-KEYS must actually be :-less symbols.
-
`kvalist->filter-keys' is actually used to do this work."
- (kvalist->plist
- (apply
- 'kvalist->filter-keys
- (cons (kvplist->alist plist) keys))))
+ (let ((symkeys (loop for k in keys
+ collect (let ((strkey (symbol-name k)))
+ (if (equal (substring strkey 0 1) ":")
+ (intern (substring strkey 1))
+ k)))))
+ (kvalist->plist
+ (apply
+ 'kvalist->filter-keys
+ (cons (kvplist->alist plist) symkeys)))))
(defun kvplist2->filter-keys (plist2 &rest keys)
"Return the PLIST2 (a list of plists) filtered to the KEYS."