Re: master 3586fef: Make HIST arg of read-from-minibuffer work with buffer-local vars

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: master 3586fef: Make HIST arg of read-from-minibuffer work with buffer-local vars

Stefan Monnier
> @@ -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 | Threaded
Open this post in threaded view
|

Re: master 3586fef: Make HIST arg of read-from-minibuffer work with buffer-local vars

Federico Tedin
> 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.

Hey Stefan,

Would that mean moving the `add-to-history' call to after the final call
to `unbind_to(count, val)'?

- Fede

Reply | Threaded
Open this post in threaded view
|

Re: master 3586fef: Make HIST arg of read-from-minibuffer work with buffer-local vars

Stefan Monnier
>> 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.
> Would that mean moving the `add-to-history' call to after the final call
> to `unbind_to(count, val)'?

Yes, I think that's basically all it takes.


        Stefan


Reply | Threaded
Open this post in threaded view
|

Re: master 3586fef: Make HIST arg of read-from-minibuffer work with buffer-local vars

Federico Tedin
Hey Stefan, here's a patch with the changes you suggested.

Note that I changed the use of Vminibuffer_history_variable for histvar
in the call to `add-to-history', since the value of
Vminibuffer_history_variable was being restored to its original value
after `read_minibuf_unwind' was called at the end of the function.

Thanks!


minibuf.patch (2K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: master 3586fef: Make HIST arg of read-from-minibuffer work with buffer-local vars

Stefan Monnier
> Hey Stefan, here's a patch with the changes you suggested.

Looks great, thanks,


        Stefan


Reply | Threaded
Open this post in threaded view
|

Re: master 3586fef: Make HIST arg of read-from-minibuffer work with buffer-local vars

Federico Tedin
Hey Stefan,

I can't find the patch on master branch - friendly reminder to install it
when you have the time.

Thanks!
- Fede

Reply | Threaded
Open this post in threaded view
|

Re: master 3586fef: Make HIST arg of read-from-minibuffer work with buffer-local vars

Stefan Monnier
> I can't find the patch on master branch - friendly reminder to install it
> when you have the time.

Done, thank you (sorry, I thought you had write access),


        Stefan


Reply | Threaded
Open this post in threaded view
|

Re: master 3586fef: Make HIST arg of read-from-minibuffer work with buffer-local vars

Federico Tedin
>> I can't find the patch on master branch - friendly reminder to install it
>> when you have the time.
>
> Done, thank you (sorry, I thought you had write access),
>
>
>         Stefan

No problem, thanks!