summaryrefslogtreecommitdiff
path: root/lisp/icomplete.el
diff options
context:
space:
mode:
authorJoão Távora <joaotavora@gmail.com>2019-01-15 12:10:23 +0000
committerJoão Távora <joaotavora@gmail.com>2019-01-17 15:17:02 +0000
commit5a6df06494f9ba6df53af82cfdf81f1d3708edc3 (patch)
treef48bf19352af749fe72b082f06603e85557ffdcd /lisp/icomplete.el
parent7560ef7de925b56f367df168befc9b748b6237c1 (diff)
downloademacs-5a6df06494f9ba6df53af82cfdf81f1d3708edc3.tar.gz
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.
Diffstat (limited to 'lisp/icomplete.el')
-rw-r--r--lisp/icomplete.el34
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 @@
-;;; icomplete.el --- minibuffer completion incremental feedback
+;;; icomplete.el --- minibuffer completion incremental feedback -*- lexical-binding: t -*-
;; Copyright (C) 1992-1994, 1997, 1999, 2001-2019 Free Software
;; Foundation, Inc.
@@ -368,8 +368,21 @@ If there are multiple possibilities, `icomplete-separator' separates them.
The displays for unambiguous matches have ` [Matched]' appended
\(whether complete or not), or ` [No matches]', if no eligible
matches exist."
- (let* ((minibuffer-completion-table candidates)
- (minibuffer-completion-predicate predicate)
+ (let* ((ignored-extension-re
+ (and minibuffer-completing-file-name
+ icomplete-with-completion-tables
+ completion-ignored-extensions
+ (concat "\\(?:\\`\\.\\./\\|"
+ (regexp-opt completion-ignored-extensions)
+ "\\)\\'")))
+ (minibuffer-completion-table candidates)
+ (minibuffer-completion-predicate
+ (if ignored-extension-re
+ (lambda (cand)
+ (and (not (string-match ignored-extension-re cand))
+ (or (null predicate)
+ (funcall predicate cand))))
+ predicate))
(md (completion--field-metadata (icomplete--field-beg)))
(comps (completion-all-sorted-completions
(icomplete--field-beg) (icomplete--field-end)))
@@ -380,11 +393,8 @@ matches exist."
;; `concat'/`mapconcat' is the slow part.
(if (not (consp comps))
(progn ;;(debug (format "Candidates=%S field=%S" candidates name))
- (format " %sNo matches%s" open-bracket close-bracket))
+ (format " %sNo matches%s" open-bracket close-bracket))
(if last (setcdr last nil))
- (when (and minibuffer-completing-file-name
- icomplete-with-completion-tables)
- (setq comps (completion-pcm--filename-try-filter comps)))
(let* ((most-try
(if (and base-size (> base-size 0))
(completion-try-completion
@@ -470,11 +480,11 @@ matches exist."
(if prefix-len (substring (car comps) prefix-len) (car comps))
comps (cdr comps))
(setq prospects-len
- (+ (string-width comp)
- (string-width icomplete-separator)
- prospects-len))
- (if (< prospects-len prospects-max)
- (push comp prospects)
+ (+ (string-width comp)
+ (string-width icomplete-separator)
+ prospects-len))
+ (if (< prospects-len prospects-max)
+ (push comp prospects)
(setq limit t))))
(setq prospects (nreverse prospects))
;; Decorate first of the prospects.