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: Juri Linkov
Subject: bug#45474: Icomplete exhibiting in recursive minibuffer when it shouldn’t
Date: Mon, 19 Apr 2021 21:16:18 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu)

> A quick&dirty workaround for now would be for `completing-read` to set
> some var alongside `minibuffer-completion-table` which indicates *which*
> minibuffer this is for (e.g. some minibuffer-depth information).
> This way `read-from-minibuffer` could distinguish
> a `minibuffer-completion-table` passed for the current invocation from
> one passed for the outer invocation and could hence temporarily rebind
> `minibuffer-completion-table` to nil.

This patch is how I thought your suggestion could be implemented,
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.
Maybe this minibuffer-with-setup-hook could be moved even to
'completing-read'?


diff --git a/lisp/icomplete.el b/lisp/icomplete.el
index 91bbb60013..543e451c5d 100644
--- a/lisp/icomplete.el
+++ b/lisp/icomplete.el
@@ -400,7 +400,7 @@ 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) (and completing-minibuffer 
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 a0247d1fba..3ceb67733d 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -3826,6 +3826,8 @@ completing-read-function
   "The function called by `completing-read' to do its work.
 It should accept the same arguments as `completing-read'.")
 
+(defvar completing-minibuffer nil)
+
 (defun completing-read-default (prompt collection &optional predicate
                                        require-match initial-input
                                        hist def inherit-input-method)
@@ -3839,6 +3841,9 @@ completing-read-default
                 ;; `read-from-minibuffer' uses 1-based index.
                 (1+ (cdr initial-input)))))
 
+  (minibuffer-with-setup-hook
+      (lambda ()
+        (setq-local completing-minibuffer t))
     (let* ((minibuffer-completion-table collection)
            (minibuffer-completion-predicate predicate)
            ;; FIXME: Remove/rename this var, see the next one.
@@ -3862,7 +3867,7 @@ completing-read-default
                                          nil hist def inherit-input-method)))
       (when (and (equal result "") def)
         (setq result (if (consp def) (car def) def)))
-    result))
+      result)))
 
 ;; Miscellaneous
 

reply via email to

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