Subject: bug#31376: 26.0.50; print-charset-text-property not honored

From: Noam Postavsky <[email-masked]>
Date: Fri, 11 May 2018 13:44:46 -0400

On 11 May 2018 at 09:31, Eli Zaretskii <[email-masked]> wrote:

> Can someone see any difference between the value t and 'default', wrt
                                                   ^
                                                   nil
> when/how the 'charset' property of strings is printed?

Assuming you meant nil, then no, I can't see any difference. As far as
I can tell, setting to 'default' just makes Emacs do pointless extra
checking for "unsafe" charsets even after it has found one.

> I think the behavior under the value of nil is actually intended for
> 'default', and the value of nil is not implemented.  So I think we
> should have a change in print_check_string_charset_prop that sets the
> PRINT_STRING_UNSAFE_CHARSET_FOUND flag whenever it finds _any_
> 'charset' property on the string.

It looks like the NILP (Vprint_charset_text_property) check is just in
the wrong place, if I move it to print_prune_string_charset then it
seems to work as documented.

--- i/src/print.c
+++ w/src/print.c
@@ -1317,8 +1317,7 @@ print_check_string_charset_prop (INTERVAL interval,
          || CONSP (XCDR (XCDR (val))))
        print_check_string_result |= PRINT_STRING_NON_CHARSET_FOUND;
     }
-  if (NILP (Vprint_charset_text_property)
-      || ! (print_check_string_result & PRINT_STRING_UNSAFE_CHARSET_FOUND))
+  if (! (print_check_string_result & PRINT_STRING_UNSAFE_CHARSET_FOUND))
     {
       int i, c;
       ptrdiff_t charpos = interval->position;
@@ -1348,7 +1347,8 @@ print_prune_string_charset (Lisp_Object string)
   print_check_string_result = 0;
   traverse_intervals (string_intervals (string), 0,
                      print_check_string_charset_prop, string);
-  if (! (print_check_string_result & PRINT_STRING_UNSAFE_CHARSET_FOUND))
+  if (NILP (Vprint_charset_text_property)
+      || ! (print_check_string_result & PRINT_STRING_UNSAFE_CHARSET_FOUND))
     {
       string = Fcopy_sequence (string);
       if (print_check_string_result & PRINT_STRING_NON_CHARSET_FOUND)