* lisp/minibuffer.el (minibuffer-complete-history): New command.

(minibuffer-complete-defaults): New command.
https://lists.gnu.org/archive/html/emacs-devel/2022-06/msg00498.html
This commit is contained in:
Juri Linkov 2022-06-14 10:14:52 +03:00
parent e494222814
commit 99cb3a7154
2 changed files with 36 additions and 0 deletions

View file

@ -1090,6 +1090,12 @@ to complete. The value 'visual' is like 'always', but only updates
the completions if they are already visible. The default value 't'
always hides the completion buffer after some completion is made.
*** New commands to complete the minibuffer history.
'minibuffer-complete-history' ('C-x up') is like 'minibuffer-complete'
but completes on the history items instead of the default completion
table. 'minibuffer-complete-defaults' ('C-x down') completes
on the list of default items.
+++
*** New user option 'completions-sort'.
This option controls the sorting of the completion candidates in

View file

@ -4425,6 +4425,36 @@ minibuffer, but don't quit the completions window."
(let ((completion-use-base-affixes t))
(choose-completion nil no-exit no-quit))))
(defun minibuffer-complete-history ()
"Complete the minibuffer history as far as possible.
Like `minibuffer-complete' but completes on the history items
instead of the default completion table."
(interactive)
(let ((completions-sort nil)
(history (mapcar (lambda (h)
;; Support e.g. `C-x ESC ESC TAB' as
;; a replacement of `list-command-history'
(if (consp h) (format "%S" h) h))
(symbol-value minibuffer-history-variable))))
(completion-in-region (minibuffer--completion-prompt-end) (point-max)
history nil)))
(defun minibuffer-complete-defaults ()
"Complete minibuffer defaults as far as possible.
Like `minibuffer-complete' but completes on the default items
instead of the completion table."
(interactive)
(let ((completions-sort nil))
(when (and (not minibuffer-default-add-done)
(functionp minibuffer-default-add-function))
(setq minibuffer-default-add-done t
minibuffer-default (funcall minibuffer-default-add-function)))
(completion-in-region (minibuffer--completion-prompt-end) (point-max)
(ensure-list minibuffer-default) nil)))
(define-key minibuffer-local-map [?\C-x up] 'minibuffer-complete-history)
(define-key minibuffer-local-map [?\C-x down] 'minibuffer-complete-defaults)
(defcustom minibuffer-default-prompt-format " (default %s)"
"Format string used to output \"default\" values.
When prompting for input, there will often be a default value,