[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/cape 03d8c56c93 7/9: char: Remove `eval-when-compile` o
From: |
ELPA Syncer |
Subject: |
[elpa] externals/cape 03d8c56c93 7/9: char: Remove `eval-when-compile` on translation-hash function |
Date: |
Thu, 28 Sep 2023 00:57:47 -0400 (EDT) |
branch: externals/cape
commit 03d8c56c935d38a16ae539a9742d68d3320d8bf2
Author: hedy <hedy@tilde.cafe>
Commit: Daniel Mendler <mail@daniel-mendler.de>
char: Remove `eval-when-compile` on translation-hash function
Also note that the purity declaration is also removed.
Suggested from PR review comments.
> If we remove that, which is possible because of your vastly simpler
> implementation, the macro can be used, which is a significant
> improvement over the status quo
The reason for the change in this commit is because of the improved
implementation for the translation-hash function (several commits ago).
---
cape-char.el | 47 +++++++++++++++++++++--------------------------
1 file changed, 21 insertions(+), 26 deletions(-)
diff --git a/cape-char.el b/cape-char.el
index 2643a05f16..a5c32f8228 100644
--- a/cape-char.el
+++ b/cape-char.el
@@ -28,12 +28,8 @@
(autoload 'thing-at-point-looking-at "thingatpt")
-;; Declare as pure function which is evaluated at compile time. We don't use a
-;; macro for this computation since packages like `helpful' will
-;; `macroexpand-all' the expensive `cape-char--define' macro calls.
-(eval-when-compile
- (defun cape-char--translation-hash (method regexp)
- "Return character translation hash for input method METHOD.
+(defun cape-char--translation-hash (method regexp)
+ "Return character translation hash for input method METHOD.
REGEXP is the regular expression matching the names.
Names (hash keys) that map to multiple candidates (hash values) in the
@@ -42,28 +38,27 @@ quail translation map are not included.
Hash values are either char or strings. They are stored as strings
only if converting the string into char and back to string does not
retain the original string; otherwise they are stored as chars."
- (declare (pure t))
- (require 'quail)
- ;; Load the quail input method and its required libraries
- (apply #'quail-use-package method (nthcdr 5 (assoc method
input-method-alist)))
- (let ((hash (make-hash-table :test #'equal))
- (decode-map (list 'dm)))
- (quail-build-decode-map (list (quail-map)) "" decode-map 0)
- ;; Now decode-map contains: (dm (name . value) (name . value) ...)
- (dolist (cell (cdr decode-map))
- (let ((name (car cell)) (value (cdr cell))
- value-char value-str)
- (if (and (vectorp value) (= (length value) 1))
- (setq value (aref value 0)))
- (when (char-or-string-p value)
- (when (string-match-p regexp name)
- (puthash name (if (string= (char-to-string value-char) value-str)
- value-char value-str)
- hash)))))
- (quail-deactivate)
- hash)))
+ (require 'quail)
+ ;; Load the quail input method and its required libraries
+ (apply #'quail-use-package method (nthcdr 5 (assoc method
input-method-alist)))
+ (let ((hash (make-hash-table :test #'equal))
+ (decode-map (list 'dm)))
+ (quail-build-decode-map (list (quail-map)) "" decode-map 0)
+ ;; Now decode-map contains: (dm (name . value) (name . value) ...)
+ (dolist (cell (cdr decode-map))
+ (let ((name (car cell)) (value (cdr cell))
+ value-char value-str)
+ (if (and (vectorp value) (= (length value) 1))
+ (setq value (aref value 0)))
+ (when (char-or-string-p value)
(setq value-char (if (stringp value) (string-to-char value) value)
value-str (if (characterp value) (char-to-string value) value))
+ (when (string-match-p regexp name)
+ (puthash name (if (string= (char-to-string value-char) value-str)
+ value-char value-str)
+ hash)))))
+ (quail-deactivate)
+ hash))
(defmacro cape-char--define (name method &rest prefix)
"Define character translation Capf.
- [elpa] externals/cape updated (4506ee8212 -> f97e64e870), ELPA Syncer, 2023/09/28
- [elpa] externals/cape f89307f9fe 1/9: char: Better implementation of obtaining input method translation hash, ELPA Syncer, 2023/09/28
- [elpa] externals/cape 0f4b94109a 2/9: char: More inclusive on the matching translations to include, ELPA Syncer, 2023/09/28
- [elpa] externals/cape d25df039f8 3/9: char: Refactor translation hash function, ELPA Syncer, 2023/09/28
- [elpa] externals/cape b06ee58fd6 4/9: char: Suppress reference to free variable warning, ELPA Syncer, 2023/09/28
- [elpa] externals/cape 3f4afc695c 6/9: char: Make `*--ensure-*` functions inline, ELPA Syncer, 2023/09/28
- [elpa] externals/cape 4b8f101dfb 8/9: char: `*--define` macro: Call translation-hash from within the macro, ELPA Syncer, 2023/09/28
- [elpa] externals/cape 29beb6a1c7 5/9: char: Define `*--ensure-*` functions as macros, ELPA Syncer, 2023/09/28
- [elpa] externals/cape 03d8c56c93 7/9: char: Remove `eval-when-compile` on translation-hash function,
ELPA Syncer <=
- [elpa] externals/cape f97e64e870 9/9: cape-char: Refactoring, ELPA Syncer, 2023/09/28