Subject: 29.0.50; Imenu does not pop up the Completions eagerly

From: Protesilaos Stavrou <[email-masked]>
Date: Thu, 09 Dec 2021 15:32:11 +0200

Dear maintainers,

I think the current behaviour of 'imenu-eager-completion-buffer' is
counter-intuitive.  Its default value is non-nil, while its doc string
tells us that:

    If non-nil, eagerly popup the completion buffer.

This, however, is not what actually happens.  With 'emacs -Q':

+ Include a demo function in the scratch buffer: (defun test-fn ())
+ M-x imenu
+ Here we expect the Completions' buffer to eagerly pop up, yet it does
  not.
+ M-: (setq imenu-eager-completion-buffer nil)
+ M-x imenu
+ The Completions' buffer now pops up automatically.

Do you agree that this is counter-intuitive?  If so, please find
attached a patch that should fix the issue.  I was not sure this was
NEWSworthy, but I included an entry regardless.

All the best,
Protesilaos

-- 
Protesilaos Stavrou
https://protesilaos.com
>From b4625110cb5b40f079c134a73e9be8240818fa33 Mon Sep 17 00:00:00 2001
Message-Id: <[email-masked]>
From: Protesilaos Stavrou <[email-masked]>
Date: Thu, 9 Dec 2021 15:19:48 +0200
Subject: [PATCH] Fix semantics of imenu-eager-completion-buffer

* etc/NEWS: Document the change.
* lisp/imenu.el (imenu-eager-completion-buffer): Set the default value
to nil, as that was the intended one.
(imenu--completion-buffer): Update the condition to check for a
non-nil value to 'imenu-eager-completion-buffer'.
---
 etc/NEWS      | 7 +++++++
 lisp/imenu.el | 6 +++---
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index b9134d850e..a83f2d2a86 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -706,6 +706,13 @@ the Netscape web browser was released in February, 2008.
 This support has been obsolete since Emacs 25.1.  The final version of
 the Galeon web browser was released in September, 2008.
 
+** Imenu
+The default value of 'imenu-eager-completion-buffer' is set to nil to
+better convey the intended semantics of optionally popping up the
+Completions' buffer automatically after invoking M-x imenu (with the
+default settings from previous versions, the Completions would not pop
+up automatically and the same is true now).
+
 
 * New Modes and Packages in Emacs 29.1
 
diff --git a/lisp/imenu.el b/lisp/imenu.el
index 22412d5f88..bf12e110e5 100644
--- a/lisp/imenu.el
+++ b/lisp/imenu.el
@@ -99,10 +99,10 @@ (defcustom imenu-use-popup-menu 'on-mouse
 		 (const :tag "Never" nil)
                  (other :tag "Always" t)))
 
-(defcustom imenu-eager-completion-buffer t
+(defcustom imenu-eager-completion-buffer nil
   "If non-nil, eagerly popup the completion buffer."
   :type 'boolean
-  :version "22.1")
+  :version "29.1")
 
 (defcustom imenu-after-jump-hook nil
   "Hooks called after jumping to a place in the buffer.
@@ -727,7 +727,7 @@ (defun imenu--completion-buffer (index-alist &optional prompt)
                          name))))
     (let ((minibuffer-setup-hook minibuffer-setup-hook))
       ;; Display the completion buffer.
-      (if (not imenu-eager-completion-buffer)
+      (when imenu-eager-completion-buffer
 	  (add-hook 'minibuffer-setup-hook 'minibuffer-completion-help))
       (setq name (completing-read prompt
 				  prepared-index-alist
-- 
2.34.1