diff options
| author | Federico Tedin | 2019-12-06 01:23:25 +0100 |
|---|---|---|
| committer | Stefan Monnier | 2019-12-10 11:12:23 -0500 |
| commit | 9042ece787cf93665776ffb69893fcb1357aacbe (patch) | |
| tree | 9abe945ddc4f510c56fd392231c21fb88f04a381 /src | |
| parent | 0f9c016a52a396cce9e0f1cc2ee35b0524d917ef (diff) | |
| download | emacs-9042ece787cf93665776ffb69893fcb1357aacbe.tar.gz emacs-9042ece787cf93665776ffb69893fcb1357aacbe.zip | |
Simplify call to add-to-history in read_minibuf
* src/minibuf.c (read_minibuf): Avoid restoring the previous buffer,
as this is already done at the end of the function; call
`add-to-history' after that point.
Diffstat (limited to 'src')
| -rw-r--r-- | src/minibuf.c | 29 |
1 files changed, 10 insertions, 19 deletions
diff --git a/src/minibuf.c b/src/minibuf.c index bdae01dbc58..f8790f55070 100644 --- a/src/minibuf.c +++ b/src/minibuf.c | |||
| @@ -353,7 +353,7 @@ read_minibuf (Lisp_Object map, Lisp_Object initial, Lisp_Object prompt, | |||
| 353 | Lisp_Object histvar, Lisp_Object histpos, Lisp_Object defalt, | 353 | Lisp_Object histvar, Lisp_Object histpos, Lisp_Object defalt, |
| 354 | bool allow_props, bool inherit_input_method) | 354 | bool allow_props, bool inherit_input_method) |
| 355 | { | 355 | { |
| 356 | Lisp_Object val, previous_buffer = Fcurrent_buffer (); | 356 | Lisp_Object val; |
| 357 | ptrdiff_t count = SPECPDL_INDEX (); | 357 | ptrdiff_t count = SPECPDL_INDEX (); |
| 358 | Lisp_Object mini_frame, ambient_dir, minibuffer, input_method; | 358 | Lisp_Object mini_frame, ambient_dir, minibuffer, input_method; |
| 359 | Lisp_Object enable_multibyte; | 359 | Lisp_Object enable_multibyte; |
| @@ -696,30 +696,21 @@ read_minibuf (Lisp_Object map, Lisp_Object initial, Lisp_Object prompt, | |||
| 696 | else | 696 | else |
| 697 | histstring = Qnil; | 697 | histstring = Qnil; |
| 698 | 698 | ||
| 699 | /* Add the value to the appropriate history list, if any. */ | ||
| 700 | if (! (NILP (Vhistory_add_new_input) || NILP (histstring))) | ||
| 701 | { | ||
| 702 | ptrdiff_t count2 = SPECPDL_INDEX (); | ||
| 703 | |||
| 704 | /* If possible, switch back to the previous buffer first, in | ||
| 705 | case the history variable is buffer-local. */ | ||
| 706 | if (BUFFER_LIVE_P (XBUFFER (previous_buffer))) | ||
| 707 | { | ||
| 708 | record_unwind_current_buffer (); | ||
| 709 | Fset_buffer (previous_buffer); | ||
| 710 | } | ||
| 711 | |||
| 712 | call2 (intern ("add-to-history"), Vminibuffer_history_variable, histstring); | ||
| 713 | unbind_to (count2, Qnil); | ||
| 714 | } | ||
| 715 | |||
| 716 | /* If Lisp form desired instead of string, parse it. */ | 699 | /* If Lisp form desired instead of string, parse it. */ |
| 717 | if (expflag) | 700 | if (expflag) |
| 718 | val = string_to_object (val, defalt); | 701 | val = string_to_object (val, defalt); |
| 719 | 702 | ||
| 720 | /* The appropriate frame will get selected | 703 | /* The appropriate frame will get selected |
| 721 | in set-window-configuration. */ | 704 | in set-window-configuration. */ |
| 722 | return unbind_to (count, val); | 705 | unbind_to (count, Qnil); |
| 706 | |||
| 707 | /* Add the value to the appropriate history list, if any. This is | ||
| 708 | done after the previous buffer has been made current again, in | ||
| 709 | case the history variable is buffer-local. */ | ||
| 710 | if (! (NILP (Vhistory_add_new_input) || NILP (histstring))) | ||
| 711 | call2 (intern ("add-to-history"), histvar, histstring); | ||
| 712 | |||
| 713 | return val; | ||
| 723 | } | 714 | } |
| 724 | 715 | ||
| 725 | /* Return a buffer to be used as the minibuffer at depth `depth'. | 716 | /* Return a buffer to be used as the minibuffer at depth `depth'. |