From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Gregory Heytings Newsgroups: gmane.emacs.bugs Subject: bug#45474: Icomplete exhibiting in recursive minibuffer when it =?UTF-8?Q?shouldn=E2=80=99t?= Date: Fri, 23 Apr 2021 13:45:47 +0000 Message-ID: References: <3ed97a9c53e0a5d4fef8@heytings.org> <87fszrz21d.fsf@mail.linkov.net> <3ed97a9c530093aca93d@heytings.org> <7dee3f4235d331cab291@heytings.org> <87r1jatd34.fsf@mail.linkov.net> <7dee3f423551aaf318cb@heytings.org> <87im4kzlfm.fsf@mail.linkov.net> <1869622e16546eafd9df@heytings.org> <871rb6np5j.fsf@mail.linkov.net> <87lf9cepqw.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="33496"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Dario Gjorgjevski , 45474@debbugs.gnu.org, Juri Linkov To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Apr 23 15:46:29 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 1lZw8a-0008Nw-N0 for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 23 Apr 2021 15:46:29 +0200 Original-Received: from localhost ([::1]:39970 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lZw8Z-0005Ul-Ov for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 23 Apr 2021 09:46:27 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:40516) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lZw8A-0005UT-Fo for bug-gnu-emacs@gnu.org; Fri, 23 Apr 2021 09:46:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:53143) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lZw8A-0001bP-88 for bug-gnu-emacs@gnu.org; Fri, 23 Apr 2021 09:46:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lZw8A-0005RQ-7U for bug-gnu-emacs@gnu.org; Fri, 23 Apr 2021 09:46:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Gregory Heytings Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 23 Apr 2021 13:46:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 45474 X-GNU-PR-Package: emacs Original-Received: via spool by 45474-submit@debbugs.gnu.org id=B45474.161918555120898 (code B ref 45474); Fri, 23 Apr 2021 13:46:02 +0000 Original-Received: (at 45474) by debbugs.gnu.org; 23 Apr 2021 13:45:51 +0000 Original-Received: from localhost ([127.0.0.1]:36456 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lZw7z-0005Qz-He for submit@debbugs.gnu.org; Fri, 23 Apr 2021 09:45:51 -0400 Original-Received: from heytings.org ([95.142.160.155]:50186) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lZw7w-0005Qo-PH for 45474@debbugs.gnu.org; Fri, 23 Apr 2021 09:45:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=heytings.org; s=20210101; t=1619185547; bh=VslNeW9gQ1WQxYUl8PJKD59aOonOCuTx1rMPz5NX+YY=; h=Date:From:To:cc:Subject:In-Reply-To:Message-ID:References:From; b=tDuC1UoaaWQy3kOeYnA0Fsfo2f/mInoBMyxB9k0bZgttuG3d6/S51e2udw3gX5WiO jqKLcx1wz+TvMRrP4cp8nmemNT0x4w56yAFhiEMKcQPs4ZvWosuLkx45rM5be79wki wsg+xowPmstFAuAVX5O7TbFl0yHjnzxyhgP9M58PCx/X0X5p2/e3A6kSw63ZkZsCDU 9opYXfpOalKpgx3vV81Q/1fMZwASUax3yCPNZwwlwUPbgkkXAShCRIgVLIOEzvLk0R vNTubdJGYQ7ZhcRPzn5ReWK2B6N4ZPVQzsxD8GYOMNFXVhAvxL32BMLxkdR9pyutbu a5dicQFVFMpoQ== In-Reply-To: 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:204741 Archived-At: >> It seems to me that my proposal is better, and here's why. The right >> thing to do in this case is not to install a local fix in >> completing-read-default, because completing-read-default is not where >> the root cause of the current problem lies. > > Hmm... that's odd: the problem has to do with values of > `minibuffer-completion-*` appearing where they shouldn't, and those > values are set by `completing-read-default`, so I think it's clearly the > culprit. > By 'completing-read-default' _and_ by other completion backends that set minibuffer-completion-* elements and call read-from-minibuffer. Or am I misunderstanding something? If not, it means that your patch will fix the problem for completing-read-default, but not for other completion backends, who will have to resort on a similar trick to get the same effect. IMO it would be better to avoid that, and to give "read-from-minibuffer" the new semantics that it takes some arguments from the environment and that these arguments are not anymore visible by all other (recursive) uses of read-from-minibuffer. >> The right thing to do is to change the semantics of >> read-from-minibuffer (while preserving backward compatibility for a >> limited amount of time), in such a way it receives some of its >> arguments through its environment. > > The core problem is the fact that dynamic scoping leaks: the parameters > passed to `read-from-minibuffer` via dynamic scoping and up being passed > to all other uses of `read-from-minibuffer` which happen to take place > within the same dynamic extent. > Not with the patch I'm proposing. What it does is the following (in abbreviated form): (let ((minibuffer-local-* minibuffer-completion-*)) (let ((minibuffer-completion-* nil)) (internal-read-from-minibuffer ...))) Line 1 saves the parameters in temporary variables, and line 2 resets the values of the parameters to nil, which means that they will not be visible anymore to all other uses of read-from-minibuffer within the same dynamic extent. Isn't that a nice trick? So you get all you want at once: - receiving the arguments from the environment (thereby avoiding to add new explicit parameters) - buffer-local values of the arguments on demand (thereby getting better semantics for callers that want it, in particular completing-read-default) - be backward compatible the current semantics of read-from-minibufer (thereby avoiding to break compatibility for callers that did not adapt to the the new semantics)