changeset 99883:494c4c7bcf01

(minibuffer-complete-and-exit): Change `confirm-only' value of minibuffer-completion-confirm to `confirm', and handle a `confirm-after-completion' value.
author Chong Yidong <cyd@stupidchicken.com>
date Mon, 24 Nov 2008 19:14:05 +0000
parents ccbff16a0960
children e73ab780756d
files lisp/minibuffer.el
diffstat 1 files changed, 22 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/minibuffer.el	Mon Nov 24 19:13:58 2008 +0000
+++ b/lisp/minibuffer.el	Mon Nov 24 19:14:05 2008 +0000
@@ -543,12 +543,18 @@
       (setq completion-all-sorted-completions (cdr all)))))
 
 (defun minibuffer-complete-and-exit ()
-  "If the minibuffer contents is a valid completion then exit.
-Otherwise try to complete it.  If completion leads to a valid completion,
-a repetition of this command will exit.
-If `minibuffer-completion-confirm' is equal to `confirm', then do not
-try to complete, but simply ask for confirmation and accept any
-input if confirmed."
+  "Exit if the minibuffer contains a valid completion.
+Otherwise, try to complete the minibuffer contents.  If
+completion leads to a valid completion, a repetition of this
+command will exit.
+
+If `minibuffer-completion-confirm' is `confirm', do not try to
+ complete; instead, ask for confirmation and accept any input if
+ confirmed.
+If `minibuffer-completion-confirm' is `confirm-after-completion',
+ do not try to complete; instead, ask for confirmation if the
+ preceding minibuffer command was `minibuffer-complete', and
+ accept the input otherwise."
   (interactive)
   (let ((beg (field-beginning))
         (end (field-end)))
@@ -578,14 +584,22 @@
             (delete-region beg end))))
       (exit-minibuffer))
 
-     ((eq minibuffer-completion-confirm 'confirm-only)
+     ((eq minibuffer-completion-confirm 'confirm)
       ;; The user is permitted to exit with an input that's rejected
-      ;; by test-completion, but at the condition to confirm her choice.
+      ;; by test-completion, after confirming her choice.
       (if (eq last-command this-command)
           (exit-minibuffer)
         (minibuffer-message "Confirm")
         nil))
 
+     ((eq minibuffer-completion-confirm 'confirm-after-completion)
+      ;; Similar to the above, but only if trying to exit immediately
+      ;; after typing TAB (this catches most minibuffer typos).
+      (if (eq last-command 'minibuffer-complete)
+	  (progn (minibuffer-message "Confirm")
+		 nil)
+	(exit-minibuffer)))
+
      (t
       ;; Call do-completion, but ignore errors.
       (case (condition-case nil