From 9fb7129305282105e748b41d7c23ff0d319a2e73 Mon Sep 17 00:00:00 2001 From: Kenichi Handa Date: Wed, 24 Feb 1999 02:31:57 +0000 Subject: [PATCH] (push_key_description): If enable-multibyte-characters is non-nil, try to convert unibyte character to multibyte. For invalid multibyte character, show all bits by octal form. (Fsingle_key_description): Check the varidity of charset for a generic character. --- src/keymap.c | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/src/keymap.c b/src/keymap.c index caf4300187f..865e8dd3202 100644 --- a/src/keymap.c +++ b/src/keymap.c @@ -1845,26 +1845,38 @@ push_key_description (c, p) *p++ = 'L'; } else if (c == ' ') - { + { *p++ = 'S'; *p++ = 'P'; *p++ = 'C'; } else if (c < 128) *p++ = c; - else if (c < 512) - { - *p++ = '\\'; - *p++ = (7 & (c >> 6)) + '0'; - *p++ = (7 & (c >> 3)) + '0'; - *p++ = (7 & (c >> 0)) + '0'; - } else { - unsigned char work[4], *str; - int i = CHAR_STRING (c, work, str); - bcopy (str, p, i); - p += i; + if (! NILP (current_buffer->enable_multibyte_characters)) + c = unibyte_char_to_multibyte (c); + + if (NILP (current_buffer->enable_multibyte_characters) + || SINGLE_BYTE_CHAR_P (c) + || ! char_valid_p (c, 0)) + { + int bit_offset; + *p++ = '\\'; + /* The biggest character code uses 19 bits. */ + for (bit_offset = 18; bit_offset >= 0; bit_offset -= 3) + { + if (c >= (1 << bit_offset)) + *p++ = ((c & (7 << bit_offset)) >> bit_offset) + '0'; + } + } + else + { + unsigned char work[4], *str; + int i = CHAR_STRING (c, work, str); + bcopy (str, p, i); + p += i; + } } return p; @@ -1894,6 +1906,7 @@ Control characters turn into C-whatever, etc.") SPLIT_NON_ASCII_CHAR (without_bits, charset, c1, c2); if (charset + && CHARSET_DEFINED_P (charset) && ((c1 >= 0 && c1 < 32) || (c2 >= 0 && c2 < 32))) { -- 2.39.2