aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/minibuffer.el30
1 files changed, 22 insertions, 8 deletions
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index eb78bba80fc..d16d0362a36 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -543,12 +543,18 @@ Repeated uses step through the possible completions."
543 (setq completion-all-sorted-completions (cdr all))))) 543 (setq completion-all-sorted-completions (cdr all)))))
544 544
545(defun minibuffer-complete-and-exit () 545(defun minibuffer-complete-and-exit ()
546 "If the minibuffer contents is a valid completion then exit. 546 "Exit if the minibuffer contains a valid completion.
547Otherwise try to complete it. If completion leads to a valid completion, 547Otherwise, try to complete the minibuffer contents. If
548a repetition of this command will exit. 548completion leads to a valid completion, a repetition of this
549If `minibuffer-completion-confirm' is equal to `confirm', then do not 549command will exit.
550try to complete, but simply ask for confirmation and accept any 550
551input if confirmed." 551If `minibuffer-completion-confirm' is `confirm', do not try to
552 complete; instead, ask for confirmation and accept any input if
553 confirmed.
554If `minibuffer-completion-confirm' is `confirm-after-completion',
555 do not try to complete; instead, ask for confirmation if the
556 preceding minibuffer command was `minibuffer-complete', and
557 accept the input otherwise."
552 (interactive) 558 (interactive)
553 (let ((beg (field-beginning)) 559 (let ((beg (field-beginning))
554 (end (field-end))) 560 (end (field-end)))
@@ -578,14 +584,22 @@ input if confirmed."
578 (delete-region beg end)))) 584 (delete-region beg end))))
579 (exit-minibuffer)) 585 (exit-minibuffer))
580 586
581 ((eq minibuffer-completion-confirm 'confirm-only) 587 ((eq minibuffer-completion-confirm 'confirm)
582 ;; The user is permitted to exit with an input that's rejected 588 ;; The user is permitted to exit with an input that's rejected
583 ;; by test-completion, but at the condition to confirm her choice. 589 ;; by test-completion, after confirming her choice.
584 (if (eq last-command this-command) 590 (if (eq last-command this-command)
585 (exit-minibuffer) 591 (exit-minibuffer)
586 (minibuffer-message "Confirm") 592 (minibuffer-message "Confirm")
587 nil)) 593 nil))
588 594
595 ((eq minibuffer-completion-confirm 'confirm-after-completion)
596 ;; Similar to the above, but only if trying to exit immediately
597 ;; after typing TAB (this catches most minibuffer typos).
598 (if (eq last-command 'minibuffer-complete)
599 (progn (minibuffer-message "Confirm")
600 nil)
601 (exit-minibuffer)))
602
589 (t 603 (t
590 ;; Call do-completion, but ignore errors. 604 ;; Call do-completion, but ignore errors.
591 (case (condition-case nil 605 (case (condition-case nil