* Re: master 3586fef: Make HIST arg of read-from-minibuffer work with buffer-local vars [not found] ` <20191205093043.1A8E0209BE@vcs0.savannah.gnu.org> @ 2019-12-05 13:56 ` Stefan Monnier 2019-12-05 16:50 ` Federico Tedin 0 siblings, 1 reply; 8+ messages in thread From: Stefan Monnier @ 2019-12-05 13:56 UTC (permalink / raw) To: Federico Tedin; +Cc: emacs-devel > @@ -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 ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: master 3586fef: Make HIST arg of read-from-minibuffer work with buffer-local vars 2019-12-05 13:56 ` master 3586fef: Make HIST arg of read-from-minibuffer work with buffer-local vars Stefan Monnier @ 2019-12-05 16:50 ` Federico Tedin 2019-12-05 19:17 ` Stefan Monnier 0 siblings, 1 reply; 8+ messages in thread From: Federico Tedin @ 2019-12-05 16:50 UTC (permalink / raw) To: Stefan Monnier; +Cc: emacs-devel > 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 ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: master 3586fef: Make HIST arg of read-from-minibuffer work with buffer-local vars 2019-12-05 16:50 ` Federico Tedin @ 2019-12-05 19:17 ` Stefan Monnier 2019-12-06 0:36 ` Federico Tedin 0 siblings, 1 reply; 8+ messages in thread From: Stefan Monnier @ 2019-12-05 19:17 UTC (permalink / raw) To: Federico Tedin; +Cc: emacs-devel >> 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 ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: master 3586fef: Make HIST arg of read-from-minibuffer work with buffer-local vars 2019-12-05 19:17 ` Stefan Monnier @ 2019-12-06 0:36 ` Federico Tedin 2019-12-06 1:57 ` Stefan Monnier 0 siblings, 1 reply; 8+ messages in thread From: Federico Tedin @ 2019-12-06 0:36 UTC (permalink / raw) To: Stefan Monnier; +Cc: emacs-devel [-- Attachment #1: Type: text/plain, Size: 331 bytes --] 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! [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: patch --] [-- Type: text/x-diff, Size: 2421 bytes --] From cb1cc374bfb1a5fc5ded8bed55b7f2641925f47a Mon Sep 17 00:00:00 2001 From: Federico Tedin <federicotedin@gmail.com> Date: Fri, 6 Dec 2019 01:23:25 +0100 Subject: [PATCH 1/1] 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. --- src/minibuf.c | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/src/minibuf.c b/src/minibuf.c index bdae01dbc5..f8790f5507 100644 --- a/src/minibuf.c +++ b/src/minibuf.c @@ -353,7 +353,7 @@ read_minibuf (Lisp_Object map, Lisp_Object initial, Lisp_Object prompt, Lisp_Object histvar, Lisp_Object histpos, Lisp_Object defalt, bool allow_props, bool inherit_input_method) { - Lisp_Object val, previous_buffer = Fcurrent_buffer (); + Lisp_Object val; ptrdiff_t count = SPECPDL_INDEX (); Lisp_Object mini_frame, ambient_dir, minibuffer, input_method; Lisp_Object enable_multibyte; @@ -696,30 +696,21 @@ read_minibuf (Lisp_Object map, Lisp_Object initial, Lisp_Object prompt, else histstring = Qnil; - /* Add the value to the appropriate history list, if any. */ - if (! (NILP (Vhistory_add_new_input) || NILP (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) val = string_to_object (val, defalt); /* The appropriate frame will get selected in set-window-configuration. */ - return unbind_to (count, val); + unbind_to (count, Qnil); + + /* Add the value to the appropriate history list, if any. This is + done after the previous buffer has been made current again, in + case the history variable is buffer-local. */ + if (! (NILP (Vhistory_add_new_input) || NILP (histstring))) + call2 (intern ("add-to-history"), histvar, histstring); + + return val; } /* Return a buffer to be used as the minibuffer at depth `depth'. -- 2.17.1 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: master 3586fef: Make HIST arg of read-from-minibuffer work with buffer-local vars 2019-12-06 0:36 ` Federico Tedin @ 2019-12-06 1:57 ` Stefan Monnier 2019-12-09 23:53 ` Federico Tedin 0 siblings, 1 reply; 8+ messages in thread From: Stefan Monnier @ 2019-12-06 1:57 UTC (permalink / raw) To: Federico Tedin; +Cc: emacs-devel > Hey Stefan, here's a patch with the changes you suggested. Looks great, thanks, Stefan ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: master 3586fef: Make HIST arg of read-from-minibuffer work with buffer-local vars 2019-12-06 1:57 ` Stefan Monnier @ 2019-12-09 23:53 ` Federico Tedin 2019-12-10 16:14 ` Stefan Monnier 0 siblings, 1 reply; 8+ messages in thread From: Federico Tedin @ 2019-12-09 23:53 UTC (permalink / raw) To: Stefan Monnier; +Cc: emacs-devel Hey Stefan, I can't find the patch on master branch - friendly reminder to install it when you have the time. Thanks! - Fede ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: master 3586fef: Make HIST arg of read-from-minibuffer work with buffer-local vars 2019-12-09 23:53 ` Federico Tedin @ 2019-12-10 16:14 ` Stefan Monnier 2019-12-10 18:44 ` Federico Tedin 0 siblings, 1 reply; 8+ messages in thread From: Stefan Monnier @ 2019-12-10 16:14 UTC (permalink / raw) To: Federico Tedin; +Cc: emacs-devel > 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 ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: master 3586fef: Make HIST arg of read-from-minibuffer work with buffer-local vars 2019-12-10 16:14 ` Stefan Monnier @ 2019-12-10 18:44 ` Federico Tedin 0 siblings, 0 replies; 8+ messages in thread From: Federico Tedin @ 2019-12-10 18:44 UTC (permalink / raw) To: Stefan Monnier; +Cc: emacs-devel >> 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! ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2019-12-10 18:44 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- [not found] <20191205093041.3243.23144@vcs0.savannah.gnu.org> [not found] ` <20191205093043.1A8E0209BE@vcs0.savannah.gnu.org> 2019-12-05 13:56 ` master 3586fef: Make HIST arg of read-from-minibuffer work with buffer-local vars Stefan Monnier 2019-12-05 16:50 ` Federico Tedin 2019-12-05 19:17 ` Stefan Monnier 2019-12-06 0:36 ` Federico Tedin 2019-12-06 1:57 ` Stefan Monnier 2019-12-09 23:53 ` Federico Tedin 2019-12-10 16:14 ` Stefan Monnier 2019-12-10 18:44 ` Federico Tedin
Code repositories for project(s) associated with this external index https://git.savannah.gnu.org/cgit/emacs.git https://git.savannah.gnu.org/cgit/emacs/org-mode.git This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.