all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: daanturo <daanturo@gmail.com>
To: 59333@debbugs.gnu.org
Subject: bug#59333: [PATCH] Define macro dlet*
Date: Thu, 17 Nov 2022 14:13:35 +0700	[thread overview]
Message-ID: <0e8ca5ce-a413-0dd0-c62e-647d19953a3b@gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1234 bytes --]

--=-=-=
Content-Type: text/plain

Tags: patch


The dlet breakage comes as much surprise to me. There's not even a
single entry in NEWS that mentions it.

I would rather prefer b72f88518b89560accf740a4548368863e6238e0 be
reverted, though. But maybe that's fine if the majority of maintainers
agree with that change. But please mention similar breakages more
universally.



In GNU Emacs 29.0.50 (build 2, x86_64-pc-linux-gnu, GTK+ Version
3.24.34, cairo version 1.17.6) of 2022-11-13 built on dan-laptop
Repository revision: b806e8a8a2c7d01a18f11e6582961c42a9eecc01
Repository branch: makepkg
System Description: Arch Linux

Configured using:
'configure --sysconfdir=/etc --prefix=/usr --libexecdir=/usr/lib
--localstatedir=/var
'--program-transform-name=s/\([ec]tags\)/\1.emacs/' --with-json
--with-libsystemd --with-mailutils --with-modules --with-pgtk
--without-xaw3d --with-sound=alsa --with-xinput2 --with-xwidgets
--without-compress-install --with-native-compilation=aot
--with-tree-sitter 'CFLAGS=-march=native -O2 -pipe -fno-plt
-fexceptions -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security
-fstack-clash-protection -fcf-protection'
LDFLAGS=-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now'

--=-=-=--

-- 
Daanturo.

[-- Attachment #2: 0001-Define-macro-dlet-star.patch --]
[-- Type: text/x-patch, Size: 2801 bytes --]

From cf4dba3899eef0a88bf4032bec5cf45c56a77077 Mon Sep 17 00:00:00 2001
From: Daanturo <daanturo@gmail.com>
Date: Thu, 17 Nov 2022 13:57:20 +0700
Subject: [PATCH] Define macro dlet*

* lisp/subr.el: implementation.
* doc/lispref/variables.texi: documentation.
* etc/NEWS: announce it, also add dlet's non-backward compatible
breakage.
---
 doc/lispref/variables.texi |  8 ++++++++
 etc/NEWS                   | 10 ++++++++++
 lisp/subr.el               |  8 ++++++++
 3 files changed, 26 insertions(+)

diff --git a/doc/lispref/variables.texi b/doc/lispref/variables.texi
index 7206f2acd2..c574ffaf09 100644
--- a/doc/lispref/variables.texi
+++ b/doc/lispref/variables.texi
@@ -303,6 +303,14 @@ Binding}), but it's impractical to @code{defvar} these variables.
 the forms, and then make the variables non-special again.
 @end defspec
 
+@defspec dlet* (bindings@dots{}) forms@dots{}
+This form is like @code{dlet}, but each valueform can refer to the
+symbols already bound previously, like what @code{let*} is to
+@code{let} (actually this is Emacs 28's old @code{dlet}, as from Emacs
+29 it no longer let bindings refer to the preceding symbols in this
+same form).
+@end defspec
+
 @defspec named-let name bindings &rest body
 This special form is a looping construct inspired from the
 Scheme language.  It is similar to @code{let}: It binds the variables in
diff --git a/etc/NEWS b/etc/NEWS
index 0b8f4539f9..1e9b1ce279 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -2913,6 +2913,10 @@ when visiting JSON files.
 \f
 * Incompatible Lisp Changes in Emacs 29.1
 
++++
+** dlet now uses let internally instead of let*.
+---
+
 +++
 ** 'format-prompt' now uses 'substitute-command-keys'.
 This means that both the prompt and 'minibuffer-default-prompt-format'
@@ -3269,6 +3273,12 @@ The following generalized variables have been made obsolete:
 \f
 * Lisp Changes in Emacs 29.1
 
+
++++
+** New macro 'dlet*'.
+Like what 'let*' is to 'let', functionally identical to the old 'dlet'
+in Emacs 28.
+
 +++
 ** Interpreted closures are "safe for space".
 As was already the case for byte-compiled closures, instead of capturing
diff --git a/lisp/subr.el b/lisp/subr.el
index 6b83196d05..ddc48b554e 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -2155,6 +2155,14 @@ all symbols are bound before any of the VALUEFORMs are evalled."
                binders)
      (let ,binders ,@body)))
 
+(defmacro dlet* (binders &rest body)
+  "Like `let*' but using dynamic scoping."
+  (declare (indent 1) (debug let))
+  `(let (_)
+     ,@(mapcar (lambda (binder)
+                 `(defvar ,(if (consp binder) (car binder) binder)))
+               binders)
+     (let ,binders ,@body)))
 
 (defmacro with-wrapper-hook (hook args &rest body)
   "Run BODY, using wrapper functions from HOOK with additional ARGS.
-- 
2.38.1


             reply	other threads:[~2022-11-17  7:13 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-17  7:13 daanturo [this message]
2022-11-17  7:25 ` bug#59333: [PATCH] Define macro dlet* Eli Zaretskii
2022-11-17  7:40   ` Daan Ro
2022-11-19  4:37     ` Jean Louis
2022-11-17 13:22   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-17 13:36     ` Mattias Engdegård
2022-11-25  0:14       ` Stefan Kangas
2022-11-19  4:28   ` Jean Louis
2022-11-19  4:47 ` Jean Louis
2022-11-19  5:29   ` daanturo

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=0e8ca5ce-a413-0dd0-c62e-647d19953a3b@gmail.com \
    --to=daanturo@gmail.com \
    --cc=59333@debbugs.gnu.org \
    /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.