emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 768676f: Improve display of raw bytes in the echo-area


From: Eli Zaretskii
Subject: master 768676f: Improve display of raw bytes in the echo-area
Date: Sun, 27 Sep 2020 01:28:05 -0400 (EDT)

branch: master
commit 768676f74f093e75e2d7e04e18e1fd1836d1e7e9
Author: Eli Zaretskii <eliz@gnu.org>
Commit: Eli Zaretskii <eliz@gnu.org>

    Improve display of raw bytes in the echo-area
    
    * src/print.c (print_object): When printing a unibyte string,
    convert non-ASCII bytes to their character code, before sending
    them to 'printchar'.  (Bug#43632)
---
 src/print.c | 50 +++++++++++++++++++++++++++-----------------------
 1 file changed, 27 insertions(+), 23 deletions(-)

diff --git a/src/print.c b/src/print.c
index 0ecc98f..dca095f 100644
--- a/src/print.c
+++ b/src/print.c
@@ -1929,7 +1929,7 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, 
bool escapeflag)
          ptrdiff_t i, i_byte;
          ptrdiff_t size_byte;
          /* True means we must ensure that the next character we output
-            cannot be taken as part of a hex character escape.  */
+            cannot be taken as part of a hex character escape.  */
          bool need_nonhex = false;
          bool multibyte = STRING_MULTIBYTE (obj);
 
@@ -1976,25 +1976,29 @@ print_object (Lisp_Object obj, Lisp_Object 
printcharfun, bool escapeflag)
                  /* If we just had a hex escape, and this character
                     could be taken as part of it,
                     output `\ ' to prevent that.  */
-                  if (c_isxdigit (c))
-                    {
-                      if (need_nonhex)
-                        print_c_string ("\\ ", printcharfun);
-                      printchar (c, printcharfun);
-                    }
-                  else if (c == '\n' && print_escape_newlines
-                           ? (c = 'n', true)
-                           : c == '\f' && print_escape_newlines
-                           ? (c = 'f', true)
-                           : c == '\"' || c == '\\')
-                    {
-                      printchar ('\\', printcharfun);
-                      printchar (c, printcharfun);
-                    }
-                  else if (print_escape_control_characters && c_iscntrl (c))
+                 if (c_isxdigit (c))
+                   {
+                     if (need_nonhex)
+                       print_c_string ("\\ ", printcharfun);
+                     printchar (c, printcharfun);
+                   }
+                 else if (c == '\n' && print_escape_newlines
+                          ? (c = 'n', true)
+                          : c == '\f' && print_escape_newlines
+                          ? (c = 'f', true)
+                          : c == '\"' || c == '\\')
+                   {
+                     printchar ('\\', printcharfun);
+                     printchar (c, printcharfun);
+                   }
+                 else if (print_escape_control_characters && c_iscntrl (c))
                    octalout (c, SDATA (obj), i_byte, size_byte, printcharfun);
-                  else
-                    printchar (c, printcharfun);
+                 else if (!multibyte
+                          && SINGLE_BYTE_CHAR_P (c)
+                          && !ASCII_CHAR_P (c))
+                   printchar (BYTE8_TO_CHAR (c), printcharfun);
+                 else
+                   printchar (c, printcharfun);
                  need_nonhex = false;
                }
            }
@@ -2024,7 +2028,7 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, 
bool escapeflag)
                          && len == size_byte);
 
        if (! NILP (Vprint_gensym)
-            && !SYMBOL_INTERNED_IN_INITIAL_OBARRAY_P (obj))
+           && !SYMBOL_INTERNED_IN_INITIAL_OBARRAY_P (obj))
          print_c_string ("#:", printcharfun);
        else if (size_byte == 0)
          {
@@ -2047,7 +2051,7 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, 
bool escapeflag)
                    || c == ',' || c == '.' || c == '`'
                    || c == '[' || c == ']' || c == '?' || c <= 040
                    || c == NO_BREAK_SPACE
-                    || confusing)
+                   || confusing)
                  {
                    printchar ('\\', printcharfun);
                    confusing = false;
@@ -2112,7 +2116,7 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, 
bool escapeflag)
 
                  if (!NILP (Vprint_circle))
                    {
-                     /* With the print-circle feature.  */
+                     /* With the print-circle feature.  */
                      Lisp_Object num = Fgethash (obj, Vprint_number_table,
                                                  Qnil);
                      if (FIXNUMP (num))
@@ -2164,7 +2168,7 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, 
bool escapeflag)
       {
        int len;
        /* We're in trouble if this happens!
-          Probably should just emacs_abort ().  */
+          Probably should just emacs_abort ().  */
        print_c_string ("#<EMACS BUG: INVALID DATATYPE ", printcharfun);
        if (VECTORLIKEP (obj))
          len = sprintf (buf, "(PVEC 0x%08zx)", (size_t) ASIZE (obj));



reply via email to

[Prev in Thread] Current Thread [Next in Thread]