diff options
| author | hedy <hedy@tilde.cafe> | 2023-09-11 22:26:56 +0800 |
|---|---|---|
| committer | Daniel Mendler <mail@daniel-mendler.de> | 2023-09-28 06:20:48 +0200 |
| commit | 29beb6a1c74a0e627da59d7c9da423fe0fc3bef6 (patch) | |
| tree | 7ef28a94f206f29c62aba8c6041dc2c871169c12 | |
| parent | b06ee58fd68a93425723a1cc1b1841fc509108d6 (diff) | |
char: Define `*--ensure-*` functions as macros
This fixes the void-function errors. Efficiency wise IMO it's pretty
much on par with the function implementation. But when the current
translation function having `eval-when-compile` around it, this
suppresses the cape-char--translation-hash symbol definition is void
errors.
There are possibly more targeted fixes to this problem, and we'll
probably be changing the `eval-when-compile` in the future anyway, but I
think this change isn't really a "hack" to fix it -- just an alternate
solution for `*--ensure-*` functions (macros).
| -rw-r--r-- | cape-char.el | 18 |
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 |
