]> git.eshelyaron.com Git - emacs.git/commitdiff
* src/minibuf.c (read_minibuf): Change multibyte more safely
authorStefan Monnier <monnier@iro.umontreal.ca>
Tue, 20 Apr 2021 12:51:44 +0000 (08:51 -0400)
committerStefan Monnier <monnier@iro.umontreal.ca>
Tue, 20 Apr 2021 12:52:04 +0000 (08:52 -0400)
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.

src/minibuf.c

index b823224a5f266c1761c2378250bb892c84cd50c6..89d9357b4edead480a84531f0f22a7c28387ec3a 100644 (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);