From: Thuna <thuna.cing@gmail.com>
To: 72334@debbugs.gnu.org
Subject: bug#72334: [PATCH] Always print commas and comma-ats specially
Date: Sun, 28 Jul 2024 15:30:40 +0200 [thread overview]
Message-ID: <874j893apr.fsf@gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 565 bytes --]
In 55481 the recursion was fixed but backquotes and comma(-at)s were
left as-is, so as to print comma(-at)s specially only if they are
escaping a backquote.
This is not particularly useful (and I would argue is bad), so something
like the attached patch could be a good starting point to make it so
that they are always printed specially (given `print-quoted' is non-nil
and it is a proper list of length two - the usual checks for other
quoted forms), which also solves(maybe? - it was not the primary goal)
the recursion. Feel free to change or drop whatever.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Always-print-commas-and-comma-ats-specially-with-pri.patch --]
[-- Type: text/x-patch, Size: 2709 bytes --]
From bdb1af8498b523c7e80a02675035037884a2f1d0 Mon Sep 17 00:00:00 2001
From: Thuna <thuna.cing@gmail.com>
Date: Sun, 28 Jul 2024 14:45:40 +0200
Subject: [PATCH] Always print commas and comma-ats specially with print-quoted
---
src/print.c | 47 +++++++++++++++--------------------------------
1 file changed, 15 insertions(+), 32 deletions(-)
diff --git a/src/print.c b/src/print.c
index 8f28b14e8b6..256f19aeb90 100644
--- a/src/print.c
+++ b/src/print.c
@@ -2488,43 +2488,26 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag)
&& print_depth > XFIXNUM (Vprint_level))
print_c_string ("...", printcharfun);
else if (print_quoted && CONSP (XCDR (obj)) && NILP (XCDR (XCDR (obj)))
- && EQ (XCAR (obj), Qquote))
+ && (EQ (XCAR (obj), Qquote) ||
+ EQ (XCAR (obj), Qfunction) ||
+ EQ (XCAR (obj), Qbackquote) ||
+ EQ (XCAR (obj), Qcomma) ||
+ EQ (XCAR (obj), Qcomma_at)))
{
- printchar ('\'', printcharfun);
+ if (EQ (XCAR (obj), Qquote))
+ printchar ('\'', printcharfun);
+ else if (EQ (XCAR (obj), Qfunction))
+ print_c_string("#'", printcharfun);
+ else if (EQ (XCAR (obj), Qbackquote))
+ printchar ('`', printcharfun);
+ else if (EQ (XCAR (obj), Qcomma))
+ printchar (',', printcharfun);
+ else if (EQ (XCAR (obj), Qcomma_at))
+ print_c_string (",@", printcharfun);
obj = XCAR (XCDR (obj));
--print_depth; /* tail recursion */
goto print_obj;
}
- else if (print_quoted && CONSP (XCDR (obj)) && NILP (XCDR (XCDR (obj)))
- && EQ (XCAR (obj), Qfunction))
- {
- print_c_string ("#'", printcharfun);
- obj = XCAR (XCDR (obj));
- --print_depth; /* tail recursion */
- goto print_obj;
- }
- /* FIXME: Do we really need the new_backquote_output gating of
- special syntax for comma and comma-at? There is basically no
- benefit from it at all, and it would be nice to get rid of
- the recursion here without additional complexity. */
- else if (print_quoted && CONSP (XCDR (obj)) && NILP (XCDR (XCDR (obj)))
- && EQ (XCAR (obj), Qbackquote))
- {
- printchar ('`', printcharfun);
- new_backquote_output++;
- print_object (XCAR (XCDR (obj)), printcharfun, escapeflag);
- new_backquote_output--;
- }
- else if (print_quoted && CONSP (XCDR (obj)) && NILP (XCDR (XCDR (obj)))
- && (EQ (XCAR (obj), Qcomma)
- || EQ (XCAR (obj), Qcomma_at))
- && new_backquote_output)
- {
- print_object (XCAR (obj), printcharfun, false);
- new_backquote_output--;
- print_object (XCAR (XCDR (obj)), printcharfun, escapeflag);
- new_backquote_output++;
- }
else
{
printchar ('(', printcharfun);
--
2.44.2
reply other threads:[~2024-07-28 13:30 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=874j893apr.fsf@gmail.com \
--to=thuna.cing@gmail.com \
--cc=72334@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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).