Mercurial > emacs
comparison lisp/minibuffer.el @ 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 | 63548ee8ae9f |
children | 3e1f480f4b69 |
comparison
equal
deleted
inserted
replaced
99882:ccbff16a0960 | 99883:494c4c7bcf01 |
---|---|
541 ;; so that repeated calls minibuffer-force-complete still cycle | 541 ;; so that repeated calls minibuffer-force-complete still cycle |
542 ;; through the previous possible completions. | 542 ;; through the previous 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. |
547 Otherwise try to complete it. If completion leads to a valid completion, | 547 Otherwise, try to complete the minibuffer contents. If |
548 a repetition of this command will exit. | 548 completion leads to a valid completion, a repetition of this |
549 If `minibuffer-completion-confirm' is equal to `confirm', then do not | 549 command will exit. |
550 try to complete, but simply ask for confirmation and accept any | 550 |
551 input if confirmed." | 551 If `minibuffer-completion-confirm' is `confirm', do not try to |
552 complete; instead, ask for confirmation and accept any input if | |
553 confirmed. | |
554 If `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))) |
555 (cond | 561 (cond |
556 ;; Allow user to specify null string | 562 ;; Allow user to specify null string |
576 (goto-char end) | 582 (goto-char end) |
577 (insert compl) | 583 (insert compl) |
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)) |
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))) | |
588 | 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 |
592 (completion--do-completion) | 606 (completion--do-completion) |