From: Stefan Monnier Date: Tue, 20 Apr 2021 12:51:44 +0000 (-0400) Subject: * src/minibuf.c (read_minibuf): Change multibyte more safely X-Git-Tag: emacs-28.0.90~2804 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=efbc07ab57c403bb20958132c63f44dad91f55a0;p=emacs.git * src/minibuf.c (read_minibuf): Change multibyte more safely We used to `bset_enable_multibyte_characters` while the buffer is not empty, putting the buffer temporarily in an inconsistent state. Further simplifications along the way: Prefer re-using local var `histvar` and let `insert` do the unibyte<->multibyte conversion if needed. --- diff --git a/src/minibuf.c b/src/minibuf.c index b823224a5f2..89d9357b4ed 100644 --- a/src/minibuf.c +++ b/src/minibuf.c @@ -728,10 +728,10 @@ read_minibuf (Lisp_Object map, Lisp_Object initial, Lisp_Object prompt, Vminibuffer_completing_file_name = Qlambda; /* If variable is unbound, make it nil. */ - histval = find_symbol_value (Vminibuffer_history_variable); + histval = find_symbol_value (histvar); if (EQ (histval, Qunbound)) { - Fset (Vminibuffer_history_variable, Qnil); + Fset (histvar, Qnil); histval = Qnil; } @@ -753,10 +753,6 @@ read_minibuf (Lisp_Object map, Lisp_Object initial, Lisp_Object prompt, not work correctly in minibuffers. (Bug#5715, etc) */ bset_truncate_lines (current_buffer, Qnil); - /* If appropriate, copy enable-multibyte-characters into the minibuffer. */ - if (inherit_input_method) - bset_enable_multibyte_characters (current_buffer, enable_multibyte); - /* The current buffer's default directory is usually the right thing for our minibuffer here. However, if you're typing a command at a minibuffer-only frame when minibuf_level is zero, then buf IS @@ -808,9 +804,11 @@ read_minibuf (Lisp_Object map, Lisp_Object initial, Lisp_Object prompt, specbind (Qinhibit_modification_hooks, Qt); Ferase_buffer (); - if (!NILP (BVAR (current_buffer, enable_multibyte_characters)) - && ! STRING_MULTIBYTE (minibuf_prompt)) - minibuf_prompt = Fstring_make_multibyte (minibuf_prompt); + /* If appropriate, copy enable-multibyte-characters into the minibuffer. + In any case don't blindly inherit the multibyteness used previously. */ + bset_enable_multibyte_characters (current_buffer, + inherit_input_method ? enable_multibyte + : Qt); /* Insert the prompt, record where it ends. */ Finsert (1, &minibuf_prompt);