1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-11-26 07:33:47 +00:00

* 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.
This commit is contained in:
Stefan Monnier 2021-04-20 08:51:44 -04:00
parent 4da7b2dfee
commit efbc07ab57

View File

@ -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);