diff options
| author | Stefan Monnier | 2021-04-20 08:51:44 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2021-04-20 08:52:04 -0400 |
| commit | efbc07ab57c403bb20958132c63f44dad91f55a0 (patch) | |
| tree | fd527834252808f60fd2d3bdb2cfdf656caf9f25 /src | |
| parent | 4da7b2dfeec82ad0fac987d2628048e85f222258 (diff) | |
| download | emacs-efbc07ab57c403bb20958132c63f44dad91f55a0.tar.gz emacs-efbc07ab57c403bb20958132c63f44dad91f55a0.zip | |
* 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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/minibuf.c | 16 |
1 files changed, 7 insertions, 9 deletions
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, | |||
| 728 | Vminibuffer_completing_file_name = Qlambda; | 728 | Vminibuffer_completing_file_name = Qlambda; |
| 729 | 729 | ||
| 730 | /* If variable is unbound, make it nil. */ | 730 | /* If variable is unbound, make it nil. */ |
| 731 | histval = find_symbol_value (Vminibuffer_history_variable); | 731 | histval = find_symbol_value (histvar); |
| 732 | if (EQ (histval, Qunbound)) | 732 | if (EQ (histval, Qunbound)) |
| 733 | { | 733 | { |
| 734 | Fset (Vminibuffer_history_variable, Qnil); | 734 | Fset (histvar, Qnil); |
| 735 | histval = Qnil; | 735 | histval = Qnil; |
| 736 | } | 736 | } |
| 737 | 737 | ||
| @@ -753,10 +753,6 @@ read_minibuf (Lisp_Object map, Lisp_Object initial, Lisp_Object prompt, | |||
| 753 | not work correctly in minibuffers. (Bug#5715, etc) */ | 753 | not work correctly in minibuffers. (Bug#5715, etc) */ |
| 754 | bset_truncate_lines (current_buffer, Qnil); | 754 | bset_truncate_lines (current_buffer, Qnil); |
| 755 | 755 | ||
| 756 | /* If appropriate, copy enable-multibyte-characters into the minibuffer. */ | ||
| 757 | if (inherit_input_method) | ||
| 758 | bset_enable_multibyte_characters (current_buffer, enable_multibyte); | ||
| 759 | |||
| 760 | /* The current buffer's default directory is usually the right thing | 756 | /* The current buffer's default directory is usually the right thing |
| 761 | for our minibuffer here. However, if you're typing a command at | 757 | for our minibuffer here. However, if you're typing a command at |
| 762 | a minibuffer-only frame when minibuf_level is zero, then buf IS | 758 | 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, | |||
| 808 | specbind (Qinhibit_modification_hooks, Qt); | 804 | specbind (Qinhibit_modification_hooks, Qt); |
| 809 | Ferase_buffer (); | 805 | Ferase_buffer (); |
| 810 | 806 | ||
| 811 | if (!NILP (BVAR (current_buffer, enable_multibyte_characters)) | 807 | /* If appropriate, copy enable-multibyte-characters into the minibuffer. |
| 812 | && ! STRING_MULTIBYTE (minibuf_prompt)) | 808 | In any case don't blindly inherit the multibyteness used previously. */ |
| 813 | minibuf_prompt = Fstring_make_multibyte (minibuf_prompt); | 809 | bset_enable_multibyte_characters (current_buffer, |
| 810 | inherit_input_method ? enable_multibyte | ||
| 811 | : Qt); | ||
| 814 | 812 | ||
| 815 | /* Insert the prompt, record where it ends. */ | 813 | /* Insert the prompt, record where it ends. */ |
| 816 | Finsert (1, &minibuf_prompt); | 814 | Finsert (1, &minibuf_prompt); |