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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master dee0dbd: [el-search] Save two 'eval' calls


From: Michael Heerdegen
Subject: [elpa] master dee0dbd: [el-search] Save two 'eval' calls
Date: Wed, 20 Jun 2018 13:16:30 -0400 (EDT)

branch: master
commit dee0dbdc7f7071724c03abe04edfa17f5f7bae23
Author: Stefan Monnier <address@hidden>
Commit: Michael Heerdegen <address@hidden>

    [el-search] Save two 'eval' calls
    
    * packages/el-search/el-search.el
    (el-search--with-additional-pcase-macros): Reimplement to set and
    unset respective 'pcase-macroexpander' symbol properties "by
    hand" (i.e. without 'cl-letf').
    (el-search--macroexpand): Remove now unnecessary 'eval' wrapper.
    (el-search-make-matcher): Remove now unnecessary 'eval' wrapper.
    Byte compile lambda form instead of function value.
---
 packages/el-search/el-search.el | 34 ++++++++++++++++++++--------------
 1 file changed, 20 insertions(+), 14 deletions(-)

diff --git a/packages/el-search/el-search.el b/packages/el-search/el-search.el
index 1176275..ecedaa3 100644
--- a/packages/el-search/el-search.el
+++ b/packages/el-search/el-search.el
@@ -930,9 +930,16 @@ for details.
              (lambda ,args ,@(and doc `(,doc)) ,@body)))))
 
 (defmacro el-search--with-additional-pcase-macros (&rest body)
-  `(cl-letf ,(mapcar (pcase-lambda (`(,symbol . ,fun)) `((get ',symbol 
'pcase-macroexpander) #',fun))
-                     el-search--pcase-macros)
-     ,@body))
+  (let ((saved (make-symbol "saved")))
+    `(let ((,saved nil))
+       (unwind-protect
+           (progn
+             (pcase-dolist (`(,symbol . ,fun) el-search--pcase-macros)
+               (push (cons symbol (get symbol 'pcase-macroexpander)) ,saved)
+               (put symbol 'pcase-macroexpander fun))
+             ,@body)
+         (pcase-dolist (`(,symbol . ,fun) ,saved)
+           (put symbol 'pcase-macroexpander fun))))))
 
 (defun el-search--macroexpand-1 (pattern &optional n)
   "Expand el-search PATTERN.
@@ -952,19 +959,18 @@ N times."
 
 (defun el-search--macroexpand (pattern)
   "Like `pcase--macroexpand' but also expanding \"el-search\" patterns."
-  (eval `(el-search--with-additional-pcase-macros (pcase--macroexpand 
',pattern))))
+  (el-search--with-additional-pcase-macros (pcase--macroexpand pattern)))
 
 (cl-defun el-search-make-matcher (pattern &optional (result nil 
result-specified))
-  (eval ;use `eval' to allow for user defined pattern types at run time
-   (let ((expression (make-symbol "expression")))
-     `(el-search--with-additional-pcase-macros
-       (let ((byte-compile-debug t) ;make undefined pattern types raise an 
error
-             (warning-suppress-log-types '((bytecomp)))
-             (pcase--dontwarn-upats (cons '_ pcase--dontwarn-upats)))
-         (byte-compile (lambda (,expression)
-                         (pcase ,expression
-                           (,pattern ,(if result-specified result t))
-                           (_        nil)))))))))
+  (let ((expression (make-symbol "expression")))
+    (el-search--with-additional-pcase-macros
+     (let ((byte-compile-debug t) ;make undefined pattern types raise an error
+           (warning-suppress-log-types '((bytecomp)))
+           (pcase--dontwarn-upats (cons '_ pcase--dontwarn-upats)))
+       (byte-compile `(lambda (,expression)
+                        (pcase ,expression
+                          (,pattern ,(if result-specified result t))
+                          (_        nil))))))))
 
 (defun el-search--match-p (matcher expression)
   (funcall matcher expression))



reply via email to

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