all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Michael Heerdegen <michael_heerdegen@web.de>
To: 57397@debbugs.gnu.org
Cc: Lars Ingebrigtsen <larsi@gnus.org>,
	Stefan Monnier <monnier@iro.umontreal.ca>
Subject: bug#57397: 29.0.50; cl-letf blindly macroexpands places
Date: Thu, 25 Aug 2022 06:42:17 +0200	[thread overview]
Message-ID: <877d2xdjdi.fsf@web.de> (raw)


Hello,

background: to get rid of warnings about the recently obsoleted
generalized variables in my init file... because I'm lazy and wanted to
try (and there were only two) I blindly replaced them with synthetic
places - like this:

#+begin_src emacs-lisp
(defun test1 (b query)
  (cl-letf (((buffer-local-value 'buffer-save-without-query b)
             (or buffer-save-without-query query)))
    (with-current-buffer b (save-buffer))))
;; ~~>
(defun test2 (b query)
  (cl-letf (((gv-synthetic-place
              (buffer-local-value 'buffer-save-without-query b)
              (lambda (v) `(setq-local buffer-save-without-query ,v)))
             (or buffer-save-without-query query)))
    (with-current-buffer b (save-buffer))))
#+end_src

[ I know it is an nonsense example wrt what it does and how it does it,
that doesn't matter. ]

This should get rid of the warning - but in this case it doesn't (in
the other it did).  The reason is that Stefan made cl-letf (the helper
cl--letf more precisely), macroexpand each place:

| 91a7f934ac * lisp/emacs-lisp/cl-macs.el: Fix bug#26073.

to support symbol macros better:

#+begin_src emacs-lisp
(defun cl--letf (bindings simplebinds binds body)
  ;; It's not quite clear what the semantics of cl-letf should be...10..
  (if (null bindings)
      (if (and (null binds) (null simplebinds)) (macroexp-progn body)..20..)
    (let* ((binding (car bindings))
           (place (macroexpand (car binding) macroexpand-all-environment)));<--!!
      (gv-letplace (getter setter) place..12..))))
#+end_src

I think this is an error in the general case.  Maybe it's enough to
expand only symbol macros?  It's at least always wrong when (car PLACE)
is a macro name with a gv spec defined.

TIA,

Michael.


In GNU Emacs 29.0.50 (build 2, x86_64-pc-linux-gnu, X toolkit, cairo
 version 1.16.0, Xaw scroll bars) of 2022-08-25 built on drachen
Repository revision: bd5b704447ac5ec0559a824209bb01b271d29959
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12011000
System Description: Debian GNU/Linux 11 (bullseye)

Configured using:
 'configure --with-x-toolkit=lucid'






             reply	other threads:[~2022-08-25  4:42 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-25  4:42 Michael Heerdegen [this message]
2022-08-25 19:33 ` bug#57397: cl-letf blindly macroexpands places Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-08-27  1:43   ` Michael Heerdegen
2022-08-27 14:48     ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-08-31  1:32       ` Michael Heerdegen
2022-09-04  2:55         ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-09-28 15:44           ` Michael Heerdegen
2022-09-28 16:29             ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-09-28 16:52               ` Eli Zaretskii
2022-09-28 17:10                 ` Michael Heerdegen
2022-09-28 17:12                   ` Lars Ingebrigtsen
2022-09-28 17:15                   ` Eli Zaretskii
2022-09-28 17:56                     ` Michael Heerdegen
2022-09-28 18:15                       ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-10-02 18:18                         ` bug#57397: 29.0.50; " Michael Heerdegen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=877d2xdjdi.fsf@web.de \
    --to=michael_heerdegen@web.de \
    --cc=57397@debbugs.gnu.org \
    --cc=larsi@gnus.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.