Thanks for taking time to help with this!
Hi Stefan,
> diff --git a/module/ice-9/psyntax.scm b/module/ice-9/psyntax.scm
> index e522f54..70463a5 100644
> --- a/module/ice-9/psyntax.scm
> +++ b/module/ice-9/psyntax.scm
> @@ -155,6 +155,10 @@
> (eval-when (compile)
> (set-current-module (resolve-module '(guile))))
>
> +(define *macro-lookup* (make-fluid))
> +(fluid-set! *macro-lookup*
> + (lambda x (error "not in a macro evaluation context")))
> +
> (let ()
> (define-syntax define-expansion-constructors
> (lambda (x)
> @@ -1304,8 +1308,12 @@
> (syntax-violation #f "encountered raw symbol in macro output"
> (source-wrap e w (wrap-subst w) mod) x))
> (else (decorate-source x s)))))
> - (rebuild-macro-output (p (source-wrap e (anti-mark w) s mod))
> - (new-mark))))
> + (with-fluids ((*macro-lookup*
> + (lambda (e) (lookup (id-var-name e w)
> + r mod))))
> +
> + (rebuild-macro-output (p (source-wrap e (anti-mark w) s mod))
> + (new-mark)))))
>
> (define expand-body
> ;; In processing the forms of the body, we create a new, empty wrap.
This doesn't look quite right to me.
At this one point only, where a macro is expanded, you capture the
lexical environment (r w mod) in your fluid. This is the lexical
environment that you use to lookup plain symbols later passed to
`syntax-binding-info'.