diff options
author | Juri Linkov <juri@linkov.net> | 2022-06-14 10:14:52 +0300 |
---|---|---|
committer | Juri Linkov <juri@linkov.net> | 2022-06-14 10:14:52 +0300 |
commit | 99cb3a7154cd1e1b751b7cdf84479cd850e7da17 (patch) | |
tree | 7be08b561215d0fd9ec45f19c29f88953d7d05d6 /lisp/minibuffer.el | |
parent | e494222814585cffaafa2c7784a2e4d632b8cd2d (diff) | |
download | emacs-99cb3a7154cd1e1b751b7cdf84479cd850e7da17.tar.gz emacs-99cb3a7154cd1e1b751b7cdf84479cd850e7da17.tar.bz2 emacs-99cb3a7154cd1e1b751b7cdf84479cd850e7da17.zip |
* 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
Diffstat (limited to 'lisp/minibuffer.el')
-rw-r--r-- | lisp/minibuffer.el | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index bf89874ecc8..7d589c01740 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -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, |