Update minibuffer-show-help based on minibuffer-visible-completions
authorSpencer Baugh <sbaugh@janestreet.com>
Wed, 24 Jan 2024 16:10:40 +0000 (11:10 -0500)
committerJuri Linkov <juri@linkov.net>
Thu, 25 Jan 2024 07:49:50 +0000 (09:49 +0200)
minibuffer-visible-completions makes some more convenient bindings
available, but the help shown by minibuffer-show-help wasn't
suggesting them.  Now it is.

* lisp/simple.el (completion-setup-function): Change help text when
minibuffer-visible-completions is non-nil. (bug#68689)

lisp/simple.el

index 4ffe159dc8868765eddfa94f91cb317f2d96e097..1157bd578fda6f55daf8f691e7f1e968b8a2f4cc 100644 (file)
@@ -10335,13 +10335,27 @@ Called from `temp-buffer-show-hook'."
       ;; Maybe insert help string.
       (when completion-show-help
        (goto-char (point-min))
-        (insert (substitute-command-keys
-                (if (display-mouse-p)
-                    "Click or type \\[minibuffer-choose-completion] on a completion to select it.\n"
-                   "Type \\[minibuffer-choose-completion] on a completion to select it.\n")))
-        (insert (substitute-command-keys
-                "Type \\[minibuffer-next-completion] or \\[minibuffer-previous-completion] \
-to move point between completions.\n\n"))))))
+        (if minibuffer-visible-completions
+            (let ((helps
+                   (with-current-buffer (window-buffer (active-minibuffer-window))
+                     (list
+                      (substitute-command-keys
+                      (if (display-mouse-p)
+                          "Click or type \\[minibuffer-choose-completion-or-exit] on a completion to select it.\n"
+                         "Type \\[minibuffer-choose-completion-or-exit] on a completion to select it.\n"))
+                      (substitute-command-keys
+                      "Type \\[minibuffer-next-completion], \\[minibuffer-previous-completion], \
+\\[minibuffer-next-line-completion], \\[minibuffer-previous-line-completion] \
+to move point between completions.\n\n")))))
+              (dolist (help helps)
+                (insert help)))
+          (insert (substitute-command-keys
+                  (if (display-mouse-p)
+                      "Click or type \\[minibuffer-choose-completion] on a completion to select it.\n"
+                     "Type \\[minibuffer-choose-completion] on a completion to select it.\n")))
+          (insert (substitute-command-keys
+                  "Type \\[minibuffer-next-completion] or \\[minibuffer-previous-completion] \
+to move point between completions.\n\n")))))))
 
 (add-hook 'completion-setup-hook #'completion-setup-function)