From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Federico Tedin Newsgroups: gmane.emacs.devel Subject: Re: master 3586fef: Make HIST arg of read-from-minibuffer work with buffer-local vars Date: Fri, 06 Dec 2019 01:36:50 +0100 Message-ID: <878snqp9wd.fsf@gmail.com> References: <20191205093041.3243.23144@vcs0.savannah.gnu.org> <20191205093043.1A8E0209BE@vcs0.savannah.gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="108209"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Dec 06 01:37:41 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1id1cr-000S3I-Q9 for ged-emacs-devel@m.gmane.org; Fri, 06 Dec 2019 01:37:41 +0100 Original-Received: from localhost ([::1]:34238 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1id1cp-0005vN-VN for ged-emacs-devel@m.gmane.org; Thu, 05 Dec 2019 19:37:39 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:59507) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1id1c8-0005uS-HE for emacs-devel@gnu.org; Thu, 05 Dec 2019 19:36:57 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1id1c7-0003yj-BR for emacs-devel@gnu.org; Thu, 05 Dec 2019 19:36:56 -0500 Original-Received: from mail-ed1-x52b.google.com ([2a00:1450:4864:20::52b]:40352) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1id1c6-0003uc-6N for emacs-devel@gnu.org; Thu, 05 Dec 2019 19:36:54 -0500 Original-Received: by mail-ed1-x52b.google.com with SMTP id c93so4343684edf.7 for ; Thu, 05 Dec 2019 16:36:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=lsNvjQxYw5u5Sx61sQbx5kKNv0/w/jz0KkPlrL6/9Kg=; b=edRb1cC8WbIrLh8+8ylr+JjoxMRoPy3PfeBHpznqSwuOkClQjw2y2Au2qvAP6Rr+VN PDFQI14H/r3w6Ir+G1Y3GopRjw8ImcfzJBWmqtKbZQ671YuxdRwbp5zlEIpcJC3i2j8G GJnVm7HH2tlaw385C3x3sJSTbmN2k3EJhaiZaOySoj2XlqTJ6Gfr8E/uRjrotjWK6PDZ iBon9qRUpeIHhvdDxdB6O0hVg9YSgqjgowr5L377WLIl3KRvbSckPsfeEIBwTQfbkP39 dNLTZV5BRzBT9My4fN8ss6FKbtAx2pGQRkvM8x9t5xzs7r2pihqP1p7dceNxZ2rpX//n ZSIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=lsNvjQxYw5u5Sx61sQbx5kKNv0/w/jz0KkPlrL6/9Kg=; b=C81pg9VISrM7Da14uE5YlUWH3Q9AyH77QrG7TC84hDkWLsJjFEEJ3b4Cazn7HW1bAu XLWBV+V9qmL1b7Phhx5lfYCmN8N7w7joIMiK2Jyt5hc4ZOOC+iNhsMktxThzDcTVnmEb vfdxnp2zt4mMIR2xr6uUgJ5p+vsExp7higFVXJhI3q3vU3Tpv3DnV6MmNog5vTa+qioh sf3FzGyHC47NBfMnLNjWo1yOZmWGJ53ppZ2hYfho3TlU/usafxcylIx8KBTWJLN5qbd1 wMjMg1bj1zVdh7zBXsvJlMbOVpwYnWV7vZHf+kqsJBkW50pUZGESf8MYDN6YoziPO6vW J78w== X-Gm-Message-State: APjAAAUTxtoYnAY/Ijq0OBNfjH2Q6zpp+p08u31IzCYcbfc2BCqebjfr SL4ZXcgTTiDZAUKa1jX3xjGiIS+/ X-Google-Smtp-Source: APXvYqw/VwnePFGMJI2RoPUoDJvikViGxMqlGHgJO+gYPR4hw2LU9IvqBdJcMdMbAkuE3qrm+zin/w== X-Received: by 2002:a17:906:d790:: with SMTP id pj16mr12389836ejb.19.1575592612526; Thu, 05 Dec 2019 16:36:52 -0800 (PST) Original-Received: from lead ([2a02:8109:8ac0:2ff0:6985:79:e55f:2087]) by smtp.gmail.com with ESMTPSA id y20sm379643edu.7.2019.12.05.16.36.51 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 05 Dec 2019 16:36:51 -0800 (PST) In-Reply-To: (Stefan Monnier's message of "Thu, 05 Dec 2019 14:17:43 -0500") X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::52b X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:243173 Archived-At: --=-=-= Content-Type: text/plain 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! --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=minibuf.patch Content-Description: patch >From cb1cc374bfb1a5fc5ded8bed55b7f2641925f47a Mon Sep 17 00:00:00 2001 From: Federico Tedin 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 --=-=-=--