emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: master 3586fef: Make HIST arg of read-from-minibuffer work with buff


From: Stefan Monnier
Subject: Re: master 3586fef: Make HIST arg of read-from-minibuffer work with buffer-local vars
Date: Thu, 05 Dec 2019 08:56:10 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

> @@ -698,7 +698,20 @@ read_minibuf (Lisp_Object map, Lisp_Object initial, 
> Lisp_Object prompt,
>  
>    /* Add the value to the appropriate history list, if any.  */
>    if (! (NILP (Vhistory_add_new_input) || NILP (histstring)))
> -    call2 (intern ("add-to-history"), Vminibuffer_history_variable, 
> histstring);
> +    {
> +      ptrdiff_t count2 = SPECPDL_INDEX ();
> +
> +      /* If possible, switch back to the previous buffer first, in
> +      case the history variable is buffer-local.  */
> +      if (BUFFER_LIVE_P (XBUFFER (previous_buffer)))
> +     {
> +       record_unwind_current_buffer ();
> +       Fset_buffer (previous_buffer);
> +     }
> +
> +      call2 (intern ("add-to-history"), Vminibuffer_history_variable, 
> histstring);
> +      unbind_to (count2, Qnil);
> +    }
>  
>    /* If Lisp form desired instead of string, parse it.  */
>    if (expflag)

Note that this `add-to-history` call takes place at the very end of
read_minibuf, hence just *before* we return to previous_buffer.
Maybe a simpler option than the code above is to postpone the code
a little bit so that it takes place *after* we return to
previous_buffer.


        Stefan




reply via email to

[Prev in Thread] Current Thread [Next in Thread]