emacs-diffs
[Top][All Lists]
Advanced

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

master 88ca228: * lisp/emacs-lisp/pcase.el (pcase-defmacro): Fix `pcase-


From: Stefan Monnier
Subject: master 88ca228: * lisp/emacs-lisp/pcase.el (pcase-defmacro): Fix `pcase-tests-macro`
Date: Wed, 3 Mar 2021 18:40:08 -0500 (EST)

branch: master
commit 88ca2280ba430ad2fa681c72cc6ba8216709e63f
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>

    * lisp/emacs-lisp/pcase.el (pcase-defmacro): Fix `pcase-tests-macro`
    
    * lisp/emacs-lisp/radix-tree.el (radix-tree-leaf): Simplify accordingly.
---
 lisp/emacs-lisp/pcase.el      |  8 +++++++-
 lisp/emacs-lisp/radix-tree.el | 13 ++++++-------
 2 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/lisp/emacs-lisp/pcase.el b/lisp/emacs-lisp/pcase.el
index 4804180..5342a01 100644
--- a/lisp/emacs-lisp/pcase.el
+++ b/lisp/emacs-lisp/pcase.el
@@ -436,7 +436,13 @@ for the result of evaluating EXP (first arg to `pcase').
        (decl (assq 'declare body)))
     (when decl (setq body (remove decl body)))
     `(progn
-       (defun ,fsym ,args ,@body)
+       ;; FIXME: We use `eval-and-compile' here so that the pcase macro can be
+       ;; used in the same file where it's defined, but ideally, we should
+       ;; handle this using something similar to `overriding-plist-environment'
+       ;; but for `symbol-function' slots so compiling a file doesn't have the
+       ;; side-effect of defining the function.
+       (eval-and-compile
+         (defun ,fsym ,args ,@body))
        (define-symbol-prop ',fsym 'edebug-form-spec ',(cadr (assq 'debug 
decl)))
        (define-symbol-prop ',name 'pcase-macroexpander #',fsym))))
 
diff --git a/lisp/emacs-lisp/radix-tree.el b/lisp/emacs-lisp/radix-tree.el
index 0905ac6..fb65975 100644
--- a/lisp/emacs-lisp/radix-tree.el
+++ b/lisp/emacs-lisp/radix-tree.el
@@ -194,14 +194,13 @@ If not found, return nil."
   "Return an alist of all bindings in TREE for prefixes of STRING."
   (radix-tree--prefixes tree string 0 nil))
 
-(eval-and-compile
-  (pcase-defmacro radix-tree-leaf (vpat)
-    "Pattern which matches a radix-tree leaf.
+(pcase-defmacro radix-tree-leaf (vpat)
+  "Pattern which matches a radix-tree leaf.
 The pattern VPAT is matched against the leaf's carried value."
-    ;; We used to use `(pred atom)', but `pcase' doesn't understand that
-    ;; `atom' is equivalent to the negation of `consp' and hence generates
-    ;; suboptimal code.
-    `(or `(t . ,,vpat) (and (pred (not consp)) ,vpat))))
+  ;; We used to use `(pred atom)', but `pcase' doesn't understand that
+  ;; `atom' is equivalent to the negation of `consp' and hence generates
+  ;; suboptimal code.
+  `(or `(t . ,,vpat) (and (pred (not consp)) ,vpat)))
 
 (defun radix-tree-iter-subtrees (tree fun)
   "Apply FUN to every immediate subtree of radix TREE.



reply via email to

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