bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#27841: 25.2; Patch for completion-table-with-predicate


From: npostavs
Subject: bug#27841: 25.2; Patch for completion-table-with-predicate
Date: Fri, 04 Aug 2017 18:55:05 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2.50 (gnu/linux)

tags 27841 + patch
quit

Ryan <rct@thompsonclan.org> writes:

> When the pred2 arg to completion-table-with-predicate is nil, it acts
> like strict is non-nil, even if it isn't. I'm attaching a patch
> (created with "git format-patch") that
> fixes the bug.

Looks reasonable, though I'm not very familiar with this code.  The
commit messages should be reformatted into ChangeLog format, and the
first one would be better rephrased into present tense.  I'm reattaching
the patches inline here for convenience.

>From e531f97247bc7f28d20cd9d4f468aa062924e117 Mon Sep 17 00:00:00 2001
From: "Ryan C. Thompson" <rct@thompsonclan.org>
Date: Wed, 26 Jul 2017 11:09:42 -0700
Subject: [PATCH 1/2] Fix a bug in completion-table-with-predicate

If strict was nil and pred2 was nil, then it acted like strict was
non-nil.
---
 lisp/minibuffer.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index e5b1029c01..bb8cf21ad2 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -392,7 +392,7 @@ (defun completion-table-with-predicate (table pred1 strict 
string pred2 action)
                                   (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)
-- 
2.11.1

>From 422c87af1dafd57f4e8c97a70b2104a76c77d104 Mon Sep 17 00:00:00 2001
From: "Ryan C. Thompson" <rct@thompsonclan.org>
Date: Wed, 26 Jul 2017 11:14:13 -0700
Subject: [PATCH 2/2] Optimize completion-table-with-predicate for pred1 = nil

---
 lisp/minibuffer.el | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index bb8cf21ad2..3a79016d13 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -379,6 +379,9 @@ (defun completion-table-with-predicate (table pred1 strict 
string pred2 action)
 nothing.  Note: TABLE needs to be a proper completion table which
 obeys predicates."
   (cond
+   ;; If pred1 is nil, pass through
+   ((null pred1)
+    (complete-with-action action table string pred2))
    ((and (not strict) (eq action 'lambda))
     ;; Ignore pred1 since it doesn't really have to apply anyway.
     (test-completion string table pred2))
-- 
2.11.1


reply via email to

[Prev in Thread] Current Thread [Next in Thread]