diff options
| author | Stefan Monnier | 2008-05-20 03:36:20 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2008-05-20 03:36:20 +0000 |
| commit | 476d2aef425a16800841475fcc23e003b9d96345 (patch) | |
| tree | 4049db9620d442d2871138aa83fc5e6a40cd1817 /lisp | |
| parent | 6a221b7dc472674d2a95a4155c7400c03ceda35c (diff) | |
| download | emacs-476d2aef425a16800841475fcc23e003b9d96345.tar.gz emacs-476d2aef425a16800841475fcc23e003b9d96345.zip | |
(icomplete-simple-completing-p):
Allow icomplete-with-completion-tables to say "use it everywhere".
(icomplete-completions): Obey completion-styles. Try to accomodate
partial-completion style.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/ChangeLog | 7 | ||||
| -rw-r--r-- | lisp/icomplete.el | 70 |
2 files changed, 57 insertions, 20 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 71f1d108abf..bff5545b453 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,10 @@ | |||
| 1 | 2008-05-20 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | * icomplete.el (icomplete-simple-completing-p): | ||
| 4 | Allow icomplete-with-completion-tables to say "use it everywhere". | ||
| 5 | (icomplete-completions): Obey completion-styles. Try to accomodate | ||
| 6 | partial-completion style. | ||
| 7 | |||
| 1 | 2008-05-20 Michael Olson <mwolson@gnu.org> | 8 | 2008-05-20 Michael Olson <mwolson@gnu.org> |
| 2 | 9 | ||
| 3 | * files.el (project-find-settings-file): Change concat to | 10 | * files.el (project-find-settings-file): Change concat to |
diff --git a/lisp/icomplete.el b/lisp/icomplete.el index 9b93d637a50..38fbf8f42e7 100644 --- a/lisp/icomplete.el +++ b/lisp/icomplete.el | |||
| @@ -189,6 +189,7 @@ Conditions are: | |||
| 189 | (not executing-kbd-macro) | 189 | (not executing-kbd-macro) |
| 190 | minibuffer-completion-table | 190 | minibuffer-completion-table |
| 191 | (or (not (functionp minibuffer-completion-table)) | 191 | (or (not (functionp minibuffer-completion-table)) |
| 192 | (eq icomplete-with-completion-tables t) | ||
| 192 | (member minibuffer-completion-table | 193 | (member minibuffer-completion-table |
| 193 | icomplete-with-completion-tables)))) | 194 | icomplete-with-completion-tables)))) |
| 194 | 195 | ||
| @@ -280,29 +281,58 @@ The displays for unambiguous matches have ` [Matched]' appended | |||
| 280 | matches exist. \(Keybindings for uniquely matched commands | 281 | matches exist. \(Keybindings for uniquely matched commands |
| 281 | are exhibited within the square braces.)" | 282 | are exhibited within the square braces.)" |
| 282 | 283 | ||
| 283 | (let ((comps (all-completions name candidates predicate)) | 284 | (let* ((comps (completion-all-completions name candidates predicate |
| 284 | ; "-determined" - only one candidate | 285 | (length name))) |
| 285 | (open-bracket-determined (if require-match "(" "[")) | 286 | (last (last comps)) |
| 286 | (close-bracket-determined (if require-match ")" "]"))) | 287 | (base-size (if (consp last) (prog1 (cdr last) (setcdr last nil)))) |
| 288 | (open-bracket (if require-match "(" "[")) | ||
| 289 | (close-bracket (if require-match ")" "]"))) | ||
| 287 | ;; `concat'/`mapconcat' is the slow part. With the introduction of | 290 | ;; `concat'/`mapconcat' is the slow part. With the introduction of |
| 288 | ;; `icomplete-prospects-length', there is no need for `catch'/`throw'. | 291 | ;; `icomplete-prospects-length', there is no need for `catch'/`throw'. |
| 289 | (if (null comps) (format " %sNo matches%s" | 292 | (if (null comps) |
| 290 | open-bracket-determined | 293 | (format " %sNo matches%s" open-bracket close-bracket) |
| 291 | close-bracket-determined) | 294 | (let* ((most-try (completion-try-completion |
| 292 | (let* ((most-try (try-completion name (mapcar (function list) comps))) | 295 | name |
| 293 | (most (if (stringp most-try) most-try (car comps))) | 296 | ;; If the `comps' are 0-based, the result should be |
| 294 | (most-len (length most)) | 297 | ;; the same with `comps'. |
| 295 | (determ (and (> most-len (length name)) | 298 | (if base-size candidates comps) |
| 296 | (concat open-bracket-determined | 299 | predicate |
| 297 | (substring most (length name)) | 300 | (length name))) |
| 298 | close-bracket-determined))) | 301 | (most (if (consp most-try) (car most-try) (car comps))) |
| 302 | ;; Compare name and most, so we can determine if name is | ||
| 303 | ;; a prefix of most, or something else. | ||
| 304 | (compare (compare-strings name nil nil | ||
| 305 | most nil nil completion-ignore-case)) | ||
| 306 | (determ (unless (or (eq t compare) (eq t most-try) | ||
| 307 | (= (setq compare (1- (abs compare))) | ||
| 308 | (length most))) | ||
| 309 | (concat open-bracket | ||
| 310 | (cond | ||
| 311 | ((= compare (length name)) | ||
| 312 | ;; Typical case: name is a prefix. | ||
| 313 | (substring most compare)) | ||
| 314 | ((< compare 5) most) | ||
| 315 | (t (concat "..." (substring most compare)))) | ||
| 316 | close-bracket))) | ||
| 299 | ;;"-prospects" - more than one candidate | 317 | ;;"-prospects" - more than one candidate |
| 300 | (prospects-len (+ (length determ) 6)) ;; take {,...} into account | 318 | (prospects-len (+ (length determ) 6)) ;; take {,...} into account |
| 319 | (prefix-len | ||
| 320 | ;; Find the common prefix among `comps'. | ||
| 321 | (if (eq t (compare-strings (car comps) nil (length most) | ||
| 322 | most nil nil case-fold-search)) | ||
| 323 | ;; Common case. | ||
| 324 | (length most) | ||
| 325 | ;; Else, use try-completion. | ||
| 326 | (let ((comps-prefix (try-completion "" comps))) | ||
| 327 | (and (stringp comps-prefix) | ||
| 328 | (length comps-prefix))))) | ||
| 329 | |||
| 301 | prospects most-is-exact comp limit) | 330 | prospects most-is-exact comp limit) |
| 302 | (if (eq most-try t) | 331 | (if (or (eq most-try t) (null (cdr comps))) |
| 303 | (setq prospects nil) | 332 | (setq prospects nil) |
| 304 | (while (and comps (not limit)) | 333 | (while (and comps (not limit)) |
| 305 | (setq comp (substring (car comps) most-len) | 334 | (setq comp |
| 335 | (if prefix-len (substring (car comps) prefix-len) (car comps)) | ||
| 306 | comps (cdr comps)) | 336 | comps (cdr comps)) |
| 307 | (cond ((string-equal comp "") (setq most-is-exact t)) | 337 | (cond ((string-equal comp "") (setq most-is-exact t)) |
| 308 | ((member comp prospects)) | 338 | ((member comp prospects)) |
| @@ -327,10 +357,10 @@ are exhibited within the square braces.)" | |||
| 327 | (if keys (concat "; " keys) "")) | 357 | (if keys (concat "; " keys) "")) |
| 328 | "]")))))) | 358 | "]")))))) |
| 329 | 359 | ||
| 330 | ;;;_* Local emacs vars. | 360 | ;;_* Local emacs vars. |
| 331 | ;;;Local variables: | 361 | ;;Local variables: |
| 332 | ;;;allout-layout: (-2 :) | 362 | ;;allout-layout: (-2 :) |
| 333 | ;;;End: | 363 | ;;End: |
| 334 | 364 | ||
| 335 | ;; arch-tag: 339ec25a-0741-4eb6-be63-997532e89b0f | 365 | ;; arch-tag: 339ec25a-0741-4eb6-be63-997532e89b0f |
| 336 | ;;; icomplete.el ends here | 366 | ;;; icomplete.el ends here |