From 4429f97b58653540985387caa554fc0f25f90000 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Sat, 17 Feb 2018 14:26:49 +0200 Subject: [PATCH] Make echo-area buffers almost always multibyte * src/xdisp.c (setup_echo_area_for_printing, set_message_1): Ensure the echo-area buffer is multibyte, unless unibyte-display-via-language-environment is non-nil, and the text we are to display is or could be unibyte. (Bug#30405) --- src/xdisp.c | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/src/xdisp.c b/src/xdisp.c index 7c90d32db69..f6fcdec6624 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -10982,10 +10982,18 @@ setup_echo_area_for_printing (bool multibyte_p) } TEMP_SET_PT_BOTH (BEG, BEG_BYTE); - /* Set up the buffer for the multibyteness we need. */ - if (multibyte_p - != !NILP (BVAR (current_buffer, enable_multibyte_characters))) - Fset_buffer_multibyte (multibyte_p ? Qt : Qnil); + /* Set up the buffer for the multibyteness we need. We always + set it to be multibyte, except when + unibyte-display-via-language-environment is non-nil and the + buffer from which we are called is unibyte, because in that + case unibyte characters should not be displayed as octal + escapes. */ + if (unibyte_display_via_language_environment + && !multibyte_p + && !NILP (BVAR (current_buffer, enable_multibyte_characters))) + Fset_buffer_multibyte (Qnil); + else if (NILP (BVAR (current_buffer, enable_multibyte_characters))) + Fset_buffer_multibyte (Qt); /* Raise the frame containing the echo area. */ if (minibuffer_auto_raise) @@ -11431,10 +11439,17 @@ set_message_1 (ptrdiff_t a1, Lisp_Object string) { eassert (STRINGP (string)); - /* Change multibyteness of the echo buffer appropriately. */ - if (message_enable_multibyte - != !NILP (BVAR (current_buffer, enable_multibyte_characters))) - Fset_buffer_multibyte (message_enable_multibyte ? Qt : Qnil); + /* Change multibyteness of the echo buffer appropriately. We always + set it to be multibyte, except when + unibyte-display-via-language-environment is non-nil and the + string to display is unibyte, because in that case unibyte + characters should not be displayed as octal escapes. */ + if (!message_enable_multibyte + && unibyte_display_via_language_environment + && !NILP (BVAR (current_buffer, enable_multibyte_characters))) + Fset_buffer_multibyte (Qnil); + else if (NILP (BVAR (current_buffer, enable_multibyte_characters))) + Fset_buffer_multibyte (Qt); bset_truncate_lines (current_buffer, message_truncate_lines ? Qt : Qnil); if (!NILP (BVAR (current_buffer, bidi_display_reordering))) -- 2.39.2