diff options
author | Jambunathan K <kjambunathan@gmail.com> | 2012-11-29 16:32:24 -0500 |
---|---|---|
committer | Stefan Monnier <monnier@iro.umontreal.ca> | 2012-11-29 16:32:24 -0500 |
commit | cc37e70f6699cbadb1a8f5467e8dc9fcea986aa1 (patch) | |
tree | d0bd2e2dc9ebf2f2a958c7acb9cff788f11788ca /lisp/minibuffer.el | |
parent | 83e12fe07c18a6190c6c5ef6e959697eb0ac9f19 (diff) | |
download | emacs-cc37e70f6699cbadb1a8f5467e8dc9fcea986aa1.tar.gz |
* lisp/icomplete.el: Change separator; add ido-style commands.
(icomplete-show-key-bindings): Remove custom var.
(icomplete-get-keys): Remove function.
(icomplete-forward-completions, icomplete-backward-completions):
New commands.
(icomplete-minibuffer-map): New var.
(icomplete-minibuffer-setup): Use it.
(icomplete-exhibit): Don't delay if the list of completions is known.
(icomplete-separator): New custom.
(icomplete-completions): Use it.
* lisp/minibuffer.el (completion-all-sorted-completions): Delete duplicates.
(minibuffer-force-complete-and-exit): New command.
(minibuffer--complete-and-exit): New function extracted from
minibuffer-complete-and-exit.
(minibuffer-complete-and-exit): Use it.
Diffstat (limited to 'lisp/minibuffer.el')
-rw-r--r-- | lisp/minibuffer.el | 42 |
1 files changed, 33 insertions, 9 deletions
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index 6e704fad807..7fe50e930ce 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -1106,6 +1106,13 @@ scroll the window of possible completions." (sort-fun (completion-metadata-get all-md 'cycle-sort-function))) (when last (setcdr last nil) + + ;; Delete duplicates: do it after setting last's cdr to nil (so + ;; it's a proper list), and be careful to reset `last' since it + ;; may be a different cons-cell. + (setq all (delete-dups all)) + (setq last (last all)) + (setq all (if sort-fun (funcall sort-fun all) ;; Prefer shorter completions, by default. (sort all (lambda (c1 c2) (< (length c1) (length c2)))))) @@ -1120,6 +1127,15 @@ scroll the window of possible completions." ;; all possibilities. (completion--cache-all-sorted-completions (nconc all base-size)))))) +(defun minibuffer-force-complete-and-exit () + "Complete the minibuffer with first of the matches and exit." + (interactive) + (minibuffer-force-complete) + (minibuffer--complete-and-exit + ;; If the previous completion completed to an element which fails + ;; test-completion, then we shouldn't exit, but that should be rare. + (lambda () (minibuffer-message "Incomplete")))) + (defun minibuffer-force-complete () "Complete the minibuffer to an exact match. Repeated uses step through the possible completions." @@ -1192,6 +1208,22 @@ If `minibuffer-completion-confirm' is `confirm-after-completion', `minibuffer-confirm-exit-commands', and accept the input otherwise." (interactive) + (minibuffer--complete-and-exit + (lambda () + (pcase (condition-case nil + (completion--do-completion nil 'expect-exact) + (error 1)) + ((or #b001 #b011) (exit-minibuffer)) + (#b111 (if (not minibuffer-completion-confirm) + (exit-minibuffer) + (minibuffer-message "Confirm") + nil)) + (_ nil))))) + +(defun minibuffer--complete-and-exit (completion-function) + "Exit from `require-match' minibuffer. +COMPLETION-FUNCTION is called if the current buffer's content does not +appear to be a match." (let ((beg (field-beginning)) (end (field-end))) (cond @@ -1239,15 +1271,7 @@ If `minibuffer-completion-confirm' is `confirm-after-completion', (t ;; Call do-completion, but ignore errors. - (pcase (condition-case nil - (completion--do-completion nil 'expect-exact) - (error 1)) - ((or #b001 #b011) (exit-minibuffer)) - (#b111 (if (not minibuffer-completion-confirm) - (exit-minibuffer) - (minibuffer-message "Confirm") - nil)) - (_ nil)))))) + (funcall completion-function))))) (defun completion--try-word-completion (string table predicate point md) (let ((comp (completion-try-completion string table predicate point md))) |