summaryrefslogtreecommitdiff
path: root/cider-util.el
diff options
context:
space:
mode:
authorMarshall Bockrath-Vandegrift <llasram@damballa.com>2014-12-18 09:05:55 -0500
committerMarshall Bockrath-Vandegrift <llasram@damballa.com>2014-12-18 09:26:39 -0500
commit92d5ffd6cb03dad7b5dbf99ca216b819bc0d9f5c (patch)
tree2c47745de4a334fe6944c8115180aef8d147912a /cider-util.el
parent797d473f21792be78e9be5698391e913a1d5e5ac (diff)
[Fix #885] Ensure text property keys are symbols.
Maps received via nREPL have string keys. The Emacs Lisp text property functions expect all property keys to be symbols. Thus we must first intern any non-symbol property keys prior to applying them as text properties.
Diffstat (limited to 'cider-util.el')
-rw-r--r--cider-util.el8
1 files changed, 8 insertions, 0 deletions
diff --git a/cider-util.el b/cider-util.el
index eb146160..fabc3967 100644
--- a/cider-util.el
+++ b/cider-util.el
@@ -67,6 +67,14 @@ buffer-local wherever it is set."
;;; Text properties
+(defun cider-maybe-intern (name)
+ "If NAME is a symbol, return it; otherwise, intern it."
+ (if (symbolp name) name (intern name)))
+
+(defun cider-intern-keys (props)
+ "Copy plist-style PROPS with any non-symbol keys replaced with symbols."
+ (-map-indexed (lambda (i x) (if (oddp i) x (cider-maybe-intern x))) props))
+
(defmacro cider-propertize-region (props &rest body)
"Execute BODY and add PROPS to all the text it inserts.
More precisely, PROPS are added to the region between the point's