emacs-elpa-diffs
[Top][All Lists]
Advanced

[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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]