diff options
| -rw-r--r-- | lisp/icomplete.el | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/lisp/icomplete.el b/lisp/icomplete.el index 89318ca4c7e..47e47f895f0 100644 --- a/lisp/icomplete.el +++ b/lisp/icomplete.el | |||
| @@ -152,13 +152,33 @@ icompletion is occurring." | |||
| 152 | "Keymap used by `icomplete-mode' in the minibuffer.") | 152 | "Keymap used by `icomplete-mode' in the minibuffer.") |
| 153 | 153 | ||
| 154 | (defun icomplete-force-complete-and-exit () | 154 | (defun icomplete-force-complete-and-exit () |
| 155 | "Complete the minibuffer and exit. | 155 | "Complete the minibuffer with the longest possible match and exit. |
| 156 | Use the first of the matches if there are any displayed, and use | 156 | Use the first of the matches if there are any displayed, and use |
| 157 | the default otherwise." | 157 | the default otherwise." |
| 158 | (interactive) | 158 | (interactive) |
| 159 | (if (or (and (not minibuffer-default) icomplete-show-matches-on-no-input) | 159 | ;; This function is tricky. The mandate is to "force", meaning we |
| 160 | (> (icomplete--field-end) (icomplete--field-beg))) | 160 | ;; should take the first possible valid completion for the input. |
| 161 | ;; However, if there is no input and we can prove that that | ||
| 162 | ;; coincides with the default, it is much faster to just call | ||
| 163 | ;; `minibuffer-complete-and-exit'. Otherwise, we have to call | ||
| 164 | ;; `minibuffer-force-complete-and-exit', which needs the full | ||
| 165 | ;; completion set and is potentially slow and blocking. Do the | ||
| 166 | ;; latter if: | ||
| 167 | (if (or | ||
| 168 | ;; there's some input, meaning the default in off the table by | ||
| 169 | ;; definition; OR | ||
| 170 | (> (icomplete--field-end) (icomplete--field-beg)) | ||
| 171 | ;; there's no input, but there's also no minibuffer default | ||
| 172 | ;; (and the user really wants to see completions on no input, | ||
| 173 | ;; meaning he expects a "force" to be at least attempted); OR | ||
| 174 | (and (not minibuffer-default) | ||
| 175 | icomplete-show-matches-on-no-input) | ||
| 176 | ;; there's no input but the full completion set has been | ||
| 177 | ;; calculated, This causes the first cached completion to | ||
| 178 | ;; be taken (i.e. the one that the user sees highlighted) | ||
| 179 | completion-all-sorted-completions) | ||
| 161 | (minibuffer-force-complete-and-exit) | 180 | (minibuffer-force-complete-and-exit) |
| 181 | ;; Otherwise take the faster route... | ||
| 162 | (minibuffer-complete-and-exit))) | 182 | (minibuffer-complete-and-exit))) |
| 163 | 183 | ||
| 164 | (defun icomplete-force-complete () | 184 | (defun icomplete-force-complete () |