bug#81537: 32.0.50; Fixing icomplete-in-buffer requiring users to advice-add
Sean Whitton <[email protected]> Sun, 02 Aug 2026 12:12:41 +0100
| Newsgroups | gmane.emacs.bugs |
|---|---|
| Message-ID | <[email protected]> |
Here's a very similar patch, perhaps slightly cleaner.
--
etc/NEWS | 10 ++++++++++
lisp/icomplete.el | 10 +---------
lisp/minibuffer.el | 31 +++++++++++++++++++++----------
3 files changed, 32 insertions(+), 19 deletions(-)
diff --git a/etc/NEWS b/etc/NEWS
index 23b97971105..ead3f7fb72c 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -97,6 +97,16 @@ You can restore the previous behavior by removing
---
*** The variable 'completion-ignore-case' is now customizable.
+---
+*** 'icomplete-in-buffer' users need no longer advise 'completion-at-point'.
+The "*Completions*" buffer no longer pops up in addition to Icomplete's
+in-buffer display of completions, by default.
+Therefore, the instructions in the NEWS file for Emacs 30.1 to add
+
+ (advice-add 'completion-at-point :after #'minibuffer-hide-completions)
+
+to your initialization file no longer apply, and you may remove it.
+
* Editing Changes in Emacs 32.1
diff --git a/lisp/icomplete.el b/lisp/icomplete.el
index 9a1202c30af..c8da0e9bf9b 100644
--- a/lisp/icomplete.el
+++ b/lisp/icomplete.el
@@ -154,15 +154,7 @@ icomplete-max-delay-chars
(defcustom icomplete-in-buffer nil
"If non-nil, use Icomplete when completing in buffers other than minibuffer.
This affects commands like `completion-in-region', but not commands
-that use their own completions setup.
-
-If you would prefer to see only Icomplete's in-buffer display, but do
-not want the \"*Completions*\" buffer to pop up in those cases, add
-this advice to your init file:
-
- (advice-add \\='completion-at-point
- :after #\\='minibuffer-hide-completions)
-"
+that use their own completions setup."
:type 'boolean)
(defcustom icomplete-minibuffer-setup-hook nil
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index 6c13fcabe54..10c55605c13 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -1581,6 +1581,9 @@ completion--in-boundaries-p
(end (+ (length string) (cdr boundaries))))
(>= start pos end)))
+(defun completion--icomplete-in-buffer-p ()
+ (eq (bound-and-true-p icomplete--in-region-buffer) (current-buffer)))
+
(defun completion--do-completion (beg end &optional
try-completion-function expect-exact)
"Do the completion and return a summary of what happened.
@@ -1686,6 +1689,7 @@ completion--do-completion
(minibuffer-force-complete beg end))
((or completed only-changed-boundaries)
(cond
+ ((completion--icomplete-in-buffer-p))
((pcase completion-auto-help
('visible (minibuffer--completions-visible))
('always t))
@@ -1699,16 +1703,18 @@ completion--do-completion
'exact 'unknown))))))
;; Show the completion table, if requested.
((not exact)
- (if (pcase completion-auto-help
- ('lazy (eq this-command last-command))
- (_ completion-auto-help))
+ (if (and (pcase completion-auto-help
+ ('lazy (eq this-command last-command))
+ (_ completion-auto-help))
+ (not (completion--icomplete-in-buffer-p)))
(minibuffer-completion-help beg end)
(completion--message "Next char not unique")))
;; If the last exact completion and this one were the same, it
;; means we've already given a "Complete, but not unique" message
;; and the user's hit TAB again, so now we give him help.
(t
- (when (and (eq this-command last-command) completion-auto-help)
+ (when (and (eq this-command last-command) completion-auto-help
+ (not (completion--icomplete-in-buffer-p)))
(minibuffer-completion-help beg end))
(completion--done completion 'exact
(unless (or expect-exact
@@ -1774,12 +1780,17 @@ completion--in-region-1
(t (prog1 (pcase (completion--do-completion beg end)
(#b000 nil)
(_ t))
- (if (window-live-p minibuffer-scroll-window)
- (and (eq completion-auto-select t)
- (eq t (frame-visible-p (window-frame minibuffer-scroll-window)))
- ;; When the completion list window was displayed, select it.
- (switch-to-completions))
- (completion-in-region-mode -1))))))
+ ;; FIXME: This reintroduces bug#67001 for `icomplete-in-region'
+ ;; users. It's not as bad for them, because Icomplete users
+ ;; probably expect to have to C-g out of completion before using
+ ;; other bindings, but it would still be better to fix it. --spwhitton
+ (unless (completion--icomplete-in-buffer-p)
+ (if (window-live-p minibuffer-scroll-window)
+ (and (eq completion-auto-select t)
+ (eq t (frame-visible-p (window-frame minibuffer-scroll-window)))
+ ;; When the completion list window was displayed, select it.
+ (switch-to-completions))
+ (completion-in-region-mode -1)))))))
(defun completion--cache-all-sorted-completions (beg end comps)
(add-hook 'after-change-functions
--
Sean Whitton