]> git.eshelyaron.com Git - emacs.git/commitdiff
print_error_message: Handle user-error to the echo area specially
authorSean Whitton <spwhitton@spwhitton.name>
Mon, 7 Jul 2025 08:57:37 +0000 (09:57 +0100)
committerEshel Yaron <me@eshelyaron.com>
Thu, 24 Jul 2025 07:54:35 +0000 (09:54 +0200)
* src/print.c (print_error_message): For a user-error that is to
be printed to the echo area, use message3 in order to preserve
fontification.

(cherry picked from commit b03f11d9ac867833a504a2184620e531fbe43a44)

src/print.c

index c14e6e1419e3e7d1ba0cbcb0151fd6f0d4ccb5c6..fa80074349743418d48f94dbaa6c9fd010424637 100644 (file)
@@ -1118,6 +1118,19 @@ print_error_message (Lisp_Object data, Lisp_Object stream, const char *context,
 
   tail = Fcdr_safe (data);
 
+  /* For a user-error displayed in the echo area, use message3 rather
+     than Fprinc in order to preserve fontification.
+     In particular, there might be hints to the user about key sequences
+     they could type to do what they seemed to want.  */
+  if (EQ (errname, Quser_error) && EQ (stream, Qt)
+      /* These should always be true for a user-error, but check, lest
+        we throw any information away.  */
+      && !NILP (XCAR (tail)) && NILP (XCDR (tail)))
+    {
+      message3 (XCAR (tail));
+      return;
+    }
+
   /* For file-error, make error message by concatenating
      all the data items.  They are all strings.  */
   if (!NILP (file_error) && CONSP (tail))