unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Gregory Heytings <gregory@heytings.org>
Cc: Dario Gjorgjevski <dario.gjorgjevski@gmail.com>,
	45474@debbugs.gnu.org, Juri Linkov <juri@linkov.net>
Subject: bug#45474: Icomplete exhibiting in recursive minibuffer when it shouldn’t
Date: Fri, 23 Apr 2021 11:35:40 -0400	[thread overview]
Message-ID: <jwvwnst6n9z.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <f2b9666c4ad3eb906830@heytings.org> (Gregory Heytings's message of "Fri, 23 Apr 2021 13:45:47 +0000")

>>> 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?

AFAICT there are very few other pieces of code which let-bind (or set)
minibuffer-completion-*.  And my suggested patch should hopefully not
affect them too significantly.  Also I don't think we can fix this
problem without introducing corner-case incompatibilities and/or extra
code/changes in other frontends or backends.

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

I think they'd need to make similar changes to fix the problem under
discussion in this longish thread, but they can keep using their old way
of working and the consequence will just be that they will keep
suffering from the old problem.

>> 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 ...)))

Not quite.  The actual code is more like:

    (let ((minibuffer-local-* minibuffer-completion-*))
       [SOMETHING1]
       (let ((minibuffer-completion-* nil))
          (internal-read-from-minibuffer ...))
       [SOMETHING2])

and those two [SOMETHINGn] still leak.

[ Another problem is that this approach breaks when you have
  simultaneous active minibuffers, and the inner minibuffer is triggered
  from the outer one (e.g. `C-x C-f` following by `C-h o`) since the
  let-bindings above will (when run for the `C-h o`) temporarily
  override the completion information of the outer minibuffer.
  This is not too serious in the sense that it's no worse than what we
  have now, tho.  ]

> 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)

You share the main downside of my proposal:
`minibuffer-local-*` are now only non-nil buffer-locally in
the minibuffers.

I mean it's good because it's what we want in the long term, but it's
bad because it's not backward compatible and there's probably some code
out there which will need to be adjusted to work with this.


        Stefan






  reply	other threads:[~2021-04-23 15:35 UTC|newest]

Thread overview: 64+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-27 17:44 bug#45474: Icomplete exhibiting in recursive minibuffer when it shouldn’t Dario Gjorgjevski
2021-04-15 17:40 ` Gregory Heytings
2021-04-15 21:11   ` Juri Linkov
2021-04-15 22:34     ` Gregory Heytings
2021-04-16  0:03       ` Gregory Heytings
2021-04-16 16:34         ` Juri Linkov
2021-04-16 16:55           ` Gregory Heytings
2021-04-17 20:49             ` Juri Linkov
2021-04-17 21:35               ` Gregory Heytings
2021-04-17 21:58                 ` Stefan Monnier
2021-04-17 22:16                   ` Gregory Heytings
2021-04-18 14:44                     ` Stefan Monnier
2021-04-18 22:23                       ` Gregory Heytings
2021-04-19  1:26                         ` Stefan Monnier
2021-04-19 12:14                           ` Gregory Heytings
2021-04-19 15:57                             ` Stefan Monnier
2021-04-19 20:20                               ` Gregory Heytings
2021-04-17 23:21                   ` bug#45474: [External] : " Drew Adams
2021-04-18  3:59                     ` Stefan Monnier
2021-04-18  4:04                       ` Drew Adams
2021-04-18  5:08                         ` Stefan Monnier
2021-04-18 15:42                           ` Drew Adams
2021-04-18 18:35                             ` Stefan Monnier
2021-04-18 20:11                               ` Drew Adams
2021-04-18 20:53                                 ` Stefan Monnier
2021-04-18 23:46                                   ` Drew Adams
2021-04-22 15:03                                     ` Stefan Monnier
2021-04-19 18:16                   ` Juri Linkov
2021-04-19 21:42                     ` Stefan Monnier
2021-04-20 19:00                       ` Gregory Heytings
2021-04-22 13:56                         ` Stefan Monnier
2021-04-22 14:08                           ` Gregory Heytings
2021-04-20 19:01                       ` Juri Linkov
2021-04-22 13:54                         ` Stefan Monnier
2021-04-22 14:13                           ` Stefan Monnier
2021-04-22 14:18                             ` Gregory Heytings
2021-04-22 15:18                               ` Gregory Heytings
2021-04-22 18:36                                 ` Stefan Monnier
2021-04-22 19:04                                   ` Gregory Heytings
2021-04-22 19:59                                     ` Gregory Heytings
2021-04-22 20:57                                       ` Gregory Heytings
2021-04-22 23:24                                     ` Stefan Monnier
2021-04-23  6:06                                       ` Eli Zaretskii
2021-04-23 13:12                                         ` Stefan Monnier
2021-04-23 13:19                                           ` Eli Zaretskii
2021-04-23 15:18                                             ` Stefan Monnier
2021-04-23 17:37                                               ` Eli Zaretskii
2021-04-23  6:59                                       ` Gregory Heytings
2021-04-23 13:21                                         ` Stefan Monnier
2021-04-23 13:45                                           ` Gregory Heytings
2021-04-23 15:35                                             ` Stefan Monnier [this message]
2021-04-23 15:58                                               ` Gregory Heytings
2021-04-23 16:36                                                 ` Juri Linkov
2021-04-23 16:55                                                 ` Stefan Monnier
2021-04-23 18:13                                                   ` Gregory Heytings
2021-04-23 20:24                                                     ` Stefan Monnier
2021-04-23 21:36                                                       ` Gregory Heytings
2021-04-23 21:54                                                         ` Stefan Monnier
2021-04-24  8:44                                                           ` Gregory Heytings
2021-05-01 19:34                                                             ` Stefan Monnier
2021-05-03  8:40                                                               ` Gregory Heytings
2022-06-07 12:04                                                                 ` Lars Ingebrigtsen
2021-04-22 21:57                             ` Juri Linkov
2021-04-23 15:53                               ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvwnst6n9z.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=45474@debbugs.gnu.org \
    --cc=dario.gjorgjevski@gmail.com \
    --cc=gregory@heytings.org \
    --cc=juri@linkov.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).