From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: miha--- via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#48925: [PATCH] Set `minibuffer-completion-*` variables buffer-locally in a few more places Date: Thu, 11 Nov 2021 11:42:34 +0100 Message-ID: <87mtmbgehx.fsf@miha-pc> References: <87fsxstdiy.fsf@miha-pc> <87czn79smi.fsf@gnus.org> Reply-To: Mime-Version: 1.0 Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="37691"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 48925@debbugs.gnu.org To: Lars Ingebrigtsen , Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Nov 11 11:39:14 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ml7UA-0009a5-9U for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 11 Nov 2021 11:39:14 +0100 Original-Received: from localhost ([::1]:53536 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ml7U9-0007LN-0t for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 11 Nov 2021 05:39:13 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:44798) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ml7Ty-0007LA-Pu for bug-gnu-emacs@gnu.org; Thu, 11 Nov 2021 05:39:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:56929) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ml7Ty-00062k-Hp for bug-gnu-emacs@gnu.org; Thu, 11 Nov 2021 05:39:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ml7Ty-0004sN-Ad for bug-gnu-emacs@gnu.org; Thu, 11 Nov 2021 05:39:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 11 Nov 2021 10:39:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 48925 X-GNU-PR-Package: emacs Original-Received: via spool by 48925-submit@debbugs.gnu.org id=B48925.163662709418681 (code B ref 48925); Thu, 11 Nov 2021 10:39:02 +0000 Original-Received: (at 48925) by debbugs.gnu.org; 11 Nov 2021 10:38:14 +0000 Original-Received: from localhost ([127.0.0.1]:40242 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ml7TB-0004rE-P1 for submit@debbugs.gnu.org; Thu, 11 Nov 2021 05:38:14 -0500 Original-Received: from kamnitnik.top ([209.250.245.214]:44170) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ml7T9-0004r5-DT for 48925@debbugs.gnu.org; Thu, 11 Nov 2021 05:38:12 -0500 Original-Received: from localhost (BSN-77-156-43.static.siol.net [193.77.156.43]) by kamnitnik.top (Postfix) with ESMTPSA id 304D79CFA8; Thu, 11 Nov 2021 10:38:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kamnitnik.top; s=mail; t=1636627090; bh=J0RHQxSWuMwgHEcuZ8v4VmqJx9B/cWlvLlaliiP3l1s=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=RvFWunlSsEHvklbyTzKPpj7laXZ/1ZnV7XGgJcuontldyE836zy027ZeFnJO/EOKb NSYqvAOWOKLAlRDVXdRmzOGlJi50pmwkkqDLFlyPCGmqvloOKQ4vf9Bkt/RnGXlppI GTTkHiSwJboe7dVvkKwu7sEx0wKmMzV5W6GLQ0RJa8rWmb11tWn+b3qoeI8DLWSOj7 VuiJZkqokv8ZR1YFs+uj3G3/u3C+K0xkxiJwOTBBsbYLjgKahGTh5wwb6mu/AQliY1 gtQwNgInlvtlXnriSFmfSM5GOX2IV4/b1IHoIz0zVLxQVdoNvhrKf0ojuqru1ZBWCB exz3uxbfmKOTQ== In-Reply-To: <87czn79smi.fsf@gnus.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:219618 Archived-At: --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain Lars Ingebrigtsen writes: > Stefan Monnier writes: > >>> This follows up on changes proposed in bug#45474. >> >> Thanks, the first patch looks good to me (assuming it works ;-). > > So I've now applied it to Emacs 29. It didn't lead to any obvious > regressions (or test suite failures) that I can see, which is a good > sign. > >>> The second patch is a bit more controversial, but is probably required >>> if we want more reliable usage of completion commands in non-innermost >>> minibuffers (that is, with minibuffer-follows-selected-frame set >>> to nil.) >> >> The patch is fundamentally right, but as you say it's a bit more >> controversial because it risks exposing bugs. Hmm... >> >> To be on the safer side, I guess we could replace the >> >> specbind (Qminibuffer_completion_table, Qnil); >> >> with a use of `minibuffer-with-setup-hook` that sets the var to nil in >> the new minibuffer. But doing it in C is awkward so it would best be >> done by moving the function to subr.el. > > Sounds like a good idea to me. Miha, could you do that? Okay, patch attached. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-Set-minibuffer-completion-table-buffer-locally-in-re.patch Content-Transfer-Encoding: quoted-printable From=2070fb493398d4961be0fa997684261554822e66b2 Mon Sep 17 00:00:00 2001 From: =3D?UTF-8?q?Miha=3D20Rihtar=3DC5=3DA1i=3DC4=3D8D?=3D Date: Thu, 11 Nov 2021 11:38:03 +0100 Subject: [PATCH] Set minibuffer-completion-table buffer-locally in read-str= ing * src/callint.c (Fcall_interactively): * src/minibuf.c (Fread_string): Move function subr.el and use minibuffer-with-setup-hook to set minibuffer-completion-table buffer-locally. =2D-- lisp/subr.el | 26 ++++++++++++++++++++++++++ src/callint.c | 10 ++++------ src/minibuf.c | 35 ----------------------------------- 3 files changed, 30 insertions(+), 41 deletions(-) diff --git a/lisp/subr.el b/lisp/subr.el index 5a5842d428..75f00f33d4 100644 =2D-- a/lisp/subr.el +++ b/lisp/subr.el @@ -3507,6 +3507,32 @@ y-or-n-p (message "%s%c" prompt (if ret ?y ?n))) ret))) =20 +(defun read-string ( prompt &optional initial-input history + default-value inherit-input-method) + "Read a string from the minibuffer, prompting with string PROMPT. +If non-nil, second arg INITIAL-INPUT is a string to insert before reading. + This argument has been superseded by DEFAULT-VALUE and should normally b= e nil + in new code. It behaves as INITIAL-CONTENTS in `read-from-minibuffer' (= which + see). +The third arg HISTORY, if non-nil, specifies a history list + and optionally the initial position in the list. +See `read-from-minibuffer' for details of HISTORY argument. +Fourth arg DEFAULT-VALUE is the default value or the list of default value= s. + If non-nil, it is used for history commands, and as the value (or the fir= st + element of the list of default values) to return if the user enters the + empty string. +Fifth arg INHERIT-INPUT-METHOD, if non-nil, means the minibuffer inherits + the current input method and the setting of `enable-multibyte-characters'= ." + (minibuffer-with-setup-hook + (lambda () + (setq-local minibuffer-completion-table nil)) + (let ((ret (read-from-minibuffer prompt initial-input nil nil + history default-value + inherit-input-method))) + (if (and default-value (equal "" ret)) + (if (consp default-value) (car default-value) default-value) + ret)))) + ;;; Atomic change groups. =20 diff --git a/src/callint.c b/src/callint.c index 44dae361c1..4e80d510ce 100644 =2D-- a/src/callint.c +++ b/src/callint.c @@ -631,8 +631,8 @@ DEFUN ("call-interactively", Fcall_interactively, Scall= _interactively, 1, 3, 0, =20 case 'M': /* String read via minibuffer with inheriting the current input method. */ =2D args[i] =3D Fread_string (callint_message, =2D Qnil, Qnil, Qnil, Qt); + args[i] =3D call5 (intern ("read-string"), + callint_message, Qnil, Qnil, Qnil, Qt); break; =20 case 'N': /* Prefix arg as number, else number from minibuffer. */ @@ -672,13 +672,11 @@ DEFUN ("call-interactively", Fcall_interactively, Sca= ll_interactively, 1, 3, 0, =20 case 's': /* String read via minibuffer without inheriting the current input method. */ =2D args[i] =3D Fread_string (callint_message, =2D Qnil, Qnil, Qnil, Qnil); + args[i] =3D call1 (intern ("read-string"), callint_message); break; =20 case 'S': /* Any symbol. */ =2D visargs[i] =3D Fread_string (callint_message, =2D Qnil, Qnil, Qnil, Qnil); + visargs[i] =3D call1 (intern ("read-string"), callint_message); args[i] =3D Fintern (visargs[i], Qnil); break; =20 diff --git a/src/minibuf.c b/src/minibuf.c index 6c0cd358c5..f0f08d97c0 100644 =2D-- a/src/minibuf.c +++ b/src/minibuf.c @@ -1366,40 +1366,6 @@ DEFUN ("read-from-minibuffer", Fread_from_minibuffer, =20 /* Functions that use the minibuffer to read various things. */ =20 =2DDEFUN ("read-string", Fread_string, Sread_string, 1, 5, 0, =2D doc: /* Read a string from the minibuffer, prompting with string = PROMPT. =2DIf non-nil, second arg INITIAL-INPUT is a string to insert before readin= g. =2D This argument has been superseded by DEFAULT-VALUE and should normally= be nil =2D in new code. It behaves as INITIAL-CONTENTS in `read-from-minibuffer'= (which =2D see). =2DThe third arg HISTORY, if non-nil, specifies a history list =2D and optionally the initial position in the list. =2DSee `read-from-minibuffer' for details of HISTORY argument. =2DFourth arg DEFAULT-VALUE is the default value or the list of default val= ues. =2D If non-nil, it is used for history commands, and as the value (or the f= irst =2D element of the list of default values) to return if the user enters the =2D empty string. =2DFifth arg INHERIT-INPUT-METHOD, if non-nil, means the minibuffer inherits =2D the current input method and the setting of `enable-multibyte-character= s'. */) =2D (Lisp_Object prompt, Lisp_Object initial_input, Lisp_Object history, L= isp_Object default_value, Lisp_Object inherit_input_method) =2D{ =2D Lisp_Object val; =2D ptrdiff_t count =3D SPECPDL_INDEX (); =2D =2D /* Just in case we're in a recursive minibuffer, make it clear that the =2D previous minibuffer's completion table does not apply to the new =2D minibuffer. =2D FIXME: `minibuffer-completion-table' should be buffer-local instead= . */ =2D specbind (Qminibuffer_completion_table, Qnil); =2D =2D val =3D Fread_from_minibuffer (prompt, initial_input, Qnil, =2D Qnil, history, default_value, =2D inherit_input_method); =2D if (STRINGP (val) && SCHARS (val) =3D=3D 0 && ! NILP (default_value)) =2D val =3D CONSP (default_value) ? XCAR (default_value) : default_value; =2D return unbind_to (count, val); =2D} =2D DEFUN ("read-command", Fread_command, Sread_command, 1, 2, 0, doc: /* Read the name of a command and return as a symbol. Prompt with PROMPT. By default, return DEFAULT-VALUE or its first element @@ -2513,7 +2479,6 @@ syms_of_minibuf (void) defsubr (&Sactive_minibuffer_window); defsubr (&Sset_minibuffer_window); defsubr (&Sread_from_minibuffer); =2D defsubr (&Sread_string); defsubr (&Sread_command); defsubr (&Sread_variable); defsubr (&Sinternal_complete_buffer); =2D-=20 2.33.1 --=-=-=-- --==-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQJHBAEBCAAxFiEEmxVnesoT5rQXvVXnswkaGpIVmT8FAmGM85oTHG1paGFAa2Ft bml0bmlrLnRvcAAKCRCzCRoakhWZP7o5EAC1C51hML5q2TRiH5+8WQgbR7Lh1s4A gXeEdodpXbh1XpIHls2llS0sEnrL1O2Vb5DaiAvjmKdheSxuZnVzlObiqXR1lpC4 CTtgz2Ba9GloeTqTYlUfsS+an6HDNB9My3pRjMFrkN36AwyFxGvHOmLruZSf931a gmnV/8VdPN2ZWoXT3fawUUSmKFkhpgT9CsDLoZuUGNf6hkCZqRwkjUozrew2Rjv1 lnpyGGysVtFP2Z8Ilm+K32NCRoj3z0vFCV8vIxKMJOydyauA7p3LMgEuS+gCZ/z1 K2ApzEr/4JlBnsiSIUxerpOyc5xwCZzBoVOACRLfHKujmFJmmv41R0mG4SbqkJ/X C10xYNf5338ia8Ho4SDAl59F4x/1G9gq4oqsNbfwqnek9LwQoXhACR3IkEseSq4o yr/II0X/qURfnlXcCEScX1EWb4UdlY7T1gGw+8Sd7aKliMRQaScoZJD7brcjANu4 oRK1/2Lp0JItnHce+Jilu0/2wisTAaw2CxyiCRfX4VbnNWJzMdwWEzogoGUFgIUJ 7eU0OxIQ7Z/UJldQ5NU+nUOEMoBvo9/776OPCfqCQ7HpzJohOiSJfXmGxD4PzN5a Y9Ivizw/rlLwNzbZlI+2DryNSXelem5gQv9z3aPR4jnfLxN14XYSopz5br0SAhWF noRV6HvzNz+ZBA== =qUe7 -----END PGP SIGNATURE----- --==-=-=--