From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: npostavs@users.sourceforge.net Newsgroups: gmane.emacs.bugs Subject: bug#27841: 25.2; Patch for completion-table-with-predicate Date: Fri, 04 Aug 2017 18:55:05 -0400 Message-ID: <87mv7f6j06.fsf@users.sourceforge.net> References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1501887253 21877 195.159.176.226 (4 Aug 2017 22:54:13 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 4 Aug 2017 22:54:13 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2.50 (gnu/linux) Cc: 27841@debbugs.gnu.org To: Ryan Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Aug 05 00:54:09 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ddlTr-0005OO-GU for geb-bug-gnu-emacs@m.gmane.org; Sat, 05 Aug 2017 00:54:07 +0200 Original-Received: from localhost ([::1]:54629 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ddlTx-0007fG-Qp for geb-bug-gnu-emacs@m.gmane.org; Fri, 04 Aug 2017 18:54:13 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44861) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ddlTq-0007e3-7K for bug-gnu-emacs@gnu.org; Fri, 04 Aug 2017 18:54:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ddlTm-0002k9-92 for bug-gnu-emacs@gnu.org; Fri, 04 Aug 2017 18:54:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:39453) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ddlTm-0002ju-2p for bug-gnu-emacs@gnu.org; Fri, 04 Aug 2017 18:54:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ddlTl-0000Qt-Rf for bug-gnu-emacs@gnu.org; Fri, 04 Aug 2017 18:54:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: npostavs@users.sourceforge.net Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 04 Aug 2017 22:54:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 27841 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 27841-submit@debbugs.gnu.org id=B27841.15018872121625 (code B ref 27841); Fri, 04 Aug 2017 22:54:01 +0000 Original-Received: (at 27841) by debbugs.gnu.org; 4 Aug 2017 22:53:32 +0000 Original-Received: from localhost ([127.0.0.1]:42130 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ddlTH-0000Q4-U5 for submit@debbugs.gnu.org; Fri, 04 Aug 2017 18:53:32 -0400 Original-Received: from mail-io0-f180.google.com ([209.85.223.180]:34422) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ddlTG-0000Pm-Hk; Fri, 04 Aug 2017 18:53:30 -0400 Original-Received: by mail-io0-f180.google.com with SMTP id o9so10830323iod.1; Fri, 04 Aug 2017 15:53:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=UqMekUEIubEUZL92XHM5ihNPHyk4qBEsbMyZA5uhRlE=; b=CD7Z/u5BjzYTYAU7af/InPeFWo79xbjBstiCa8Ii6A2/kkGYhMvLPTHLZj3OPYxoNL +PtpfJwoQGALmY83QivZdoXSbhvTM+GVoJeChjUFV6ECVsOSu1Xa3sU4yZNCvQd6LM8m IDOVXQECD2IE2RiZL883Y+nzPfn1pbuq4sWXR9qa/S54qSanpIjupO46lbm0sgkKAkjR ur+E4eABYVVI9qL3BCOhKiAnUgrZcujvDIbdGZB0JJLmgDEuyHaTVBFCsgOyj2IEBYH8 P/vOdd6W/SZkm8bOHP6KBfk/gTiKMrBsXIrh17nNma4LLlFaQjx13wpocLWp0XDYGlVB UEhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:references:date :in-reply-to:message-id:user-agent:mime-version; bh=UqMekUEIubEUZL92XHM5ihNPHyk4qBEsbMyZA5uhRlE=; b=FmoNBRdwYSfRPofdHDb8zyzIIHhU7cE9hXPNpz/BKgTtLReNVkc9yxYX+mOUFoztID S3hZw4gLdMlUqhHRoG2RD4spl4MqpxQtI4HEPMec2lquXIC+C1SfucvJbl2CdHY3/NWK xcPiTnvhTR1wh8mfz4m3yr63c5xGLV9kSWkotJoEcFPFDOF8cJYuDa/9X9x7tOo1I4+Y w9OWyUk5Fy/4OBfMr0dDzke+qOjnr3MSJHkKzmfEqN2avXBMIBgv49gkoYDktGR0ZAxL pGmekLapoAP6co0kH6NJCKt5/3FH+/0gWrA9Q3WGaLReH1bS9zdnJnsSfbXGSzaLnoXZ FAuw== X-Gm-Message-State: AHYfb5hMsKRM5HNI4c7oIO4DxaEpD2wjF6vuM7IOozUg+NIAG81BN+PS Kk83YllrkV4cQGCu X-Received: by 10.107.12.70 with SMTP id w67mr4567146ioi.295.1501887204682; Fri, 04 Aug 2017 15:53:24 -0700 (PDT) Original-Received: from zony ([45.2.119.48]) by smtp.googlemail.com with ESMTPSA id y28sm855804ita.2.2017.08.04.15.53.23 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 04 Aug 2017 15:53:23 -0700 (PDT) In-Reply-To: (Ryan's message of "Wed, 26 Jul 2017 11:36:47 -0700") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:135365 Archived-At: --=-=-= Content-Type: text/plain tags 27841 + patch quit Ryan 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. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Fix-a-bug-in-completion-table-with-predicate.patch Content-Description: patch >From e531f97247bc7f28d20cd9d4f468aa062924e117 Mon Sep 17 00:00:00 2001 From: "Ryan C. Thompson" 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 --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0002-Optimize-completion-table-with-predicate-for-pred1-n.patch Content-Description: patch >From 422c87af1dafd57f4e8c97a70b2104a76c77d104 Mon Sep 17 00:00:00 2001 From: "Ryan C. Thompson" 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 --=-=-=--