summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cape-char.el18
1 files changed, 9 insertions, 9 deletions
diff --git a/cape-char.el b/cape-char.el
index b1fa877..42e62f2 100644
--- a/cape-char.el
+++ b/cape-char.el
@@ -28,15 +28,15 @@
(autoload 'thing-at-point-looking-at "thingatpt")
-(defun cape-char--ensure-str (char-or-str)
- "Return CHAR-OR-STR as a string"
- (if (characterp char-or-str)
- (char-to-string char-or-str) char-or-str))
-
-(defun cape-char--ensure-char (char-or-str)
- "Return CHAR-OR-STR as a char"
- (if (stringp char-or-str)
- (string-to-char char-or-str) char-or-str))
+(defmacro cape-char--ensure-str (char-or-str)
+ "IF-expression to convert CHAR-OR-STR to string only if it's a char"
+ `(if (characterp ,char-or-str)
+ (char-to-string ,char-or-str) ,char-or-str))
+
+(defmacro cape-char--ensure-char (char-or-str)
+ "IF-expression to convert CHAR-OR-STR to char only if it's a string"
+ `(if (stringp ,char-or-str)
+ (string-to-char ,char-or-str) ,char-or-str))
;; Declare as pure function which is evaluated at compile time. We don't use a
;; macro for this computation since packages like `helpful' will