From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#45474: Icomplete exhibiting in recursive minibuffer when it =?UTF-8?Q?shouldn=E2=80=99t?= Date: Thu, 22 Apr 2021 10:13:22 -0400 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 Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="22784"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: Gregory Heytings , Dario Gjorgjevski , 45474@debbugs.gnu.org To: Juri Linkov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Apr 22 16:15:54 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 1lZa7V-0005jn-NA for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 22 Apr 2021 16:15:53 +0200 Original-Received: from localhost ([::1]:44376 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lZa7U-0007AF-KQ for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 22 Apr 2021 10:15:52 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:50284) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lZa5i-0005US-2T for bug-gnu-emacs@gnu.org; Thu, 22 Apr 2021 10:14:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:51896) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lZa5h-0008N6-QI for bug-gnu-emacs@gnu.org; Thu, 22 Apr 2021 10:14:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lZa5h-0004EM-Kq for bug-gnu-emacs@gnu.org; Thu, 22 Apr 2021 10:14:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 22 Apr 2021 14:14:01 +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.161910081616224 (code B ref 45474); Thu, 22 Apr 2021 14:14:01 +0000 Original-Received: (at 45474) by debbugs.gnu.org; 22 Apr 2021 14:13:36 +0000 Original-Received: from localhost ([127.0.0.1]:35209 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lZa5H-0004Da-MA for submit@debbugs.gnu.org; Thu, 22 Apr 2021 10:13:35 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:45923) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lZa5D-0004DL-Gk for 45474@debbugs.gnu.org; Thu, 22 Apr 2021 10:13:34 -0400 Original-Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id AF443100525; Thu, 22 Apr 2021 10:13:25 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 1A37A1000C9; Thu, 22 Apr 2021 10:13:24 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1619100804; bh=bWv+3Yq57D7iueJnO+Q7rhm1UN+54noM4shE+XnPmFw=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=Kec0zM0FFiLtP5Ays6TSLifRQp5A+pEuzNIjGB6J1Bq3EIPmFwRgqQ6j0Q6s28hmq z9GpkvSylhP/yG4NaNu7W46kwS/R8ggFXZR7Vq0nisE9NrCRD2F9v6is/nkFBgheWH TucBMdv04PcgQD1coEvid5L5xy14Epow088QoBpwpgEhManJn5DpoK8hC/jcmsfrDi mjZjIZGFbFvE0HGOyT24cljZ4c0P2FtjBmeTvMkS0aZlo/SYiRjjloYgmL/a7JdFDS HWK6nDvb+lAerkuGpqet8w/4KwaisEz6NltXV6yGwdLTQOq7A7B3nXJfyf3br+KpZv l0K+mQmcnrtTQ== Original-Received: from alfajor (104-222-126-84.cpe.teksavvy.com [104.222.126.84]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id D3D53120175; Thu, 22 Apr 2021 10:13:23 -0400 (EDT) In-Reply-To: (Stefan Monnier's message of "Thu, 22 Apr 2021 09:54:48 -0400") 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:204689 Archived-At: >> I tested your patch and discovered that it fails when two nested >> minibuffers both use completion, e.g. C-x C-f C-h v raises the error: >> >> Error in post-command-hook (icomplete-post-command-hook): (wrong-type-argument symbolp > > Indeed, it's nasty: > > - In the first step, we > - let-bind (globally) m-c-table to read-file-name-internal > - go to minibuf-1 > - make it buffer-local in minibuf-1 > - everything's dandy > - In the second step, things get ugly > - we're in minibuf-1 > - we let-bind m-c-table to help--symbol-completion-table which > only works buffer-locally in minibuf-1 (thus temporarily overriding > the value set just before). > - we go to minibuf-2 which still has no buffer-local setting so it > sees the global value that's still read-file-name-internal (because > of the very first part of the first step) > - we make it buffer-local but to this wrong value > > So in the end we get a wrong m-c-table in both buffers (the values are reversed!). I'm more and more thinking that we should really bite the bullet and go for a "really buffer-local" setup, such as in the patch below. I'd be surprised if it doesn't introduce backward incompatibilities, but at least it's "The Right Thing" to do. Stefan diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index 7da3c39e6b9..ce136b90449 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -3884,13 +3884,7 @@ completing-read-default ;; `read-from-minibuffer' uses 1-based index. (1+ (cdr initial-input))))) - (let* ((minibuffer-completion-table collection) - (minibuffer-completion-predicate predicate) - ;; FIXME: Remove/rename this var, see the next one. - (minibuffer-completion-confirm (unless (eq require-match t) - require-match)) - (minibuffer--require-match require-match) - (base-keymap (if require-match + (let* ((base-keymap (if require-match minibuffer-local-must-match-map minibuffer-local-completion-map)) (keymap (if (memq minibuffer-completing-file-name '(nil lambda)) @@ -3903,8 +3897,17 @@ completing-read-default ;; in minibuffer-local-filename-completion-map can ;; override bindings in base-keymap. base-keymap))) - (result (read-from-minibuffer prompt initial-input keymap - nil hist def inherit-input-method))) + (result + (minibuffer-with-setup-hook + (lambda () + (setq-local minibuffer-completion-table collection) + (setq-local minibuffer-completion-predicate predicate) + ;; FIXME: Remove/rename this var, see the next one. + (setq-local minibuffer-completion-confirm + (unless (eq require-match t) require-match)) + (setq-local minibuffer--require-match require-match)) + (read-from-minibuffer prompt initial-input keymap + nil hist def inherit-input-method)))) (when (and (equal result "") def) (setq result (if (consp def) (car def) def))) result))