@pxref{Shell Options}.
@vindex completion-auto-help
- If @code{completion-auto-help} is set to @code{nil}, the completion
-commands never display the completion list buffer; you must type
-@kbd{?} to display the list. If the value is @code{lazy}, Emacs only
-shows the completion list buffer on the second attempt to complete.
-In other words, if there is nothing to complete, the first @key{TAB}
-echoes @samp{Next char not unique}; the second @key{TAB} shows the
-completion list buffer. If the value is @code{always}, the completion
-list buffer is always shown when completion is attempted.
+ Emacs can show the @samp{*Completions*} buffer automatically in
+certain conditions. You can control this behavior by customizing the
+user option @code{completion-auto-help}. By default, this option is
+set to @code{t}, which says to show the @samp{*Completions*} buffer
+when you try to complete the minibuffer input and there is more then
+one way to complete your input. If the value is @code{lazy}, Emacs
+only shows the @samp{*Completions*} buffer on the second attempt to
+complete---the first @key{TAB} echoes @samp{Next char not unique}, and
+the second @key{TAB} shows the completion list buffer. If the value
+is @code{always}, Emacs shows the @samp{*Completions*} buffer whenever
+you invoke completion. If @code{completion-auto-help} is set to
+@code{nil}, the completion commands never display the completion list
+buffer; you must type @kbd{?} to display the list.
The display of the completion list buffer after it is shown for the
first time is also controlled by @code{completion-auto-help}. If the
completion list buffer, and like @code{always} when it decides whether
to pop it down.
+@cindex Completions Auto Update minor mode
+@findex completions-auto-update-mode
+ Beyond showing the @samp{*Completions*} buffer when you invoke
+completion commands with non-@code{nil} @samp{completion-auto-help},
+Emacs also provides the Completions Auto Update minor mode that
+updates the @samp{*Completions*} buffer to reflect your new input as
+you type in the minibuffer. To enable Completions Auto Update mode,
+type @kbd{M-x completions-auto-update-mode}.
+
@vindex completion-auto-select
Emacs can optionally select the window showing the completions when
it shows that window. To enable this behavior, customize the user
(remove-hook 'minibuffer-setup-hook #'minibuffer--regexp-setup)
(remove-hook 'minibuffer-exit-hook #'minibuffer--regexp-exit)))
+(defcustom completions-auto-update-idle-time 0.2
+ "Number of seconds of idle to wait for before updating *Completions*.
+This applies to `completions-auto-update-mode', which see."
+ :group 'minibuffer
+ :type 'number)
+
+(defvar-local completions-auto-update-timer nil)
+
+(defun completions-auto-update ()
+ "Update the *Completions* buffer, if it is visible."
+ (when (get-buffer-window "*Completions*" 0)
+ (if completion-in-region-mode
+ (completion-help-at-point)
+ (minibuffer-completion-help)))
+ (setq completions-auto-update-timer nil))
+
+(defun completions-auto-update-start-timer ()
+ "Start an idle timer for updating *Completions*."
+ (and (null completions-auto-update-timer)
+ (get-buffer-window "*Completions*" 0)
+ (setq completions-auto-update-timer
+ (run-with-idle-timer completions-auto-update-idle-time
+ nil #'completions-auto-update))))
+
+(defun completions-auto-update-setup ()
+ "Prepare for updating *Completions* as you type in the minibuffer."
+ (add-hook 'post-self-insert-hook
+ #'completions-auto-update-start-timer nil t))
+
+(defun completions-auto-update-exit ()
+ "Stop updating *Completions* as you type in the minibuffer."
+ (remove-hook 'post-self-insert-hook
+ #'completions-auto-update-start-timer t))
+
+(define-minor-mode completions-auto-update-mode
+ "Update the *Completions* buffer as you type in the minibuffer."
+ :global t
+ (if completions-auto-update-mode
+ (progn
+ (add-hook 'minibuffer-setup-hook #'completions-auto-update-setup)
+ (add-hook 'minibuffer-exit-hook #'completions-auto-update-exit))
+ (remove-hook 'minibuffer-setup-hook #'completions-auto-update-setup)
+ (remove-hook 'minibuffer-exit-hook #'completions-auto-update-exit)))
+
(provide 'minibuffer)
;;; minibuffer.el ends here