all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: npostavs@users.sourceforge.net
To: Ryan <rct@thompsonclan.org>
Cc: 27841@debbugs.gnu.org
Subject: bug#27841: 25.2; Patch for completion-table-with-predicate
Date: Fri, 04 Aug 2017 18:55:05 -0400	[thread overview]
Message-ID: <87mv7f6j06.fsf@users.sourceforge.net> (raw)
In-Reply-To: <c508b4c2-0b15-e1eb-fd87-4c8842d01dd1@thompsonclan.org> (Ryan's message of "Wed, 26 Jul 2017 11:36:47 -0700")

[-- Attachment #1: Type: text/plain, Size: 511 bytes --]

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.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch --]
[-- Type: text/x-diff, Size: 1009 bytes --]

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


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: patch --]
[-- Type: text/x-diff, Size: 913 bytes --]

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	other threads:[~2017-08-04 22:55 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-26 18:36 bug#27841: 25.2; Patch for completion-table-with-predicate Ryan
2017-08-04 22:55 ` npostavs [this message]
2017-08-04 23:00   ` Ryan Thompson
2017-08-04 23:10     ` npostavs
2017-08-04 23:11     ` Dmitry Gutov
2017-08-05  6:22       ` Ryan Thompson
2017-08-08  1:27         ` npostavs
2017-11-08  2:30           ` Noam Postavsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87mv7f6j06.fsf@users.sourceforge.net \
    --to=npostavs@users.sourceforge.net \
    --cc=27841@debbugs.gnu.org \
    --cc=rct@thompsonclan.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.