summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Kirkpatrick <ubermonk@gmail.com>2012-12-31 14:40:57 +1030
committerAndrew Kirkpatrick <ubermonk@gmail.com>2012-12-31 14:40:57 +1030
commit83df0dd7a0c6ff9e982c1601b65b83647872bf29 (patch)
treefe3bc5b15db177d295c17d38bf27090cd72b0f4d
parent8c11a41ed594e708be453bfca659e314f6a5babc (diff)
made keyword->symbol tolerant of non-keyword symbols
added test for keyword->symbol
-rw-r--r--kv-tests.el16
-rw-r--r--kv.el4
2 files changed, 19 insertions, 1 deletions
diff --git a/kv-tests.el b/kv-tests.el
index 7b83ebb..4a4823f 100644
--- a/kv-tests.el
+++ b/kv-tests.el
@@ -141,6 +141,22 @@
(dotassq 'a.b.c '((a . ((b . ((c . 10)))))))
10)))
+(ert-deftest keyword->symbol ()
+ "Convert keyword into a symbol without the leading `:'"
+ (should
+ (eq
+ 'key
+ (keyword->symbol :key)))
+ (should
+ (eq
+ 'key
+ (keyword->symbol 'key)))
+ (let ((sym (gensym)))
+ (should
+ (eq
+ sym
+ (keyword->symbol sym)))))
+
(ert-deftest kvalist->plist ()
"Make alists into plists."
(should
diff --git a/kv.el b/kv.el
index 80be11c..8d54b5e 100644
--- a/kv.el
+++ b/kv.el
@@ -168,7 +168,9 @@ expression is true."
"A keyword is a symbol leading with a :.
Converting to a symbol means dropping the :."
- (intern (substring (symbol-name keyword) 1)))
+ (if (keywordp keyword)
+ (intern (substring (symbol-name keyword) 1))
+ keyword))
(defun kvplist->alist (plist)
"Convert PLIST to an alist.