Function: completion-table-with-predicate
completion-table-with-predicate is a byte-compiled function defined in
minibuffer.el.gz.
Signature
(completion-table-with-predicate TABLE PRED1 STRICT STRING PRED2 ACTION)
Documentation
Make a completion table equivalent to TABLE but filtered through PRED1.
PRED1 is a function of one argument which returns non-nil if and
only if the argument is an element of TABLE which should be
considered for completion. STRING, PRED2, and ACTION are the
usual arguments to completion tables, as described in
try-completion, all-completions, and test-completion. If
STRICT is non-nil, the predicate always applies; if nil it only
applies if it does not reduce the set of possible completions to
nothing. Note: TABLE needs to be a proper completion table which
obeys predicates.
Source Code
;; Defined in /usr/src/emacs/lisp/minibuffer.el.gz
(defun completion-table-with-predicate (table pred1 strict string pred2 action)
"Make a completion table equivalent to TABLE but filtered through PRED1.
PRED1 is a function of one argument which returns non-nil if and
only if the argument is an element of TABLE which should be
considered for completion. STRING, PRED2, and ACTION are the
usual arguments to completion tables, as described in
`try-completion', `all-completions', and `test-completion'. If
STRICT is non-nil, the predicate always applies; if nil it only
applies if it does not reduce the set of possible completions to
nothing. Note: TABLE needs to be a proper completion table which
obeys predicates."
(cond
((and (not strict) (eq action 'lambda))
;; Ignore pred1 since it doesn't really have to apply anyway.
(test-completion string table pred2))
(t
(or (complete-with-action action table string
(if (not (and pred1 pred2))
(or pred1 pred2)
(lambda (x)
;; Call `pred1' first, so that `pred2'
;; really can't tell that `x' is in table.
(and (funcall pred1 x) (funcall pred2 x)))))
;; If completion failed and we're not applying pred1 strictly, try
;; again without pred1.
(and (not strict) pred1
(complete-with-action action table string pred2))))))