unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#72334: [PATCH] Always print commas and comma-ats specially
@ 2024-07-28 13:30 Thuna
  0 siblings, 0 replies; only message in thread
From: Thuna @ 2024-07-28 13:30 UTC (permalink / raw)
  To: 72334

[-- 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


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2024-07-28 13:30 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-28 13:30 bug#72334: [PATCH] Always print commas and comma-ats specially Thuna

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).