Subject: bug#49651: 28.0.50; setf bug

From: Michael Heerdegen <[email-masked]>
Date: Tue, 20 Jul 2021 02:29:30 +0200

Devon Sean McCullough <[email-masked]> writes:

> $ /Applications/Emacs-28.0.50.app/Contents/MacOS/Emacs -Q --batch --eval '(setf (getenv "FOO") "BAR")'
> Debugger entered--Lisp error: (void-function \(setf\ getenv\))
>   (\(setf\ getenv\) "BAR" "FOO")
>   (setf (getenv "FOO") "BAR")

> P.S. The fix is obvious:
>
> lisp/emacs-lisp/cl-lib.el
> ⋮
> ;; These used to be in cl-macs.el since all macros that use them (like setf)
> ;; were autoloaded from cl-macs.el.  But now that setf, push, and pop are in
> ;; core Elisp, they need to either be right here or be autoloaded via
> ;; cl-loaddefs.el, which is more trouble than it is worth.
> ⋮
> (gv-define-simple-setter getenv setenv t)

So the error does only occur before you require cl-lib, and your
suggestion is to do what the comment describes as trouble - correct?

I'm not sure of what kind that trouble is, moving such definitions can
have effects on bootstrapping or startup, that's beyond my knowledge.

Any opinions?

> P.P.S.  Perhaps describe-function, M-. and the like should mention
> setters?

I would like it when C-h f would tell about gv expanders.  Not trivial
though since most gv expanders are anonymous functions (like that of
`getenv').

Michael.