diff options
| author | Dmitry Gutov | 2015-05-19 15:52:27 +0300 |
|---|---|---|
| committer | Dmitry Gutov | 2015-05-19 15:53:32 +0300 |
| commit | 08033db08bc2bc75221b0dde97257c987d4efa00 (patch) | |
| tree | e476efa54d991602dd92574b57f1a997418ab54e | |
| parent | e0fec8d3cad6efbcc39c5c9d1d53cef40f27a250 (diff) | |
| download | emacs-08033db08bc2bc75221b0dde97257c987d4efa00.tar.gz emacs-08033db08bc2bc75221b0dde97257c987d4efa00.zip | |
New command icomplete-force-complete-and-exit
* lisp/icomplete.el (icomplete-force-complete-and-exit):
New command
(http://lists.gnu.org/archive/html/emacs-devel/2015-05/msg00461.html)
(http://lists.gnu.org/archive/html/emacs-devel/2015-05/msg00516.html).
(icomplete-minibuffer-map): Bind C-j to it.
(icomplete-forward-completions, icomplete-backward-completions):
Mention the new command in the docstring.
* lisp/minibuffer.el (minibuffer-force-complete-and-exit): Revert
the previous fix for bug#17545.
| -rw-r--r-- | lisp/icomplete.el | 16 | ||||
| -rw-r--r-- | lisp/minibuffer.el | 16 |
2 files changed, 19 insertions, 13 deletions
diff --git a/lisp/icomplete.el b/lisp/icomplete.el index ee281122852..b1894ca5874 100644 --- a/lisp/icomplete.el +++ b/lisp/icomplete.el | |||
| @@ -149,16 +149,26 @@ icompletion is occurring." | |||
| 149 | (defvar icomplete-minibuffer-map | 149 | (defvar icomplete-minibuffer-map |
| 150 | (let ((map (make-sparse-keymap))) | 150 | (let ((map (make-sparse-keymap))) |
| 151 | (define-key map [?\M-\t] 'minibuffer-force-complete) | 151 | (define-key map [?\M-\t] 'minibuffer-force-complete) |
| 152 | (define-key map [?\C-j] 'minibuffer-force-complete-and-exit) | 152 | (define-key map [?\C-j] 'icomplete-force-complete-and-exit) |
| 153 | (define-key map [?\C-.] 'icomplete-forward-completions) | 153 | (define-key map [?\C-.] 'icomplete-forward-completions) |
| 154 | (define-key map [?\C-,] 'icomplete-backward-completions) | 154 | (define-key map [?\C-,] 'icomplete-backward-completions) |
| 155 | map) | 155 | map) |
| 156 | "Keymap used by `icomplete-mode' in the minibuffer.") | 156 | "Keymap used by `icomplete-mode' in the minibuffer.") |
| 157 | 157 | ||
| 158 | (defun icomplete-force-complete-and-exit () | ||
| 159 | "Complete the minibuffer and exit. | ||
| 160 | Use the first of the matches if there are any displayed, and use | ||
| 161 | the default otherwise." | ||
| 162 | (interactive) | ||
| 163 | (if (or icomplete-show-matches-on-no-input | ||
| 164 | (> (icomplete--field-end) (icomplete--field-beg))) | ||
| 165 | (minibuffer-force-complete-and-exit) | ||
| 166 | (minibuffer-complete-and-exit))) | ||
| 167 | |||
| 158 | (defun icomplete-forward-completions () | 168 | (defun icomplete-forward-completions () |
| 159 | "Step forward completions by one entry. | 169 | "Step forward completions by one entry. |
| 160 | Second entry becomes the first and can be selected with | 170 | Second entry becomes the first and can be selected with |
| 161 | `minibuffer-force-complete-and-exit'." | 171 | `icomplete-force-complete-and-exit'." |
| 162 | (interactive) | 172 | (interactive) |
| 163 | (let* ((beg (icomplete--field-beg)) | 173 | (let* ((beg (icomplete--field-beg)) |
| 164 | (end (icomplete--field-end)) | 174 | (end (icomplete--field-end)) |
| @@ -171,7 +181,7 @@ Second entry becomes the first and can be selected with | |||
| 171 | (defun icomplete-backward-completions () | 181 | (defun icomplete-backward-completions () |
| 172 | "Step backward completions by one entry. | 182 | "Step backward completions by one entry. |
| 173 | Last entry becomes the first and can be selected with | 183 | Last entry becomes the first and can be selected with |
| 174 | `minibuffer-force-complete-and-exit'." | 184 | `icomplete-force-complete-and-exit'." |
| 175 | (interactive) | 185 | (interactive) |
| 176 | (let* ((beg (icomplete--field-beg)) | 186 | (let* ((beg (icomplete--field-beg)) |
| 177 | (end (icomplete--field-end)) | 187 | (end (icomplete--field-end)) |
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index 538bd974256..60b89b6d521 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el | |||
| @@ -1241,16 +1241,12 @@ scroll the window of possible completions." | |||
| 1241 | (defun minibuffer-force-complete-and-exit () | 1241 | (defun minibuffer-force-complete-and-exit () |
| 1242 | "Complete the minibuffer with first of the matches and exit." | 1242 | "Complete the minibuffer with first of the matches and exit." |
| 1243 | (interactive) | 1243 | (interactive) |
| 1244 | (if (and (eq (minibuffer-prompt-end) (point-max)) | 1244 | (minibuffer-force-complete) |
| 1245 | minibuffer-default) | 1245 | (completion--complete-and-exit |
| 1246 | ;; Use the provided default if there's one (bug#17545). | 1246 | (minibuffer-prompt-end) (point-max) #'exit-minibuffer |
| 1247 | (minibuffer-complete-and-exit) | 1247 | ;; If the previous completion completed to an element which fails |
| 1248 | (minibuffer-force-complete) | 1248 | ;; test-completion, then we shouldn't exit, but that should be rare. |
| 1249 | (completion--complete-and-exit | 1249 | (lambda () (minibuffer-message "Incomplete")))) |
| 1250 | (minibuffer-prompt-end) (point-max) #'exit-minibuffer | ||
| 1251 | ;; If the previous completion completed to an element which fails | ||
| 1252 | ;; test-completion, then we shouldn't exit, but that should be rare. | ||
| 1253 | (lambda () (minibuffer-message "Incomplete"))))) | ||
| 1254 | 1250 | ||
| 1255 | (defun minibuffer-force-complete (&optional start end) | 1251 | (defun minibuffer-force-complete (&optional start end) |
| 1256 | "Complete the minibuffer to an exact match. | 1252 | "Complete the minibuffer to an exact match. |