Subject: Re: bug#27016: possible bug in `defsetf'

From: Michael Heerdegen <[email-masked]>
Date: Mon, 10 Jul 2017 02:26:14 +0200

[email-masked] writes:

> Here's a patch for it: [...]

Thanks for working on this.  AFAIU I think it should work.

> @@ -146,12 +149,15 @@ (defmacro gv-define-expander (name handler)
>  HANDLER is a function which takes an argument DO followed by the same
>  arguments as NAME.  DO is a function as defined in `gv-get'."
>    (declare (indent 1) (debug (sexp form)))
> -  ;; Use eval-and-compile so the method can be used in the same file as it
> -  ;; is defined.
> -  ;; FIXME: Just like byte-compile-macro-environment, we should have something
> -  ;; like byte-compile-symbolprop-environment so as to handle these things
> -  ;; cleanly without affecting the running Emacs.
> -  `(eval-and-compile (put ',name 'gv-expander ,handler)))
> +  ;; Push onto `byte-compile-macro-environment' so the method can be
> +  ;; used in the same file as it is defined.
> +  (when (boundp 'byte-compile-macro-environment)
> +    (push (cons :gv-expanders
> +                (cons (cons name handler)
> +                      (cdr (assq :gv-expanders
> +                                 byte-compile-macro-environment))))
> +          byte-compile-macro-environment))
> +  `(put ',name 'gv-expander ,handler))

Is it intended to add an :gv-expanders entry to
byte-compile-macro-environment more than once?

Michael.