diff options
| author | João Távora | 2019-01-15 12:10:23 +0000 |
|---|---|---|
| committer | João Távora | 2019-01-17 15:17:02 +0000 |
| commit | 5a6df06494f9ba6df53af82cfdf81f1d3708edc3 (patch) | |
| tree | f48bf19352af749fe72b082f06603e85557ffdcd | |
| parent | 7560ef7de925b56f367df168befc9b748b6237c1 (diff) | |
| download | emacs-5a6df06494f9ba6df53af82cfdf81f1d3708edc3.tar.gz emacs-5a6df06494f9ba6df53af82cfdf81f1d3708edc3.zip | |
Simplify ignored extensions filtering in Icomplete (bug#34070)
* lisp/icomplete.el: Use lexical binding.
(icomplete-completions): Use minibuffer-completion-predicate
to filter out completion-ignored-extensions.
| -rw-r--r-- | lisp/icomplete.el | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/lisp/icomplete.el b/lisp/icomplete.el index 8bed46cb3b3..6d77c0649ae 100644 --- a/lisp/icomplete.el +++ b/lisp/icomplete.el | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | ;;; icomplete.el --- minibuffer completion incremental feedback | 1 | ;;; icomplete.el --- minibuffer completion incremental feedback -*- lexical-binding: t -*- |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 1992-1994, 1997, 1999, 2001-2019 Free Software | 3 | ;; Copyright (C) 1992-1994, 1997, 1999, 2001-2019 Free Software |
| 4 | ;; Foundation, Inc. | 4 | ;; Foundation, Inc. |
| @@ -368,8 +368,21 @@ If there are multiple possibilities, `icomplete-separator' separates them. | |||
| 368 | The displays for unambiguous matches have ` [Matched]' appended | 368 | The displays for unambiguous matches have ` [Matched]' appended |
| 369 | \(whether complete or not), or ` [No matches]', if no eligible | 369 | \(whether complete or not), or ` [No matches]', if no eligible |
| 370 | matches exist." | 370 | matches exist." |
| 371 | (let* ((minibuffer-completion-table candidates) | 371 | (let* ((ignored-extension-re |
| 372 | (minibuffer-completion-predicate predicate) | 372 | (and minibuffer-completing-file-name |
| 373 | icomplete-with-completion-tables | ||
| 374 | completion-ignored-extensions | ||
| 375 | (concat "\\(?:\\`\\.\\./\\|" | ||
| 376 | (regexp-opt completion-ignored-extensions) | ||
| 377 | "\\)\\'"))) | ||
| 378 | (minibuffer-completion-table candidates) | ||
| 379 | (minibuffer-completion-predicate | ||
| 380 | (if ignored-extension-re | ||
| 381 | (lambda (cand) | ||
| 382 | (and (not (string-match ignored-extension-re cand)) | ||
| 383 | (or (null predicate) | ||
| 384 | (funcall predicate cand)))) | ||
| 385 | predicate)) | ||
| 373 | (md (completion--field-metadata (icomplete--field-beg))) | 386 | (md (completion--field-metadata (icomplete--field-beg))) |
| 374 | (comps (completion-all-sorted-completions | 387 | (comps (completion-all-sorted-completions |
| 375 | (icomplete--field-beg) (icomplete--field-end))) | 388 | (icomplete--field-beg) (icomplete--field-end))) |
| @@ -380,11 +393,8 @@ matches exist." | |||
| 380 | ;; `concat'/`mapconcat' is the slow part. | 393 | ;; `concat'/`mapconcat' is the slow part. |
| 381 | (if (not (consp comps)) | 394 | (if (not (consp comps)) |
| 382 | (progn ;;(debug (format "Candidates=%S field=%S" candidates name)) | 395 | (progn ;;(debug (format "Candidates=%S field=%S" candidates name)) |
| 383 | (format " %sNo matches%s" open-bracket close-bracket)) | 396 | (format " %sNo matches%s" open-bracket close-bracket)) |
| 384 | (if last (setcdr last nil)) | 397 | (if last (setcdr last nil)) |
| 385 | (when (and minibuffer-completing-file-name | ||
| 386 | icomplete-with-completion-tables) | ||
| 387 | (setq comps (completion-pcm--filename-try-filter comps))) | ||
| 388 | (let* ((most-try | 398 | (let* ((most-try |
| 389 | (if (and base-size (> base-size 0)) | 399 | (if (and base-size (> base-size 0)) |
| 390 | (completion-try-completion | 400 | (completion-try-completion |
| @@ -470,11 +480,11 @@ matches exist." | |||
| 470 | (if prefix-len (substring (car comps) prefix-len) (car comps)) | 480 | (if prefix-len (substring (car comps) prefix-len) (car comps)) |
| 471 | comps (cdr comps)) | 481 | comps (cdr comps)) |
| 472 | (setq prospects-len | 482 | (setq prospects-len |
| 473 | (+ (string-width comp) | 483 | (+ (string-width comp) |
| 474 | (string-width icomplete-separator) | 484 | (string-width icomplete-separator) |
| 475 | prospects-len)) | 485 | prospects-len)) |
| 476 | (if (< prospects-len prospects-max) | 486 | (if (< prospects-len prospects-max) |
| 477 | (push comp prospects) | 487 | (push comp prospects) |
| 478 | (setq limit t)))) | 488 | (setq limit t)))) |
| 479 | (setq prospects (nreverse prospects)) | 489 | (setq prospects (nreverse prospects)) |
| 480 | ;; Decorate first of the prospects. | 490 | ;; Decorate first of the prospects. |