aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuri Linkov2022-06-14 10:14:52 +0300
committerJuri Linkov2022-06-14 10:14:52 +0300
commit99cb3a7154cd1e1b751b7cdf84479cd850e7da17 (patch)
tree7be08b561215d0fd9ec45f19c29f88953d7d05d6
parente494222814585cffaafa2c7784a2e4d632b8cd2d (diff)
downloademacs-99cb3a7154cd1e1b751b7cdf84479cd850e7da17.tar.gz
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
-rw-r--r--etc/NEWS6
-rw-r--r--lisp/minibuffer.el30
2 files changed, 36 insertions, 0 deletions
diff --git a/etc/NEWS b/etc/NEWS
index eb4c6956b81..73416fb30cd 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1090,6 +1090,12 @@ to complete. The value 'visual' is like 'always', but only updates
1090the completions if they are already visible. The default value 't' 1090the completions if they are already visible. The default value 't'
1091always hides the completion buffer after some completion is made. 1091always hides the completion buffer after some completion is made.
1092 1092
1093*** New commands to complete the minibuffer history.
1094'minibuffer-complete-history' ('C-x up') is like 'minibuffer-complete'
1095but completes on the history items instead of the default completion
1096table. 'minibuffer-complete-defaults' ('C-x down') completes
1097on the list of default items.
1098
1093+++ 1099+++
1094*** New user option 'completions-sort'. 1100*** New user option 'completions-sort'.
1095This option controls the sorting of the completion candidates in 1101This option controls the sorting of the completion candidates in
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."
4425 (let ((completion-use-base-affixes t)) 4425 (let ((completion-use-base-affixes t))
4426 (choose-completion nil no-exit no-quit)))) 4426 (choose-completion nil no-exit no-quit))))
4427 4427
4428(defun minibuffer-complete-history ()
4429 "Complete the minibuffer history as far as possible.
4430Like `minibuffer-complete' but completes on the history items
4431instead of the default completion table."
4432 (interactive)
4433 (let ((completions-sort nil)
4434 (history (mapcar (lambda (h)
4435 ;; Support e.g. `C-x ESC ESC TAB' as
4436 ;; a replacement of `list-command-history'
4437 (if (consp h) (format "%S" h) h))
4438 (symbol-value minibuffer-history-variable))))
4439 (completion-in-region (minibuffer--completion-prompt-end) (point-max)
4440 history nil)))
4441
4442(defun minibuffer-complete-defaults ()
4443 "Complete minibuffer defaults as far as possible.
4444Like `minibuffer-complete' but completes on the default items
4445instead of the completion table."
4446 (interactive)
4447 (let ((completions-sort nil))
4448 (when (and (not minibuffer-default-add-done)
4449 (functionp minibuffer-default-add-function))
4450 (setq minibuffer-default-add-done t
4451 minibuffer-default (funcall minibuffer-default-add-function)))
4452 (completion-in-region (minibuffer--completion-prompt-end) (point-max)
4453 (ensure-list minibuffer-default) nil)))
4454
4455(define-key minibuffer-local-map [?\C-x up] 'minibuffer-complete-history)
4456(define-key minibuffer-local-map [?\C-x down] 'minibuffer-complete-defaults)
4457
4428(defcustom minibuffer-default-prompt-format " (default %s)" 4458(defcustom minibuffer-default-prompt-format " (default %s)"
4429 "Format string used to output \"default\" values. 4459 "Format string used to output \"default\" values.
4430When prompting for input, there will often be a default value, 4460When prompting for input, there will often be a default value,