bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#45474: Icomplete exhibiting in recursive minibuffer when it shouldn’


From: Stefan Monnier
Subject: bug#45474: Icomplete exhibiting in recursive minibuffer when it shouldn’t
Date: Mon, 19 Apr 2021 17:42:02 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

> but then later you posted a different patch.  Anyway FWIW here is
> a safer workable workaround that implements your first suggestion
> and sets a new explicit buffer-local variable in completing minibuffers,
> so modes that need to distinguish such minibuffers could check it.

I combined your idea with that of Gregory for the patch below.
It's far from perfect, but I think it strikes a good balance of
simplicity, preserving compatibility, and moving in the right direction.

WDYT?

> Maybe this minibuffer-with-setup-hook could be moved even to
> 'completing-read'?

Because of the fundamentally broken&messy way
`minibuffer-with-setup-hook` works, it's best to keep it as close as
possible to the call to `read-from-minibuffer`, IMO.


        Stefan


diff --git a/lisp/icomplete.el b/lisp/icomplete.el
index 91bbb600136..df9c5241234 100644
--- a/lisp/icomplete.el
+++ b/lisp/icomplete.el
@@ -400,7 +400,9 @@ icomplete-mode
     (add-hook 'minibuffer-setup-hook #'icomplete-minibuffer-setup)))
 
 (defun icomplete--completion-table ()
-  (if (window-minibuffer-p) minibuffer-completion-table
+  (if (window-minibuffer-p)
+      (if (local-variable-p 'minibuffer-completion-table)
+          minibuffer-completion-table)
     (or (nth 2 completion-in-region--data)
        (message "In %S (w=%S): %S"
                 (current-buffer) (selected-window) (window-minibuffer-p)))))
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index c19f9096290..04fbd092c27 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -3857,8 +3857,11 @@ 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 () (make-local-variable 'minibuffer-completion-table))
+            (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))






reply via email to

[Prev in Thread] Current Thread [Next in Thread]