From: Gregory Heytings <gregory@heytings.org>
To: Stefan Monnier <monnier@iro.umontreal.ca>
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: Sun, 18 Apr 2021 22:23:46 +0000 [thread overview]
Message-ID: <c40b32b1f8c49b47c52d@heytings.org> (raw)
In-Reply-To: <jwvfszn3by1.fsf-monnier+emacs@gnu.org>
[-- Attachment #1: Type: text/plain, Size: 1830 bytes --]
>> See the attached patch. I's a draft, as I said
>> read-from-minibuffer-simple could probably renamed to something more
>> elegant, and (at least some of) the other calls to read-from-minibuffer
>> could be replaced by the macro.
>
> Ah, I see. But that's based on "blacklisting" those places that don't
> want to use minibuffer-completion-table, so it requires changes in many
> places (including outside of Emacs's codebase).
>
It would be possible to use whitelisting instead by renaming the current
read-from-minibuffer to internal-read-from-minibuffer, which would be
wrapped in a macro read-from-minibuffer. The change would be transparent,
except for those places (e.g. completing-read-default) where what we
actually want is to use internal-read-from-minibuffer. But this change
would be slightly more invasive than what follows.
>> These are yet other possible approaches indeed, but it seems to me at
>> first sight that they are more complex than the solution I suggest.
>
> The patch below shows one way to do what I suggest.
>
Thanks. Somehow I feel that using the keymap to decide whether the
completion table should be used isn't safe enough, it's possible (at least
in theory) that a minibuffer with a certain keymap uses completion tables
and another one using the same keymap does not. ISTM that it's safer (and
more explicit) to use the current minibuffer depth for that purpose; see
attached patch.
>
> Just like your approach, I think this is only a temporary fix until we
> can solve the problem for real by making `minibuffer-completion-table`
> buffer-local
>
I'm not sure I fully understand why this is necessary, but is
"Fmake_variable_buffer_local (Qminibuffer_completion_table);" just after
"if ... specbind (Qminibuffer_completion_table, Qnil);" not enough for
this?
[-- Attachment #2: Type: text/x-diff, Size: 2918 bytes --]
From 4654c5251cab6703e4dcd94ecaa900bb970bb589 Mon Sep 17 00:00:00 2001
From: Gregory Heytings <gregory@heytings.org>
Date: Sun, 18 Apr 2021 22:15:08 +0000
Subject: [PATCH] Make it possible to disable completion in recursive
minibuffers
---
lisp/minibuffer.el | 1 +
src/minibuf.c | 15 +++++++++------
2 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index c900b0d7ce..991ed9dc93 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -3825,6 +3825,7 @@ completing-read-default
(1+ (cdr initial-input)))))
(let* ((minibuffer-completion-table collection)
+ (minibuffer--depth-for-completion-table (minibuffer-depth))
(minibuffer-completion-predicate predicate)
;; FIXME: Remove/rename this var, see the next one.
(minibuffer-completion-confirm (unless (eq require-match t)
diff --git a/src/minibuf.c b/src/minibuf.c
index c9831fd50f..77992e1fea 100644
--- a/src/minibuf.c
+++ b/src/minibuf.c
@@ -559,6 +559,9 @@ read_minibuf (Lisp_Object map, Lisp_Object initial, Lisp_Object prompt,
specbind (Qminibuffer_default, defalt);
specbind (Qinhibit_read_only, Qnil);
+ if (!EQ (Vminibuffer__depth_for_completion_table, make_fixnum (minibuf_level)))
+ specbind (Qminibuffer_completion_table, Qnil);
+
/* If Vminibuffer_completing_file_name is `lambda' on entry, it was t
in previous recursive minibuffer, but was not set explicitly
to t for this invocation, so set it to nil in this minibuffer.
@@ -1338,12 +1341,6 @@ DEFUN ("read-string", Fread_string, Sread_string, 1, 5, 0,
Lisp_Object val;
ptrdiff_t count = SPECPDL_INDEX ();
- /* Just in case we're in a recursive minibuffer, make it clear that the
- previous minibuffer's completion table does not apply to the new
- minibuffer.
- FIXME: `minibuffer-completion-table' should be buffer-local instead. */
- specbind (Qminibuffer_completion_table, Qnil);
-
val = Fread_from_minibuffer (prompt, initial_input, Qnil,
Qnil, history, default_value,
inherit_input_method);
@@ -2394,6 +2391,12 @@ syms_of_minibuf (void)
variable is non-nil. */);
enable_recursive_minibuffers = 0;
+ DEFVAR_LISP ("minibuffer--depth-for-completion-table", Vminibuffer__depth_for_completion_table,
+ doc: /* Minibuffer depth used together with `minibuffer-completion-table'.
+`read-from-minibuffer' compares it with the current minibuffer depth to
+determine if the completion table was intended for it or not. */);
+ Vminibuffer__depth_for_completion_table = Qnil;
+
DEFVAR_LISP ("minibuffer-completion-table", Vminibuffer_completion_table,
doc: /* Alist or obarray used for completion in the minibuffer.
This becomes the ALIST argument to `try-completion' and `all-completions'.
--
2.30.2
next prev parent reply other threads:[~2021-04-18 22:23 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 [this message]
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
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c40b32b1f8c49b47c52d@heytings.org \
--to=gregory@heytings.org \
--cc=45474@debbugs.gnu.org \
--cc=dario.gjorgjevski@gmail.com \
--cc=juri@linkov.net \
--cc=monnier@iro.umontreal.ca \
/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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.