[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/macrostep c61b836 062/110: Use SB-WALKER:WALK-FORM to coll
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/macrostep c61b836 062/110: Use SB-WALKER:WALK-FORM to collect macro forms |
Date: |
Sat, 7 Aug 2021 09:18:03 -0400 (EDT) |
branch: elpa/macrostep
commit c61b836541c585060e0bbd2083b59f8280be11e9
Author: joddie <jonxfield@gmail.com>
Commit: joddie <jonxfield@gmail.com>
Use SB-WALKER:WALK-FORM to collect macro forms
The alternative implementation using *MACROEXPAND-HOOK* is retained as a
fallback.
---
swank-macrostep.lisp | 50 +++++++++++++++++++++++++++++++++-----------------
1 file changed, 33 insertions(+), 17 deletions(-)
diff --git a/swank-macrostep.lisp b/swank-macrostep.lisp
index b411051..d3820e8 100644
--- a/swank-macrostep.lisp
+++ b/swank-macrostep.lisp
@@ -75,23 +75,39 @@
(collect-macro-forms form)
(substitute-macro-forms form macro-forms compiler-macro-forms)))
-(defun collect-macro-forms (form)
- (let* ((real-macroexpand-hook *macroexpand-hook*)
- (macro-forms '())
- (*macroexpand-hook*
- (lambda (macro-function form environment)
- (setq macro-forms
- (cons form macro-forms))
- (funcall real-macroexpand-hook macro-function form environment)))
- (expansion (ignore-errors (macroexpand-all form)))
- (compiler-macro-forms '())
- (*macroexpand-hook*
- (lambda (macro-function form environment)
- (setq compiler-macro-forms
- (cons form compiler-macro-forms))
- (funcall real-macroexpand-hook macro-function form environment))))
- (ignore-errors
- (compile nil `(lambda () ,expansion)))
+#-sbcl
+(defun collect-macro-forms (form &optional environment)
+ (let ((real-macroexpand-hook *macroexpand-hook*))
+ (macrolet ((make-form-collector (variable)
+ `(lambda (macro-function form environment)
+ (setq ,variable (cons form ,variable))
+ (funcall real-macroexpand-hook
+ macro-function form environment))))
+ (let* ((macro-forms '())
+ (compiler-macro-forms '())
+ (*macroexpand-hook* (make-form-collector macro-forms))
+ (expansion (ignore-errors (macroexpand-all form)))
+ (*macroexpand-hook* (make-form-collector compiler-macro-forms)))
+ (handler-bind ((warning #'muffle-warning))
+ (ignore-errors
+ (compile nil `(lambda () ,expansion))))
+ (values macro-forms compiler-macro-forms)))))
+
+#+sbcl
+(defun collect-macro-forms (form &optional environment)
+ (let ((macro-forms '())
+ (compiler-macro-forms '()))
+ (sb-walker:walk-form
+ form environment
+ (lambda (form context environment)
+ (declare (ignore context))
+ (when (and (consp form)
+ (symbolp (car form)))
+ (cond ((macro-function (car form) environment)
+ (push form macro-forms))
+ ((compiler-macro-function (car form) environment)
+ (push form compiler-macro-forms))))
+ form))
(values macro-forms compiler-macro-forms)))
(defun substitute-macro-forms (form macro-forms compiler-macro-forms)
- [nongnu] elpa/macrostep e3e5c12 034/110: Merge branch 'expand-macrolet', (continued)
- [nongnu] elpa/macrostep e3e5c12 034/110: Merge branch 'expand-macrolet', ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep 4ea178a 045/110: Simplify overlay collapsing, ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep 2519692 038/110: Restore narrowing, ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep c748996 057/110: Tweak macrostep-slime-macro-form-p, ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep 3757ec4 033/110: Extend macrostep-environment while printing macrolet body forms, ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep a478a3a 054/110: Bind inhibit-read-only instead of buffer-read-only, ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep 8d72b62 044/110: Fix indentation in new macrostep-pp function, ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep 8950313 037/110: Bump version number and changelog for 0.8, ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep 5680278 056/110: Gross hack to macrostep--slime-propertize-macros, ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep 31e1dc2 060/110: Detect Elisp macro forms by advising `macroexpand`, ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep c61b836 062/110: Use SB-WALKER:WALK-FORM to collect macro forms,
ELPA Syncer <=
- [nongnu] elpa/macrostep 39e809a 064/110: swank-macrostep: call PROVIDE at the end, ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep 1be6c4d 061/110: Extract Elisp macro environments accurately, ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep d9c7629 063/110: Improvements to Elisp environment handling, ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep 59972eb 071/110: Fix handling of subforms contained within other subforms, ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep a0ae61c 073/110: Properly handle forms not present in the expansion, ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep 817322b 074/110: Properly place the macrostep[-compiler]-macro-face, ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep aa40d97 076/110: Test expansion within Elisp macro-defining macros, ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep 1edee85 080/110: Reorganise and comment, ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep bbfb033 081/110: Reorganise and document generic interface, ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep 2bdc946 082/110: Remove dynamic binding of `macrostep-environment'., ELPA Syncer, 2021/08/07