(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 pred2
+ (and (not strict) pred1
(complete-with-action action table string pred2))))))
(defun completion-table-in-turn (&rest tables)
(should (equal (buffer-string)
"test: "))))))
+(ert-deftest completion-table-with-predicate-test ()
+ (let ((full-collection
+ '("apple" ; Has A.
+ "beet" ; Has B.
+ "banana" ; Has A & B.
+ "cherry" ; Has neither.
+ ))
+ (no-A (lambda (x) (not (string-match-p "a" x))))
+ (no-B (lambda (x) (not (string-match-p "b" x)))))
+ (should
+ (member "cherry"
+ (completion-table-with-predicate
+ full-collection no-A t "" no-B t)))
+ (should-not
+ (member "banana"
+ (completion-table-with-predicate
+ full-collection no-A t "" no-B t)))
+ ;; "apple" should still match when strict is nil.
+ (should (eq t (try-completion
+ "apple"
+ (apply-partially
+ 'completion-table-with-predicate
+ full-collection no-A nil)
+ no-B)))
+ ;; "apple" should still match when strict is nil and pred2 is nil
+ ;; (Bug#27841).
+ (should (eq t (try-completion
+ "apple"
+ (apply-partially
+ 'completion-table-with-predicate
+ full-collection no-A nil))))))
+
(provide 'completion-tests)
;;; completion-tests.el ends here