From unknown Sat Jun 21 10:37:49 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#24966 <24966@debbugs.gnu.org> To: bug#24966 <24966@debbugs.gnu.org> Subject: Status: 26.0.50; test-completion with alist COLLECTION calls PREDICATE incorrectly Reply-To: bug#24966 <24966@debbugs.gnu.org> Date: Sat, 21 Jun 2025 17:37:49 +0000 retitle 24966 26.0.50; test-completion with alist COLLECTION calls PREDICAT= E incorrectly reassign 24966 emacs submitter 24966 Mark Oteiza severity 24966 normal tag 24966 confirmed fixed patch thanks From debbugs-submit-bounces@debbugs.gnu.org Sat Nov 19 05:26:45 2016 Received: (at submit) by debbugs.gnu.org; 19 Nov 2016 10:26:45 +0000 Received: from localhost ([127.0.0.1]:34463 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c82r6-0003mt-RW for submit@debbugs.gnu.org; Sat, 19 Nov 2016 05:26:45 -0500 Received: from eggs.gnu.org ([208.118.235.92]:38833) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c82r5-0003mf-B3 for submit@debbugs.gnu.org; Sat, 19 Nov 2016 05:26:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c82qy-0000Ah-E3 for submit@debbugs.gnu.org; Sat, 19 Nov 2016 05:26:38 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:57117) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1c82qy-0000AT-8l for submit@debbugs.gnu.org; Sat, 19 Nov 2016 05:26:36 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57915) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c82qw-0002TZ-D7 for bug-gnu-emacs@gnu.org; Sat, 19 Nov 2016 05:26:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c82qr-00005Q-EN for bug-gnu-emacs@gnu.org; Sat, 19 Nov 2016 05:26:34 -0500 Received: from mail-qt0-x235.google.com ([2607:f8b0:400d:c0d::235]:33115) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1c82qr-00004t-6s for bug-gnu-emacs@gnu.org; Sat, 19 Nov 2016 05:26:29 -0500 Received: by mail-qt0-x235.google.com with SMTP id p16so176274830qta.0 for ; Sat, 19 Nov 2016 02:26:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=udel-edu.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=2kY74kSe4lHB8FOJbmXQc+YbTQyyHdhcY0W0gPk99gI=; b=EylqbhQYcO+EFaMf9OJKd1d39ZgTnnOFvWjLgZDxmMAuMlVvF72FCeg0TgtTD9Y7MM 8KGTZYqHDY0JES6iFV+tgT+uQTBVGU2BTaP71bhRHdqwzMtA95wyUMhqh4oCROrm6Orf pRiHPJvXoZZrbHKj9Neh/Fm6oU7Nb4vYq6fdNSc3tIJo0B37RyzkifWWAH5t9ldCTiY5 BAdOrRlddeNkVpXGE1NdhYOio8wNxGBozBuJocErch2RoJ/WhHZH+bvxYwEuuon7QGCy 8HtkNbbC2e6K6SXpE8wOHq6XEIHAACS64UnVmBW3kRMfLW8yIkIMU1tERbekPn3v6qKb enAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=2kY74kSe4lHB8FOJbmXQc+YbTQyyHdhcY0W0gPk99gI=; b=cUWVMg/h+CNsmdgH320P0I0PHrAFH4kjRjqVcUhctW+49GLY9c6cEv2bdtrl4rEa/V kvz628ocPUnLsWpo8EPT1mrLdvPxPcN2ADk1zJX6imX3GdZQJj1TRqKaVCAxS5pl1veL EIWeV5WifoxulLE2ezICD8PT9yLMSb7t5jTi0oG31bBHF27xPlFPtWVATVzONO2u8kz4 rC1p8ph9kXBEEhcu8a6hXJJJNOH9nDHJVu3uk7qeV9AGcCwdDLLtIdgqpcWDWPaBL0a1 yYJrmom6cDf0ah8C7zNT3W7BtE1pjSv52NQef1S19txfKQnmoMuthsBtqu8hyQGIK6E3 cUdw== X-Gm-Message-State: AKaTC02m+gVPqHnRyIPcJDOEoRwisBYTF5vTqrknO7ua0ALpLznuTSE2FV+Fex6O3+jM1MHm X-Received: by 10.200.34.207 with SMTP id g15mr2883913qta.17.1479551187478; Sat, 19 Nov 2016 02:26:27 -0800 (PST) Received: from holos.localdomain ([69.250.222.218]) by smtp.gmail.com with ESMTPSA id 96sm6169579qkz.40.2016.11.19.02.26.26 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 19 Nov 2016 02:26:26 -0800 (PST) Received: by holos.localdomain (Postfix, from userid 1000) id EDA9066151; Sat, 19 Nov 2016 05:26:25 -0500 (EST) From: Mark Oteiza To: bug-gnu-emacs@gnu.org Subject: 26.0.50; Date: Sat, 19 Nov 2016 05:26:25 -0500 Message-ID: <87shqnpxym.fsf@udel.edu> MIME-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.4 (----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.4 (----) Hi, dd98ee8992c3246861e44 appears to be the culprit for breaking the following from -Q: 1. C-x C-f /tmp/foo.tex 2. M-x reftex-mode 3. Insert the following: \label{foobar} 4. M-x reftex-goto-label and, when attempting to complete, a wrong-type-argument error occurs. Debugger entered--Lisp error: (wrong-type-argument listp "argh") #[(x) "@;\207" [x] 1]("argh") test-completion("argh" ((xr nil "\\\\\\\\\\\\") (index-tags) (is-multi ni= l) (bibview-cache) (master-dir . "/tmp/") (label-numbers) (bof "/tmp/lol.te= x") ("argh" "s" " " "/tmp/lol.tex" nil) (eof "/tmp/lol.tex")) #[(x) "@;\20= 7" [x] 1]) completion--do-completion(8 8) completion--in-region-1(8 8) #[1028 "=01=19\n\203!\304!\203=00\202=00\305!\305\306\"=03F\307\310!\210\= 311=04\"*\207" [minibuffer-completion-predicate minibuffer-completion-table= completion-in-region-mode-predicate completion-in-region--data markerp cop= y-marker t completion-in-region-mode 1 completion--in-region-1] 8 "\n\n(fn = START END COLLECTION PREDICATE)"](8 8 ((xr nil "\\\\\\\\\\\\") (index-tags)= (is-multi nil) (bibview-cache) (master-dir . "/tmp/") (label-numbers) (bof= "/tmp/lol.tex") ("argh" "s" " " "/tmp/lol.tex" nil) (eof "/tmp/lol.tex")) = #[(x) "@;\207" [x] 1]) apply(#[1028 "=01=19\n\203!\304!\203=00\202=00\305!\305\306\"=03F\307\310= !\210\311=04\"*\207" [minibuffer-completion-predicate minibuffer-completion= -table completion-in-region-mode-predicate completion-in-region--data marke= rp copy-marker t completion-in-region-mode 1 completion--in-region-1] 8 "\n= \n(fn START END COLLECTION PREDICATE)"] (8 8 ((xr nil "\\\\\\\\\\\\") (inde= x-tags) (is-multi nil) (bibview-cache) (master-dir . "/tmp/") (label-number= s) (bof "/tmp/lol.tex") ("argh" "s" " " "/tmp/lol.tex" nil) (eof "/tmp/lol.= tex")) #[(x) "@;\207" [x] 1])) #[771 ":\2030=02@\301=3D\203=00\300\242\302=05A\"\303#\207\304@\305\306\3= 07\310\311\312\300!\313\"\314\315%=06A=06##\207\304\316\"\207" [(#0) t appe= nd nil apply apply-partially make-byte-code 642 "\300\242=03#\207" vconcat = vector [] 7 "\n\n(fn FUNS GLOBAL &rest ARGS)" #[1028 "=01=19\n\203!\304!\20= 3=00\202=00\305!\305\306\"=03F\307\310!\210\311=04\"*\207" [minibuffer-comp= letion-predicate minibuffer-completion-table completion-in-region-mode-pred= icate completion-in-region--data markerp copy-marker t completion-in-region= -mode 1 completion--in-region-1] 8 "\n\n(fn START END COLLECTION PREDICATE)= "]] 12 "\n\n(fn FUNS GLOBAL ARGS)"](nil nil (8 8 ((xr nil "\\\\\\\\\\\\") (= index-tags) (is-multi nil) (bibview-cache) (master-dir . "/tmp/") (label-nu= mbers) (bof "/tmp/lol.tex") ("argh" "s" " " "/tmp/lol.tex" nil) (eof "/tmp/= lol.tex")) #[(x) "@;\207" [x] 1])) completion--in-region(8 8 ((xr nil "\\\\\\\\\\\\") (index-tags) (is-multi= nil) (bibview-cache) (master-dir . "/tmp/") (label-numbers) (bof "/tmp/lol= .tex") ("argh" "s" " " "/tmp/lol.tex" nil) (eof "/tmp/lol.tex")) #[(x) "@;= \207" [x] 1]) completion-in-region(8 8 ((xr nil "\\\\\\\\\\\\") (index-tags) (is-multi = nil) (bibview-cache) (master-dir . "/tmp/") (label-numbers) (bof "/tmp/lol.= tex") ("argh" "s" " " "/tmp/lol.tex" nil) (eof "/tmp/lol.tex")) #[(x) "@;\= 207" [x] 1]) minibuffer-complete() funcall-interactively(minibuffer-complete) call-interactively(minibuffer-complete nil nil) command-execute(minibuffer-complete) read-from-minibuffer("Label: " nil (keymap (10 . minibuffer-complete-and-= exit) (13 . minibuffer-complete-and-exit) keymap (menu-bar keymap (minibuf = "Minibuf" keymap (tab menu-item "Complete" minibuffer-complete :help "Compl= ete as far as possible") (space menu-item "Complete Word" minibuffer-comple= te-word :help "Complete at most one word") (63 menu-item "List Completions"= minibuffer-completion-help :help "Display all possible completions") "Mini= buf")) (27 keymap (118 . switch-to-completions)) (prior . switch-to-complet= ions) (63 . minibuffer-completion-help) (32 . minibuffer-complete-word) (9 = . minibuffer-complete) keymap (menu-bar keymap (minibuf "Minibuf" keymap (p= revious menu-item "Previous History Item" previous-history-element :help "P= ut previous minibuffer history element in the minibuffer") (next menu-item = "Next History Item" next-history-element :help "Put next minibuffer history= element in the minibuffer") (isearch-backward menu-item "Isearch History B= ackward" isearch-backward :help "Incrementally search minibuffer history ba= ckward") (isearch-forward menu-item "Isearch History Forward" isearch-forwa= rd :help "Incrementally search minibuffer history forward") (return menu-it= em "Enter" exit-minibuffer :key-sequence "" :help "Terminate input and exit= minibuffer") (quit menu-item "Quit" abort-recursive-edit :help "Abort inpu= t and exit minibuffer") "Minibuf")) (10 . exit-minibuffer) (13 . exit-minib= uffer) (7 . abort-recursive-edit) (C-tab . file-cache-minibuffer-complete) = (9 . self-insert-command) (XF86Back . previous-history-element) (up . previ= ous-line-or-history-element) (prior . previous-history-element) (XF86Forwar= d . next-history-element) (down . next-line-or-history-element) (next . nex= t-history-element) (27 keymap (114 . previous-matching-history-element) (11= 5 . next-matching-history-element) (112 . previous-history-element) (110 . = next-history-element))) nil nil nil nil) completing-read-default("Label: " ((xr nil "\\\\\\\\\\\\") (index-tags) (= is-multi nil) (bibview-cache) (master-dir . "/tmp/") (label-numbers) (bof "= /tmp/lol.tex") ("argh" "s" " " "/tmp/lol.tex" nil) (eof "/tmp/lol.tex")) #[= (x) "@;\207" [x] 1] t nil nil nil nil) completing-read("Label: " ((xr nil "\\\\\\\\\\\\") (index-tags) (is-multi= nil) (bibview-cache) (master-dir . "/tmp/") (label-numbers) (bof "/tmp/lol= .tex") ("argh" "s" " " "/tmp/lol.tex" nil) (eof "/tmp/lol.tex")) #[(x) "@;= \207" [x] 1] t nil nil nil) reftex-goto-label(nil) funcall-interactively(reftex-goto-label nil) call-interactively(reftex-goto-label record nil) command-execute(reftex-goto-label record) execute-extended-command(nil "reftex-goto-label" nil) funcall-interactively(execute-extended-command nil "reftex-goto-label" ni= l) call-interactively(execute-extended-command nil nil) command-execute(execute-extended-command) In GNU Emacs 26.0.50.2 (x86_64-unknown-linux-gnu, X toolkit, Xaw scroll bar= s) of 2016-11-18 built on logos Repository revision: 6cdd1c333034b308e74e70c4fd10399fbb5329b9 From debbugs-submit-bounces@debbugs.gnu.org Sun Nov 20 23:23:36 2016 Received: (at 24966) by debbugs.gnu.org; 21 Nov 2016 04:23:36 +0000 Received: from localhost ([127.0.0.1]:36577 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c8g8m-0002ek-Bi for submit@debbugs.gnu.org; Sun, 20 Nov 2016 23:23:36 -0500 Received: from mail-io0-f176.google.com ([209.85.223.176]:35733) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c8g8k-0002eN-ST; Sun, 20 Nov 2016 23:23:35 -0500 Received: by mail-io0-f176.google.com with SMTP id n13so30591488ioe.2; Sun, 20 Nov 2016 20:23:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=5cqR65E6h35csSuCgvc2q7AEE1s/Xb8DcctlG1hoDoM=; b=BoPCW+G1F4c8+IOsLAAFw+/Nb+9Rjfm6lN0qYNHGha32aG6du8eut2QoeWnDN+K42A 0KKgYY34PkVCxEy+ED5FRlTJ3ciKFQW//gNu4ZM7cOi62I1NIfdgYcIWFCWiZMTk3k4y P7zyGWN33QqDj3urdMWS7MKpPclPS5hj+0DcaooQT1eI2T72kWgLKrY5A0f/gD1jE8vG ty1PCUzD3IhV5veOFbD/DsqX44i/kqTKILvKEwrzB7RcQHQkfOUubQkOv4Kti/UzpZT/ tN+FPVyTr0w+ov8Vw+6812lEdGrgKNPBzJz2C5Hu48dng/2/E2J5z2vG16M43s+iIr9R sF1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:references:date :in-reply-to:message-id:user-agent:mime-version; bh=5cqR65E6h35csSuCgvc2q7AEE1s/Xb8DcctlG1hoDoM=; b=KLq1XAW3F4ZA0VEGjFwvnvu9hos//SnFzbOyn3t30Xm2yr1O9MHwahfpejYuhoqF4u jV5f73d1oXRvJKDPZtokLJNkDgvUKuqfBFl+sR3D/JH5CA4YYivkfAVdN+FIWGr+tr39 587LxsOqnXD8nWS5VDM7dLDEcgtu37eBw/9N0hJlH8e4QPZ9EmBS9HL5/YpVJFEQwzh0 uSRsHK8DouB+tZNr2pe/uldFK4fcxtIR+TeIaSGD9BbCxcdOfQiMt8IBjpN8p3ePVaQq FQIsfIORYDYdaCv9lmoMX0yCuD/BttTJZ8p9RDy46wdsgft0mzNfjhbUaSHOHQvzGiwu Qw2Q== X-Gm-Message-State: AKaTC035Er3AarucpdkkqO+3/+K+20s9JDtLYAmsc0xnzPTcOC/juwyN7EjGSeU1cU/18Q== X-Received: by 10.107.190.6 with SMTP id o6mr9371412iof.95.1479702209103; Sun, 20 Nov 2016 20:23:29 -0800 (PST) Received: from zony ([45.2.7.65]) by smtp.googlemail.com with ESMTPSA id x190sm5479557ite.14.2016.11.20.20.23.27 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 20 Nov 2016 20:23:27 -0800 (PST) From: npostavs@users.sourceforge.net To: Mark Oteiza Subject: Re: bug#24966: 26.0.50; References: <87shqnpxym.fsf@udel.edu> Date: Sun, 20 Nov 2016 23:24:19 -0500 In-Reply-To: <87shqnpxym.fsf@udel.edu> (Mark Oteiza's message of "Sat, 19 Nov 2016 05:26:25 -0500") Message-ID: <87fumljw98.fsf@users.sourceforge.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.5 (/) X-Debbugs-Envelope-To: 24966 Cc: 24966@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.5 (/) unarchive 23533 # It was marked for 25.2 before master was renumbered to 26 notfixed 23533 25.2 fixed 23533 26.0.50 retitle 24966 26.0.50; test-completion with alist COLLECTION calls PREDICATE incorrectly tags 24966 confirmed quit Mark Oteiza writes: > Hi, > > dd98ee8992c3246861e44 appears to be the culprit for breaking the > following from -Q: Yup, I didn't fix test-completion correctly. > > 1. C-x C-f /tmp/foo.tex > 2. M-x reftex-mode > 3. Insert the following: \label{foobar} > 4. M-x reftex-goto-label > > and, when attempting to complete, a wrong-type-argument error occurs. > > Debugger entered--Lisp error: (wrong-type-argument listp "argh") > #[(x) "@;\207" [x] 1]("argh") > test-completion("argh" ((xr nil "\\\\\\\\\\\\") (index-tags) (is-multi nil) (bibview-cache) (master-dir . "/tmp/") (label-numbers) (bof "/tmp/lol.tex") ("argh" "s" " " "/tmp/lol.tex" nil) (eof "/tmp/lol.tex")) #[(x) "@;\207" [x] 1]) I tentatively suggest the patch below, but I want to add some tests before commiting anything. diff --git i/src/minibuf.c w/src/minibuf.c index 57eea05..fe187b3 100644 --- i/src/minibuf.c +++ w/src/minibuf.c @@ -1686,8 +1686,6 @@ DEFUN ("test-completion", Ftest_completion, Stest_completion, 2, 3, 0, tem = Fassoc_string (string, collection, completion_ignore_case ? Qt : Qnil); if (NILP (tem)) return Qnil; - else if (CONSP (tem)) - tem = XCAR (tem); } else if (VECTORP (collection)) { @@ -1765,14 +1763,16 @@ DEFUN ("test-completion", Ftest_completion, Stest_completion, 2, 3, 0, /* Reject this element if it fails to match all the regexps. */ if (CONSP (Vcompletion_regexp_list)) { + Lisp_Object temstr = (CONSP (tem)) ? XCAR (tem) : tem; + if (SYMBOLP (temstr)) + temstr = string; + ptrdiff_t count = SPECPDL_INDEX (); specbind (Qcase_fold_search, completion_ignore_case ? Qt : Qnil); for (regexps = Vcompletion_regexp_list; CONSP (regexps); regexps = XCDR (regexps)) { - if (NILP (Fstring_match (XCAR (regexps), - SYMBOLP (tem) ? string : tem, - Qnil))) + if (NILP (Fstring_match (XCAR (regexps), temstr, Qnil))) return unbind_to (count, Qnil); } unbind_to (count, Qnil); From debbugs-submit-bounces@debbugs.gnu.org Mon Nov 21 14:42:36 2016 Received: (at 24966) by debbugs.gnu.org; 21 Nov 2016 19:42:36 +0000 Received: from localhost ([127.0.0.1]:37395 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c8uU7-0004JB-TK for submit@debbugs.gnu.org; Mon, 21 Nov 2016 14:42:36 -0500 Received: from mail-qt0-f171.google.com ([209.85.216.171]:33665) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c8uU5-0004Iw-HX for 24966@debbugs.gnu.org; Mon, 21 Nov 2016 14:42:34 -0500 Received: by mail-qt0-f171.google.com with SMTP id p16so209874915qta.0 for <24966@debbugs.gnu.org>; Mon, 21 Nov 2016 11:42:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=udel-edu.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=OHNrl1CYNcOl9Ic6XvzJhXHgqZGV/x6EHCxWEUTViSY=; b=wUaTJxESTsapfKD3supROC57buP7a7WNYeSyee8IHnn/zNo1DQGxtYaeQenPSNMKM7 zKQ9BXwiFo2Xnu/ElUEL+cnHnd+EaouKTrH/keFoY6Aa8mM3mINoDiQCpSzuJvQurbL2 5J9gUFURFssniAftLlwzRP6WzoOrz8wethGOWIjq80Ve5dy6yOKGamuJcydRMT6WJ/Jg LVIXjImCUo36mDWYZuxRTjeGpqMFFkE5EDo7mTMN/BTtIAo9bwxOlS2Kng5J1sKPYJa8 /qRr/23RTQbUS/o7VzHcgb01lwIROrfnxTBjPUD2PVtPhQqO2eEVVLxKY7aLCZrR97Pq 5nJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=OHNrl1CYNcOl9Ic6XvzJhXHgqZGV/x6EHCxWEUTViSY=; b=WiIFDXmCE9KNfVO3fNYz8RXC/TEg9wyBSKIV3h3Kvdut3RCbJCIGTWg+QSql+1yLtd KWytUyMNFFnRpifdE/cM+dW6a/XOAc78Dq7KHtKMFL7W/WbcpW8Xb2xnerZdxijBmwPX EQ+aKUx1AjGSs4PFVZnDptRfINn22xz3B6SNx4SzN+qWjQhNEYMXokaGkWCwZ4bN1JgJ FEHnsB7xHo4oeKsXJlpTPwnN0UGtHPvkbevg17Q2v3UDHvSl3ZXrNYyNFquzkwveGhoy FmaUP8MlvvxMcqwT8hI73NU+JCeL5HY3rPIFjVcegRsZl1id7gVGcNkwt1Nal0piskGY 1Dag== X-Gm-Message-State: AKaTC013wLcJC4iIKpKgo66BZtvH8fldvlhhQ6TCxATmO3YiSG4a0s6jeyOZ9G74kXwvenJf X-Received: by 10.237.53.237 with SMTP id d42mr9177120qte.229.1479757347938; Mon, 21 Nov 2016 11:42:27 -0800 (PST) Received: from holos.localdomain ([69.250.222.218]) by smtp.gmail.com with ESMTPSA id 21sm5876837qkf.17.2016.11.21.11.42.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Nov 2016 11:42:26 -0800 (PST) Received: by holos.localdomain (Postfix, from userid 1000) id 211B566324; Mon, 21 Nov 2016 14:42:26 -0500 (EST) Date: Mon, 21 Nov 2016 14:42:26 -0500 From: Mark Oteiza To: npostavs@users.sourceforge.net Subject: Re: bug#24966: 26.0.50; Message-ID: <20161121194226.GA4011@holos.localdomain> References: <87shqnpxym.fsf@udel.edu> <87fumljw98.fsf@users.sourceforge.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: <87fumljw98.fsf@users.sourceforge.net> User-Agent: Mutt/1.7.1+41 (5382e1e4cee1) (2016-10-04) X-Spam-Score: 0.5 (/) X-Debbugs-Envelope-To: 24966 Cc: 24966@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.5 (/) On 20/11/16 at 11:24pm, npostavs@users.sourceforge.net wrote: > unarchive 23533 > # It was marked for 25.2 before master was renumbered to 26 > notfixed 23533 25.2 > fixed 23533 26.0.50 > retitle 24966 26.0.50; test-completion with alist COLLECTION calls PREDIC= ATE incorrectly > tags 24966 confirmed > quit >=20 > Mark Oteiza writes: >=20 > > Hi, > > > > dd98ee8992c3246861e44 appears to be the culprit for breaking the > > following from -Q: >=20 > Yup, I didn't fix test-completion correctly. >=20 > > > > 1. C-x C-f /tmp/foo.tex > > 2. M-x reftex-mode > > 3. Insert the following: \label{foobar} > > 4. M-x reftex-goto-label > > > > and, when attempting to complete, a wrong-type-argument error occurs. > > > > Debugger entered--Lisp error: (wrong-type-argument listp "argh") > > #[(x) "=08@;\207" [x] 1]("argh") > > test-completion("argh" ((xr nil "\\\\\\\\\\\\") (index-tags) (is-mult= i nil) (bibview-cache) (master-dir . "/tmp/") (label-numbers) (bof "/tmp/lo= l.tex") ("argh" "s" " " "/tmp/lol.tex" nil) (eof "/tmp/lol.tex")) #[(x) "= =08@;\207" [x] 1]) >=20 > I tentatively suggest the patch below, but I want to add some tests > before commiting anything. >=20 > diff --git i/src/minibuf.c w/src/minibuf.c > index 57eea05..fe187b3 100644 > --- i/src/minibuf.c > +++ w/src/minibuf.c > @@ -1686,8 +1686,6 @@ DEFUN ("test-completion", Ftest_completion, Stest_c= ompletion, 2, 3, 0, > tem =3D Fassoc_string (string, collection, completion_ignore_case = ? Qt : Qnil); > if (NILP (tem)) > return Qnil; > - else if (CONSP (tem)) > - tem =3D XCAR (tem); > } > else if (VECTORP (collection)) > { > @@ -1765,14 +1763,16 @@ DEFUN ("test-completion", Ftest_completion, Stest= _completion, 2, 3, 0, > /* Reject this element if it fails to match all the regexps. */ > if (CONSP (Vcompletion_regexp_list)) > { > + Lisp_Object temstr =3D (CONSP (tem)) ? XCAR (tem) : tem; > + if (SYMBOLP (temstr)) > + temstr =3D string; > + > ptrdiff_t count =3D SPECPDL_INDEX (); > specbind (Qcase_fold_search, completion_ignore_case ? Qt : Qnil); > for (regexps =3D Vcompletion_regexp_list; CONSP (regexps); > regexps =3D XCDR (regexps)) > { > - if (NILP (Fstring_match (XCAR (regexps), > - SYMBOLP (tem) ? string : tem, > - Qnil))) > + if (NILP (Fstring_match (XCAR (regexps), temstr, Qnil))) > return unbind_to (count, Qnil); > } > unbind_to (count, Qnil); >=20 Thanks, this does indeed fix the recipe. From debbugs-submit-bounces@debbugs.gnu.org Sun Nov 27 15:23:41 2016 Received: (at 24966) by debbugs.gnu.org; 27 Nov 2016 20:23:41 +0000 Received: from localhost ([127.0.0.1]:43879 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cB5zA-0000wd-8N for submit@debbugs.gnu.org; Sun, 27 Nov 2016 15:23:41 -0500 Received: from mail-io0-f169.google.com ([209.85.223.169]:33743) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cB5z7-0000wL-Fb; Sun, 27 Nov 2016 15:23:38 -0500 Received: by mail-io0-f169.google.com with SMTP id j65so199344553iof.0; Sun, 27 Nov 2016 12:23:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=GIdTVKNcCq62f/tZqVeIKn0yrCYRIuffseWW11Bz3G0=; b=jYHlyHTz1yoV9fDhHtjBILeWv4PS7/NrPqN2M+Bc/yFevjKARacvikfBuuHeh+0Mav WYJWDQPLoCgSe7UeBFj9QzxKOiRcdYh/aYJr1vPk9CZhtjaLlYHK8CCShREXUf5G5VYQ wwreWJ1uJKkfTPGDkXh0fnNea/UIZoN57q4RWuCxd645Mgs8w0EwTkkxmx4quRrOJnsX XC5YZe5UzePKp0cHirBa1PIuY1n5hkXRLsrWJw/3eYoA4ybd26i2IyrOdTIQWPsmYLJe eSwLrqxm8tcCdb4yglBIxvE01+plYonnGHzl1KrRkQ0kkkRBZuC8TcRxYt0YoR/l0oBW iovA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:references:date :in-reply-to:message-id:user-agent:mime-version; bh=GIdTVKNcCq62f/tZqVeIKn0yrCYRIuffseWW11Bz3G0=; b=TxjV02qozxl2hOYUN/3OddCJyM6sMJ6k8rtWkX4oXrwNZKZhljUoGQSNZBLsXbwMSJ E9l4fGsiEGicfW5ffKTnOyfZA6/k2KjazZ5Zg0jOuJ3Bg0oQDcNzfavMvuij7C6hW+/K heIEnCv3pvyC73iH6o6GcZVV3eMzuFxQqviMbcdTcsDQIAHNPCNyMJMHDRpig/Bm7wgN DLevaKszSPuk7reaZDln4317ofptxEBAJCG3Bx5QuexFrVBC18nLlDpUeU3AgVLV4hx6 zrez2/N42WTyzdw8CdlHRivzeiEzXR2fdJxC6DaGNABcyyfsQo/sL1HyBQipjH6Sv5LJ Sv4A== X-Gm-Message-State: AKaTC01vt2Afwj2WAUerOQEq/MvBd8LVWmpBIK8yb4Y5leEbSFEKJeaeAeF8oy+RuNTS0g== X-Received: by 10.107.156.75 with SMTP id f72mr16151813ioe.9.1480278212003; Sun, 27 Nov 2016 12:23:32 -0800 (PST) Received: from zony ([45.2.7.65]) by smtp.googlemail.com with ESMTPSA id w192sm8057785itw.3.2016.11.27.12.23.31 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 27 Nov 2016 12:23:31 -0800 (PST) From: npostavs@users.sourceforge.net To: Mark Oteiza Subject: Re: bug#24966: 26.0.50; test-completion with alist COLLECTION calls PREDICATE incorrectly References: <87shqnpxym.fsf@udel.edu> <87fumljw98.fsf@users.sourceforge.net> Date: Sun, 27 Nov 2016 15:24:27 -0500 In-Reply-To: <87fumljw98.fsf@users.sourceforge.net> (npostavs@users.sourceforge.net's message of "Sun, 20 Nov 2016 23:24:19 -0500") Message-ID: <87eg1wisck.fsf_-_@users.sourceforge.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -0.2 (/) X-Debbugs-Envelope-To: 24966 Cc: 24966@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.2 (/) --=-=-= Content-Type: text/plain tags 24966 patch quit npostavs@users.sourceforge.net writes: > > I tentatively suggest the patch below, but I want to add some tests > before commiting anything. While adding tests, I found another inconsistency: when given a hashtable with symbol keys, test-completion passes the symbol-name to PREDICATE, while all-completions and try-completion pass the original symbol key. Here are two patches, the first for this bug, and the second for the other inconsistency. --=-=-= Content-Type: text/plain Content-Disposition: attachment; filename=v1-0001-Give-test-completion-s-PREDICATE-full-alist-entry.patch Content-Description: patch >From ba3f1477e66536fd759c4f7128bfbca009532b14 Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Sun, 27 Nov 2016 10:04:48 -0500 Subject: [PATCH v1 1/2] Give test-completion's PREDICATE full alist entry Since 2016-06-26 "Fix test-completion with completion-regexp-list", when calling test-completion with an alist collection, the predicate was recieving the string value instead of the alist entry (Bug#24966). * src/minibuf.c (Ftest_completion): Don't modify the found element, just test STRING against `completion-regexp-list'. * test/src/minibuf-tests.el: New tests for `try-completion', `all-completions', and `test-completion'. --- src/minibuf.c | 8 +- test/src/minibuf-tests.el | 406 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 409 insertions(+), 5 deletions(-) create mode 100644 test/src/minibuf-tests.el diff --git a/src/minibuf.c b/src/minibuf.c index 57eea05..6c694cb 100644 --- a/src/minibuf.c +++ b/src/minibuf.c @@ -1686,8 +1686,6 @@ DEFUN ("test-completion", Ftest_completion, Stest_completion, 2, 3, 0, tem = Fassoc_string (string, collection, completion_ignore_case ? Qt : Qnil); if (NILP (tem)) return Qnil; - else if (CONSP (tem)) - tem = XCAR (tem); } else if (VECTORP (collection)) { @@ -1770,9 +1768,9 @@ DEFUN ("test-completion", Ftest_completion, Stest_completion, 2, 3, 0, for (regexps = Vcompletion_regexp_list; CONSP (regexps); regexps = XCDR (regexps)) { - if (NILP (Fstring_match (XCAR (regexps), - SYMBOLP (tem) ? string : tem, - Qnil))) + /* We can test against STRING, because if we got here, then + the element is equivalent to it. */ + if (NILP (Fstring_match (XCAR (regexps), string, Qnil))) return unbind_to (count, Qnil); } unbind_to (count, Qnil); diff --git a/test/src/minibuf-tests.el b/test/src/minibuf-tests.el new file mode 100644 index 0000000..98b8614 --- /dev/null +++ b/test/src/minibuf-tests.el @@ -0,0 +1,406 @@ +;;; minibuf-tests.el --- tests for minibuf.c functions -*- lexical-binding: t -*- + +;; Copyright (C) 2016 Free Software Foundation, Inc. + +;; This file is part of GNU Emacs. + +;; GNU Emacs is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; GNU Emacs is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs. If not, see . + +;;; Code: + +(require 'ert) + + +;;; Support functions for `try-completion', `all-completion', and +;;; `test-completion' tests. + +(defun minibuf-tests--strings-to-symbol-list (list) + (mapcar #'intern list)) +(defun minibuf-tests--strings-to-symbol-alist (list) + (let ((num 0)) + (mapcar (lambda (str) (cons (intern str) (cl-incf num))) list))) +(defun minibuf-tests--strings-to-string-alist (list) + (let ((num 0)) + (mapcar (lambda (str) (cons str (cl-incf num))) list))) +(defun minibuf-tests--strings-to-obarray (list) + (let ((ob (make-vector 7 0))) + (mapc (lambda (str) (intern str ob)) list) + ob)) +(defun minibuf-tests--strings-to-string-hashtable (list) + (let ((ht (make-hash-table :test #'equal)) + (num 0)) + (mapc (lambda (str) (puthash str (cl-incf num) ht)) list) + ht)) +(defun minibuf-tests--strings-to-symbol-hashtable (list) + (let ((ht (make-hash-table :test #'equal)) + (num 0)) + (mapc (lambda (str) (puthash (intern str) (cl-incf num) ht)) list) + ht)) + +;;; Functions that produce a predicate (for *-completion functions) +;;; which always returns non-nil for a given collection. + +(defun minibuf-tests--memq-of-collection (collection) + (lambda (elt) (memq elt collection))) +(defun minibuf-tests--part-of-obarray (ob) + (lambda (sym) (eq (intern-soft (symbol-name sym) ob) sym))) +(defun minibuf-tests--part-of-hashtable (table) + (lambda (k v) (equal (gethash k table) v))) + + +;;; Testing functions that are agnostic to type of COLLECTION. + +(defun minibuf-tests--try-completion (xform-collection) + (let* ((abcdef (funcall xform-collection '("abc" "def"))) + (+abba (funcall xform-collection '("abc" "abba" "def")))) + (should (equal (try-completion "a" abcdef) "abc")) + (should (equal (try-completion "a" +abba) "ab")) + (should (equal (try-completion "abc" +abba) t)) + (should (equal (try-completion "abcd" +abba) nil)))) + +(defun minibuf-tests--try-completion-pred (xform-collection collection-member) + (let* ((abcdef (funcall xform-collection '("abc" "def"))) + (abcdef-member (funcall collection-member abcdef)) + (+abba (funcall xform-collection '("abc" "abba" "def"))) + (+abba-member (funcall collection-member +abba))) + (should (equal (try-completion "a" abcdef abcdef-member) "abc")) + (should (equal (try-completion "a" +abba +abba-member) "ab")) + (should (equal (try-completion "abc" +abba +abba-member) t)) + (should (equal (try-completion "abcd" +abba +abba-member) nil)) + (should-not (try-completion "a" abcdef #'ignore)) + (should-not (try-completion "a" +abba #'ignore)) + (should-not (try-completion "abc" +abba #'ignore)) + (should-not (try-completion "abcd" +abba #'ignore)))) + +(defun minibuf-tests--try-completion-regexp (xform-collection) + (let ((abcdef (funcall xform-collection '("abc" "def"))) + (+abba (funcall xform-collection '("abc" "abba" "def")))) + (let ((completion-regexp-list '("."))) + (should (equal (try-completion "a" abcdef) "abc")) + (should (equal (try-completion "a" +abba) "ab")) + (should (equal (try-completion "abc" +abba) t)) + (should (equal (try-completion "abcd" +abba) nil))) + (let ((completion-regexp-list '("X"))) + (should-not (try-completion "a" abcdef)) + (should-not (try-completion "a" +abba)) + (should-not (try-completion "abc" +abba)) + (should-not (try-completion "abcd" +abba))))) + +(defun minibuf-tests--all-completions (xform-collection) + (let* ((abcdef (funcall xform-collection '("abc" "def"))) + (+abba (funcall xform-collection '("abc" "abba" "def")))) + (should (equal (all-completions "a" abcdef) '("abc"))) + (should (equal (all-completions "a" +abba) '("abc" "abba"))) + (should (equal (all-completions "abc" +abba) '("abc"))) + (should (equal (all-completions "abcd" +abba) nil)))) + +(defun minibuf-tests--all-completions-pred (xform-collection collection-member) + (let* ((abcdef (funcall xform-collection '("abc" "def"))) + (abcdef-member (funcall collection-member abcdef)) + (+abba (funcall xform-collection '("abc" "abba" "def"))) + (+abba-member (funcall collection-member +abba))) + (should (equal (all-completions "a" abcdef abcdef-member) '("abc"))) + (should (equal (all-completions "a" +abba +abba-member) '("abc" "abba"))) + (should (equal (all-completions "abc" +abba +abba-member) '("abc"))) + (should (equal (all-completions "abcd" +abba +abba-member) nil)) + (should-not (all-completions "a" abcdef #'ignore)) + (should-not (all-completions "a" +abba #'ignore)) + (should-not (all-completions "abc" +abba #'ignore)) + (should-not (all-completions "abcd" +abba #'ignore)))) + +(defun minibuf-tests--all-completions-regexp (xform-collection) + (let ((abcdef (funcall xform-collection '("abc" "def"))) + (+abba (funcall xform-collection '("abc" "abba" "def")))) + (let ((completion-regexp-list '("."))) + (should (equal (all-completions "a" abcdef) '("abc"))) + (should (equal (all-completions "a" +abba) '("abc" "abba"))) + (should (equal (all-completions "abc" +abba) '("abc"))) + (should (equal (all-completions "abcd" +abba) nil))) + (let ((completion-regexp-list '("X"))) + (should-not (all-completions "a" abcdef)) + (should-not (all-completions "a" +abba)) + (should-not (all-completions "abc" +abba)) + (should-not (all-completions "abcd" +abba))))) + +(defun minibuf-tests--test-completion (xform-collection) + (let* ((abcdef (funcall xform-collection '("abc" "def"))) + (+abba (funcall xform-collection '("abc" "abba" "def")))) + (should (test-completion "abc" abcdef)) + (should (test-completion "def" +abba)) + (should (test-completion "abba" +abba)) + (should-not (test-completion "abcd" +abba)))) + +(defun minibuf-tests--test-completion-pred (xform-collection collection-member) + (let* ((abcdef (funcall xform-collection '("abc" "def"))) + (abcdef-member (funcall collection-member abcdef)) + (+abba (funcall xform-collection '("abc" "abba" "def"))) + (+abba-member (funcall collection-member +abba))) + (should (test-completion "abc" abcdef abcdef-member)) + (should (test-completion "def" +abba +abba-member)) + (should (test-completion "abba" +abba +abba-member)) + (should-not (test-completion "abcd" +abba +abba-member)) + (should-not (test-completion "abc" abcdef #'ignore)) + (should-not (test-completion "def" +abba #'ignore)) + (should-not (test-completion "abba" +abba #'ignore)) + (should-not (test-completion "abcd" +abba #'ignore)))) + +(defun minibuf-tests--test-completion-regexp (xform-collection) + (let ((abcdef (funcall xform-collection '("abc" "def"))) + (+abba (funcall xform-collection '("abc" "abba" "def")))) + (let ((completion-regexp-list '("."))) + (should (test-completion "abc" abcdef)) + (should (test-completion "def" +abba)) + (should (test-completion "abba" +abba)) + (should-not (test-completion "abcd" +abba))) + (let ((completion-regexp-list '("X"))) + (should-not (test-completion "abc" abcdef)) + (should-not (test-completion "def" +abba)) + (should-not (test-completion "abba" +abba)) + (should-not (test-completion "abcd" +abba))))) + + +;;; Tests for `try-completion'. +(ert-deftest try-completion-string-list () + (minibuf-tests--try-completion #'identity)) +(ert-deftest try-completion-string-list-predicate () + (minibuf-tests--try-completion-pred + #'identity #'minibuf-tests--memq-of-collection)) +(ert-deftest try-completion-string-list-completion-regexp () + (minibuf-tests--try-completion-regexp #'identity)) + +(ert-deftest try-completion-symbol-list () + (minibuf-tests--try-completion + #'minibuf-tests--strings-to-symbol-list)) +(ert-deftest try-completion-symbol-list-predicate () + (minibuf-tests--try-completion-pred + #'minibuf-tests--strings-to-symbol-list + #'minibuf-tests--memq-of-collection)) +(ert-deftest try-completion-symbol-list-completion-regexp () + (minibuf-tests--try-completion-regexp + #'minibuf-tests--strings-to-symbol-list)) + +(ert-deftest try-completion-symbol-alist () + (minibuf-tests--try-completion + #'minibuf-tests--strings-to-symbol-alist)) +(ert-deftest try-completion-symbol-alist-predicate () + (minibuf-tests--try-completion-pred + #'minibuf-tests--strings-to-symbol-alist + #'minibuf-tests--memq-of-collection)) +(ert-deftest try-completion-symbol-alist-completion-regexp () + (minibuf-tests--try-completion-regexp + #'minibuf-tests--strings-to-symbol-alist)) + +(ert-deftest try-completion-string-alist () + (minibuf-tests--try-completion + #'minibuf-tests--strings-to-string-alist)) +(ert-deftest try-completion-string-alist-predicate () + (minibuf-tests--try-completion-pred + #'minibuf-tests--strings-to-string-alist + #'minibuf-tests--memq-of-collection)) +(ert-deftest try-completion-string-alist-completion-regexp () + (minibuf-tests--try-completion-regexp + #'minibuf-tests--strings-to-string-alist)) + +(ert-deftest try-completion-obarray () + (minibuf-tests--try-completion + #'minibuf-tests--strings-to-obarray)) +(ert-deftest try-completion-obarray-predicate () + (minibuf-tests--try-completion-pred + #'minibuf-tests--strings-to-obarray + #'minibuf-tests--part-of-obarray)) +(ert-deftest try-completion-obarray-completion-regexp () + (minibuf-tests--try-completion-regexp + #'minibuf-tests--strings-to-obarray)) + +(ert-deftest try-completion-string-hashtable () + (minibuf-tests--try-completion + #'minibuf-tests--strings-to-string-hashtable)) +(ert-deftest try-completion-string-hashtable-predicate () + (minibuf-tests--try-completion-pred + #'minibuf-tests--strings-to-string-hashtable + #'minibuf-tests--part-of-hashtable)) +(ert-deftest try-completion-string-hashtable-completion-regexp () + (minibuf-tests--try-completion-regexp + #'minibuf-tests--strings-to-string-hashtable)) + +(ert-deftest try-completion-symbol-hashtable () + (minibuf-tests--try-completion + #'minibuf-tests--strings-to-symbol-hashtable)) +(ert-deftest try-completion-symbol-hashtable-predicate () + (minibuf-tests--try-completion-pred + #'minibuf-tests--strings-to-symbol-hashtable + #'minibuf-tests--part-of-hashtable)) +(ert-deftest try-completion-symbol-hashtable-completion-regexp () + (minibuf-tests--try-completion-regexp + #'minibuf-tests--strings-to-symbol-hashtable)) + + +;;; Tests for `all-completions'. + +(ert-deftest all-completions-string-list () + (minibuf-tests--all-completions #'identity)) +(ert-deftest all-completions-string-list-predicate () + (minibuf-tests--all-completions-pred + #'identity #'minibuf-tests--memq-of-collection)) +(ert-deftest all-completions-string-list-completion-regexp () + (minibuf-tests--all-completions-regexp #'identity)) + +(ert-deftest all-completions-symbol-list () + (minibuf-tests--all-completions + #'minibuf-tests--strings-to-symbol-list)) +(ert-deftest all-completions-symbol-list-predicate () + (minibuf-tests--all-completions-pred + #'minibuf-tests--strings-to-symbol-list + #'minibuf-tests--memq-of-collection)) +(ert-deftest all-completions-symbol-list-completion-regexp () + (minibuf-tests--all-completions-regexp + #'minibuf-tests--strings-to-symbol-list)) + +(ert-deftest all-completions-symbol-alist () + (minibuf-tests--all-completions + #'minibuf-tests--strings-to-symbol-alist)) +(ert-deftest all-completions-symbol-alist-predicate () + (minibuf-tests--all-completions-pred + #'minibuf-tests--strings-to-symbol-alist + #'minibuf-tests--memq-of-collection)) +(ert-deftest all-completions-symbol-alist-completion-regexp () + (minibuf-tests--all-completions-regexp + #'minibuf-tests--strings-to-symbol-alist)) + +(ert-deftest all-completions-string-alist () + (minibuf-tests--all-completions + #'minibuf-tests--strings-to-string-alist)) +(ert-deftest all-completions-string-alist-predicate () + (minibuf-tests--all-completions-pred + #'minibuf-tests--strings-to-string-alist + #'minibuf-tests--memq-of-collection)) +(ert-deftest all-completions-string-alist-completion-regexp () + (minibuf-tests--all-completions-regexp + #'minibuf-tests--strings-to-string-alist)) + +(ert-deftest all-completions-obarray () + (minibuf-tests--all-completions + #'minibuf-tests--strings-to-obarray)) +(ert-deftest all-completions-obarray-predicate () + (minibuf-tests--all-completions-pred + #'minibuf-tests--strings-to-obarray + #'minibuf-tests--part-of-obarray)) +(ert-deftest all-completions-obarray-completion-regexp () + (minibuf-tests--all-completions-regexp + #'minibuf-tests--strings-to-obarray)) + +(ert-deftest all-completions-string-hashtable () + (minibuf-tests--all-completions + #'minibuf-tests--strings-to-string-hashtable)) +(ert-deftest all-completions-string-hashtable-predicate () + (minibuf-tests--all-completions-pred + #'minibuf-tests--strings-to-string-hashtable + #'minibuf-tests--part-of-hashtable)) +(ert-deftest all-completions-string-hashtable-completion-regexp () + (minibuf-tests--all-completions-regexp + #'minibuf-tests--strings-to-string-hashtable)) + +(ert-deftest all-completions-symbol-hashtable () + (minibuf-tests--all-completions + #'minibuf-tests--strings-to-symbol-hashtable)) +(ert-deftest all-completions-symbol-hashtable-predicate () + (minibuf-tests--all-completions-pred + #'minibuf-tests--strings-to-symbol-hashtable + #'minibuf-tests--part-of-hashtable)) +(ert-deftest all-completions-symbol-hashtable-completion-regexp () + (minibuf-tests--all-completions-regexp + #'minibuf-tests--strings-to-symbol-hashtable)) + + +;;; Tests for `test-completion'. + +(ert-deftest test-completion-string-list () + (minibuf-tests--test-completion #'identity)) +(ert-deftest test-completion-string-list-predicate () + (minibuf-tests--test-completion-pred + #'identity #'minibuf-tests--memq-of-collection)) +(ert-deftest test-completion-string-list-completion-regexp () + (minibuf-tests--test-completion-regexp #'identity)) + +(ert-deftest test-completion-symbol-list () + (minibuf-tests--test-completion + #'minibuf-tests--strings-to-symbol-list)) +(ert-deftest test-completion-symbol-list-predicate () + (minibuf-tests--test-completion-pred + #'minibuf-tests--strings-to-symbol-list + #'minibuf-tests--memq-of-collection)) +(ert-deftest test-completion-symbol-list-completion-regexp () + (minibuf-tests--test-completion-regexp + #'minibuf-tests--strings-to-symbol-list)) + +(ert-deftest test-completion-symbol-alist () + (minibuf-tests--test-completion + #'minibuf-tests--strings-to-symbol-alist)) +(ert-deftest test-completion-symbol-alist-predicate () + (minibuf-tests--test-completion-pred + #'minibuf-tests--strings-to-symbol-alist + #'minibuf-tests--memq-of-collection)) +(ert-deftest test-completion-symbol-alist-completion-regexp () + (minibuf-tests--test-completion-regexp + #'minibuf-tests--strings-to-symbol-alist)) + +(ert-deftest test-completion-string-alist () + (minibuf-tests--test-completion + #'minibuf-tests--strings-to-string-alist)) +(ert-deftest test-completion-string-alist-predicate () + (minibuf-tests--test-completion-pred + #'minibuf-tests--strings-to-string-alist + #'minibuf-tests--memq-of-collection)) +(ert-deftest test-completion-string-alist-completion-regexp () + (minibuf-tests--test-completion-regexp + #'minibuf-tests--strings-to-string-alist)) + +(ert-deftest test-completion-obarray () + (minibuf-tests--test-completion + #'minibuf-tests--strings-to-obarray)) +(ert-deftest test-completion-obarray-predicate () + (minibuf-tests--test-completion-pred + #'minibuf-tests--strings-to-obarray + #'minibuf-tests--part-of-obarray)) +(ert-deftest test-completion-obarray-completion-regexp () + (minibuf-tests--test-completion-regexp + #'minibuf-tests--strings-to-obarray)) + +(ert-deftest test-completion-string-hashtable () + (minibuf-tests--test-completion + #'minibuf-tests--strings-to-string-hashtable)) +(ert-deftest test-completion-string-hashtable-predicate () + (minibuf-tests--test-completion-pred + #'minibuf-tests--strings-to-string-hashtable + #'minibuf-tests--part-of-hashtable)) +(ert-deftest test-completion-string-hashtable-completion-regexp () + (minibuf-tests--test-completion-regexp + #'minibuf-tests--strings-to-string-hashtable)) + +(ert-deftest test-completion-symbol-hashtable () + (minibuf-tests--test-completion + #'minibuf-tests--strings-to-symbol-hashtable)) +(ert-deftest test-completion-symbol-hashtable-predicate () + (minibuf-tests--test-completion-pred + #'minibuf-tests--strings-to-symbol-hashtable + ;; The predicate recieves a string as the key in this case. + (lambda (table) + (let ((in-table (minibuf-tests--part-of-hashtable table))) + (lambda (k v) (funcall in-table (intern k) v)))))) +(ert-deftest test-completion-symbol-hashtable-completion-regexp () + (minibuf-tests--test-completion-regexp + #'minibuf-tests--strings-to-symbol-hashtable)) + + +;;; minibuf-tests.el ends here -- 2.9.3 --=-=-= Content-Type: text/plain Content-Disposition: attachment; filename=v1-0002-Give-test-completion-s-PREDICATE-the-hashtable-ke.patch Content-Description: patch >From 6b587c804c6a98b30de984e58e56b9ba3794810a Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Sun, 27 Nov 2016 14:41:02 -0500 Subject: [PATCH v1 2/2] Give test-completion's PREDICATE the hashtable key For hashtable entries with symbol keys, `test-completion' would convert the key to a string before calling PREDICATE, unlike `try-completion' and `all-completions'. * src/minibuf.c (Ftest_completion): Pass original key from hashtable. --- src/minibuf.c | 23 ++++++++++++----------- test/src/minibuf-tests.el | 5 +---- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/src/minibuf.c b/src/minibuf.c index 6c694cb..7c5af34 100644 --- a/src/minibuf.c +++ b/src/minibuf.c @@ -1736,26 +1736,27 @@ DEFUN ("test-completion", Ftest_completion, Stest_completion, 2, 3, 0, else if (HASH_TABLE_P (collection)) { struct Lisp_Hash_Table *h = XHASH_TABLE (collection); - Lisp_Object key = Qnil; i = hash_lookup (h, string, NULL); if (i >= 0) + { tem = HASH_KEY (h, i); + goto found_matching_key; + } else for (i = 0; i < HASH_TABLE_SIZE (h); ++i) - if (!NILP (HASH_HASH (h, i)) - && (key = HASH_KEY (h, i), - SYMBOLP (key) ? key = Fsymbol_name (key) : key, - STRINGP (key)) - && EQ (Fcompare_strings (string, make_number (0), Qnil, - key, make_number (0) , Qnil, + { + if (NILP (HASH_HASH (h, i))) continue; + tem = HASH_KEY (h, i); + Lisp_Object strkey = (SYMBOLP (tem) ? Fsymbol_name (tem) : tem); + if (!STRINGP (strkey)) continue; + if (EQ (Fcompare_strings (string, Qnil, Qnil, + strkey, Qnil, Qnil, completion_ignore_case ? Qt : Qnil), Qt)) - { - tem = key; - break; + goto found_matching_key; } - if (!STRINGP (tem)) return Qnil; + found_matching_key: ; } else return call3 (collection, string, predicate, Qlambda); diff --git a/test/src/minibuf-tests.el b/test/src/minibuf-tests.el index 98b8614..82ac037 100644 --- a/test/src/minibuf-tests.el +++ b/test/src/minibuf-tests.el @@ -394,10 +394,7 @@ minibuf-tests--test-completion-regexp (ert-deftest test-completion-symbol-hashtable-predicate () (minibuf-tests--test-completion-pred #'minibuf-tests--strings-to-symbol-hashtable - ;; The predicate recieves a string as the key in this case. - (lambda (table) - (let ((in-table (minibuf-tests--part-of-hashtable table))) - (lambda (k v) (funcall in-table (intern k) v)))))) + #'minibuf-tests--part-of-hashtable)) (ert-deftest test-completion-symbol-hashtable-completion-regexp () (minibuf-tests--test-completion-regexp #'minibuf-tests--strings-to-symbol-hashtable)) -- 2.9.3 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Mon Nov 28 15:59:25 2016 Received: (at 24966) by debbugs.gnu.org; 28 Nov 2016 20:59:25 +0000 Received: from localhost ([127.0.0.1]:45307 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cBT1J-0003BY-Bz for submit@debbugs.gnu.org; Mon, 28 Nov 2016 15:59:25 -0500 Received: from mail-qt0-f180.google.com ([209.85.216.180]:36489) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cBT1I-0003BM-Fp for 24966@debbugs.gnu.org; Mon, 28 Nov 2016 15:59:24 -0500 Received: by mail-qt0-f180.google.com with SMTP id w33so135085665qtc.3 for <24966@debbugs.gnu.org>; Mon, 28 Nov 2016 12:59:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=udel-edu.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=PJLp1mfg5+d5Nb/wlVoqlmaZwyCeszJMKFLd0VFrILc=; b=bWfJbnO6sTRCoh+Xlg0n/1NcXwTN9RDC5Xz/Y1iqFa0XdTfDgksUVRrU8TM2T1zecF KBPae7PU5QRJaiaOM9Cm9ZWZEiTi0Ii5fbOdr8rpeXHx6l4O2BICoR0kWYtl5Azp+fbt ziWVG19q3rwRQpW0ewRZdKGYltt/re5jZjCKQ835SYpke1U2Kv3iegdpb6+KwAnkjimW qdjBDutlxx6Mj2RFoN13sJoUqp168qGP4pPGzS7PYkVGmb6tPnuJrLWlA4geJ/cpfzDJ m6CeM7g8Mlf3TE5TrXEjvK56sqQK1RSTbNYvdb1pVya3OCuKFR4dHroK/zEIDpLp09wD yuNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=PJLp1mfg5+d5Nb/wlVoqlmaZwyCeszJMKFLd0VFrILc=; b=lPoQ6fG9Srfp0VW7lvsJXxl/CsyjQo0RBc4LFyzhOLMHjEYELa7XL/abhZvYtdv6J5 orvut0gjWUPpT7ZgxTf3y2vo73EsIAnFAuY3WTUq0fU912rgDbkNU/Dew3yU0B4UHc2e D+Tbp0SItz0zXITORVhq0ivTqhzhVGChLGFOo0cuVjhArnVM+CyNBAbiVJEwrI9FsYPC j0aBfP7yXESwYyFpG5LmbT8ou7mNgXTfgzteXw4kmYUzRIe845v/U3wNPIn/DAos8091 9U7Pc8w99d3h+6SOLNX+FE9eRAyfdlWB/w9EWB+NoVPuX0knuleNJrl2Nm3O+BKUSTJ8 x4Ug== X-Gm-Message-State: AKaTC01QJt3Fsyb0h7CyAaEeKnLVhLXKlcQoMpkVGcCvEk9Xu1uKoGECRu17Un4DHpML37cN X-Received: by 10.200.51.119 with SMTP id u52mr21007201qta.226.1480366758631; Mon, 28 Nov 2016 12:59:18 -0800 (PST) Received: from holos.localdomain ([69.250.222.218]) by smtp.gmail.com with ESMTPSA id x4sm29210330qtc.42.2016.11.28.12.59.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Nov 2016 12:59:17 -0800 (PST) Received: by holos.localdomain (Postfix, from userid 1000) id 10F2D60D62; Mon, 28 Nov 2016 15:59:17 -0500 (EST) Date: Mon, 28 Nov 2016 15:59:17 -0500 From: Mark Oteiza To: npostavs@users.sourceforge.net Subject: Re: bug#24966: 26.0.50; test-completion with alist COLLECTION calls PREDICATE incorrectly Message-ID: <20161128205917.GA17197@holos.localdomain> References: <87shqnpxym.fsf@udel.edu> <87fumljw98.fsf@users.sourceforge.net> <87eg1wisck.fsf_-_@users.sourceforge.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87eg1wisck.fsf_-_@users.sourceforge.net> User-Agent: Mutt/1.7.1+60 (b22c5d0e299d) (2016-10-04) X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 24966 Cc: 24966@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) On 27/11/16 at 03:24pm, npostavs@users.sourceforge.net wrote: > tags 24966 patch > quit > > npostavs@users.sourceforge.net writes: > > > > I tentatively suggest the patch below, but I want to add some tests > > before commiting anything. > > While adding tests, I found another inconsistency: when given a > hashtable with symbol keys, test-completion passes the symbol-name to > PREDICATE, while all-completions and try-completion pass the original > symbol key. Here are two patches, the first for this bug, and the > second for the other inconsistency. The first hunk of 2/2 isn't applying here. From debbugs-submit-bounces@debbugs.gnu.org Mon Nov 28 16:03:38 2016 Received: (at 24966) by debbugs.gnu.org; 28 Nov 2016 21:03:38 +0000 Received: from localhost ([127.0.0.1]:45311 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cBT5N-0003J2-Sf for submit@debbugs.gnu.org; Mon, 28 Nov 2016 16:03:38 -0500 Received: from mail-oi0-f45.google.com ([209.85.218.45]:36299) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cBT5L-0003Io-T5 for 24966@debbugs.gnu.org; Mon, 28 Nov 2016 16:03:36 -0500 Received: by mail-oi0-f45.google.com with SMTP id v84so166094240oie.3 for <24966@debbugs.gnu.org>; Mon, 28 Nov 2016 13:03:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=T6AsepEopwNXJScLJvuGcpLnlmjUxszreIOM00kE5MI=; b=qkBG8ecGmd03fNmqPbWiX1SJ1bc5NO6D5bRCUE2pEcbUvRc80JSnkovpUyOXNmR8mc Kdubgo1RO7OxBorSsFm9+/vC75jSr/sWIui8rt7nUJj4fE5GkpNN/zP8vUSHlv7PlX8B 2WhCNbsoIkkfp9pY0vwCDthh6y9ffojnYndRzB9NFbY9BmkQQxyUY7aMXda27S2/hZLL XNL+b3eoK0rpM5ahrkXibvJtBfTMj/aHBj8bsBi9gLxd2y3XuCu5AaWVlmr6m4ZuqKUy dWHREZWxejutVMpuRweUGMtWdmh9sOmf/twPFJ4gt3AbZXS4c8nw/+SunnU5Svmaqa8L IZ+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=T6AsepEopwNXJScLJvuGcpLnlmjUxszreIOM00kE5MI=; b=glS5sHtEJtXFVfRZeAOLlxOJP6lK2G1bsH9whxG+gsGYvfmzlcQz6LG7QDK/nYul4E wxtGrwocMXmeGXLEORDoMGhRazBcxOKZ96RwIzn5mTdGDXwfEwNY9/NP0CptMCgEVnI8 sTl4si1L0C8TVS2k4fmkajnOs1zrJjNv+5MIQyNVvi6voQQjGE/adPb4q/HatW6h+sjU nyI4QHwxAv9ADdJBxBzyLx5cRhYvABS0QlEStXl2U26rkzC7DtR8NyRtKsV9pSNJcoJL qOafnvP4Sfd/QFZcTqeESs4tkKA7IcZMcjlD+ni+NXkuGZumos5tpHKQERFvNIg/nDvB bLzA== X-Gm-Message-State: AKaTC002pNWnxN1inxA49FvU100SiJOZby7yIWiitmBQQ070ryO1EAIunEKft9ONm588lExy40gyO34D508z3Q== X-Received: by 10.157.53.50 with SMTP id o47mr12881453otc.19.1480367010218; Mon, 28 Nov 2016 13:03:30 -0800 (PST) MIME-Version: 1.0 Received: by 10.157.4.67 with HTTP; Mon, 28 Nov 2016 13:03:29 -0800 (PST) In-Reply-To: <20161128205917.GA17197@holos.localdomain> References: <87shqnpxym.fsf@udel.edu> <87fumljw98.fsf@users.sourceforge.net> <87eg1wisck.fsf_-_@users.sourceforge.net> <20161128205917.GA17197@holos.localdomain> From: Noam Postavsky Date: Mon, 28 Nov 2016 16:03:29 -0500 X-Google-Sender-Auth: AZ0U__v6IGvv1cFD21TgBEjoVlQ Message-ID: Subject: Re: bug#24966: 26.0.50; test-completion with alist COLLECTION calls PREDICATE incorrectly To: Mark Oteiza Content-Type: text/plain; charset=UTF-8 X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 24966 Cc: 24966@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) On Mon, Nov 28, 2016 at 3:59 PM, Mark Oteiza wrote: >> >> npostavs@users.sourceforge.net writes: >> > >> > I tentatively suggest the patch below, but I want to add some tests >> > before commiting anything. >> >> While adding tests, I found another inconsistency: when given a >> hashtable with symbol keys, test-completion passes the symbol-name to >> PREDICATE, while all-completions and try-completion pass the original >> symbol key. Here are two patches, the first for this bug, and the >> second for the other inconsistency. > > The first hunk of 2/2 isn't applying here. Oh, that's probably because I generated it with -w, so some whitespace changes are missing in 1/2. I'll post a full patch tonight. From debbugs-submit-bounces@debbugs.gnu.org Mon Nov 28 22:30:46 2016 Received: (at 24966) by debbugs.gnu.org; 29 Nov 2016 03:30:46 +0000 Received: from localhost ([127.0.0.1]:45444 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cBZ81-0005al-KU for submit@debbugs.gnu.org; Mon, 28 Nov 2016 22:30:46 -0500 Received: from mail-io0-f170.google.com ([209.85.223.170]:33553) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cBZ7y-0005aU-Qc for 24966@debbugs.gnu.org; Mon, 28 Nov 2016 22:30:43 -0500 Received: by mail-io0-f170.google.com with SMTP id j65so268517192iof.0 for <24966@debbugs.gnu.org>; Mon, 28 Nov 2016 19:30:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=XdaYar8lwH5bKHECudxHft45+Y3HE8cl9m9fYu6dVsc=; b=DoANOgL5rvuDiN2HurmEoXWKKwq1LySGVctdJRki/tXwur5x9oxvE0P8jWSSr7LoiD DUh/3BrbUMZGCVZSsENvWzTsHemHh1KMd1JWM5LwqhQ5lqA4M6M3K0e7SGZ/++MttMbR taNseUzRXT7BJgcfNk/hK48WzwH8LARPKe1nO2waRe3v5uHiG8YCjoefltf58ifWT0Ax dhuqllkL1bQZR4oaM2hnMfaZLEQQqcxcHzOeO0EYXoGuDP6eXhdLAZ5jZIVPRo4/t5CY gaH9bHiZK0FT6mnuQl0ACgE3Oky9p+zycEVAgvGTGsErbgbR/ZAl1l6AgTc65NSCOsem bfOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:references:date :in-reply-to:message-id:user-agent:mime-version; bh=XdaYar8lwH5bKHECudxHft45+Y3HE8cl9m9fYu6dVsc=; b=KhZkIudsMHQxyOaO8Hkg39bcfTj0TPLBmgABKMXuf4DzXrNggZHO55V/8Z5jI8n+6q F2EW3hNAMl2w5Ie4eR7TNvr9bR+gK+4L1C0fZ6CV6x2EoBO+eVSZ8knkALshrROvHx/B xIUe04GEcGk3sqVbxhuwwfA+/vicoxgToRVbgnkJAEmzilicNxUZAHyO/OI/1GPEqwvN Xz/k8z7re+TIT7DjNtOA2foVQYTKGuC99Sg1wBqudI6JMFuHyKn6MTbbazhYwLK2hYi8 Z7bzjzLX3L5aXnU7sYKxygMhmAOsSRxSiAqbUBo4/8sJalZUE0etXJyu6r/qbFMpf75j g2DQ== X-Gm-Message-State: AKaTC01RUU7CCBUIN6NIodoYABL6owgUdwVwdEn+ouhCa6PncXi75IOHYkWDkpGDtqi4cA== X-Received: by 10.107.131.195 with SMTP id n64mr22425474ioi.161.1480390236946; Mon, 28 Nov 2016 19:30:36 -0800 (PST) Received: from zony ([45.2.7.65]) by smtp.googlemail.com with ESMTPSA id r9sm641480ita.0.2016.11.28.19.30.35 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 28 Nov 2016 19:30:36 -0800 (PST) From: npostavs@users.sourceforge.net To: Mark Oteiza Subject: Re: bug#24966: 26.0.50; test-completion with alist COLLECTION calls PREDICATE incorrectly References: <87shqnpxym.fsf@udel.edu> <87fumljw98.fsf@users.sourceforge.net> <87eg1wisck.fsf_-_@users.sourceforge.net> <20161128205917.GA17197@holos.localdomain> Date: Mon, 28 Nov 2016 22:31:32 -0500 In-Reply-To: (Noam Postavsky's message of "Mon, 28 Nov 2016 16:03:29 -0500") Message-ID: <878ts3hsh7.fsf@users.sourceforge.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 0.5 (/) X-Debbugs-Envelope-To: 24966 Cc: 24966@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.5 (/) --=-=-= Content-Type: text/plain Noam Postavsky writes: > On Mon, Nov 28, 2016 at 3:59 PM, Mark Oteiza wrote: >>> >>> npostavs@users.sourceforge.net writes: >>> > >>> > I tentatively suggest the patch below, but I want to add some tests >>> > before commiting anything. >>> >>> While adding tests, I found another inconsistency: when given a >>> hashtable with symbol keys, test-completion passes the symbol-name to >>> PREDICATE, while all-completions and try-completion pass the original >>> symbol key. Here are two patches, the first for this bug, and the >>> second for the other inconsistency. >> >> The first hunk of 2/2 isn't applying here. > > Oh, that's probably because I generated it with -w, so some whitespace > changes are missing in 1/2. I'll post a full patch tonight. Here are the same patches with full whitespace changes. --=-=-= Content-Type: text/plain Content-Disposition: attachment; filename=v1-0001-Give-test-completion-s-PREDICATE-full-alist-entry.patch Content-Description: patch >From ba3f1477e66536fd759c4f7128bfbca009532b14 Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Sun, 27 Nov 2016 10:04:48 -0500 Subject: [PATCH v1 1/2] Give test-completion's PREDICATE full alist entry Since 2016-06-26 "Fix test-completion with completion-regexp-list", when calling test-completion with an alist collection, the predicate was recieving the string value instead of the alist entry (Bug#24966). * src/minibuf.c (Ftest_completion): Don't modify the found element, just test STRING against `completion-regexp-list'. * test/src/minibuf-tests.el: New tests for `try-completion', `all-completions', and `test-completion'. --- src/minibuf.c | 8 +- test/src/minibuf-tests.el | 406 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 409 insertions(+), 5 deletions(-) create mode 100644 test/src/minibuf-tests.el diff --git a/src/minibuf.c b/src/minibuf.c index 57eea05..6c694cb 100644 --- a/src/minibuf.c +++ b/src/minibuf.c @@ -1686,8 +1686,6 @@ DEFUN ("test-completion", Ftest_completion, Stest_completion, 2, 3, 0, tem = Fassoc_string (string, collection, completion_ignore_case ? Qt : Qnil); if (NILP (tem)) return Qnil; - else if (CONSP (tem)) - tem = XCAR (tem); } else if (VECTORP (collection)) { @@ -1770,9 +1768,9 @@ DEFUN ("test-completion", Ftest_completion, Stest_completion, 2, 3, 0, for (regexps = Vcompletion_regexp_list; CONSP (regexps); regexps = XCDR (regexps)) { - if (NILP (Fstring_match (XCAR (regexps), - SYMBOLP (tem) ? string : tem, - Qnil))) + /* We can test against STRING, because if we got here, then + the element is equivalent to it. */ + if (NILP (Fstring_match (XCAR (regexps), string, Qnil))) return unbind_to (count, Qnil); } unbind_to (count, Qnil); diff --git a/test/src/minibuf-tests.el b/test/src/minibuf-tests.el new file mode 100644 index 0000000..98b8614 --- /dev/null +++ b/test/src/minibuf-tests.el @@ -0,0 +1,406 @@ +;;; minibuf-tests.el --- tests for minibuf.c functions -*- lexical-binding: t -*- + +;; Copyright (C) 2016 Free Software Foundation, Inc. + +;; This file is part of GNU Emacs. + +;; GNU Emacs is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; GNU Emacs is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs. If not, see . + +;;; Code: + +(require 'ert) + + +;;; Support functions for `try-completion', `all-completion', and +;;; `test-completion' tests. + +(defun minibuf-tests--strings-to-symbol-list (list) + (mapcar #'intern list)) +(defun minibuf-tests--strings-to-symbol-alist (list) + (let ((num 0)) + (mapcar (lambda (str) (cons (intern str) (cl-incf num))) list))) +(defun minibuf-tests--strings-to-string-alist (list) + (let ((num 0)) + (mapcar (lambda (str) (cons str (cl-incf num))) list))) +(defun minibuf-tests--strings-to-obarray (list) + (let ((ob (make-vector 7 0))) + (mapc (lambda (str) (intern str ob)) list) + ob)) +(defun minibuf-tests--strings-to-string-hashtable (list) + (let ((ht (make-hash-table :test #'equal)) + (num 0)) + (mapc (lambda (str) (puthash str (cl-incf num) ht)) list) + ht)) +(defun minibuf-tests--strings-to-symbol-hashtable (list) + (let ((ht (make-hash-table :test #'equal)) + (num 0)) + (mapc (lambda (str) (puthash (intern str) (cl-incf num) ht)) list) + ht)) + +;;; Functions that produce a predicate (for *-completion functions) +;;; which always returns non-nil for a given collection. + +(defun minibuf-tests--memq-of-collection (collection) + (lambda (elt) (memq elt collection))) +(defun minibuf-tests--part-of-obarray (ob) + (lambda (sym) (eq (intern-soft (symbol-name sym) ob) sym))) +(defun minibuf-tests--part-of-hashtable (table) + (lambda (k v) (equal (gethash k table) v))) + + +;;; Testing functions that are agnostic to type of COLLECTION. + +(defun minibuf-tests--try-completion (xform-collection) + (let* ((abcdef (funcall xform-collection '("abc" "def"))) + (+abba (funcall xform-collection '("abc" "abba" "def")))) + (should (equal (try-completion "a" abcdef) "abc")) + (should (equal (try-completion "a" +abba) "ab")) + (should (equal (try-completion "abc" +abba) t)) + (should (equal (try-completion "abcd" +abba) nil)))) + +(defun minibuf-tests--try-completion-pred (xform-collection collection-member) + (let* ((abcdef (funcall xform-collection '("abc" "def"))) + (abcdef-member (funcall collection-member abcdef)) + (+abba (funcall xform-collection '("abc" "abba" "def"))) + (+abba-member (funcall collection-member +abba))) + (should (equal (try-completion "a" abcdef abcdef-member) "abc")) + (should (equal (try-completion "a" +abba +abba-member) "ab")) + (should (equal (try-completion "abc" +abba +abba-member) t)) + (should (equal (try-completion "abcd" +abba +abba-member) nil)) + (should-not (try-completion "a" abcdef #'ignore)) + (should-not (try-completion "a" +abba #'ignore)) + (should-not (try-completion "abc" +abba #'ignore)) + (should-not (try-completion "abcd" +abba #'ignore)))) + +(defun minibuf-tests--try-completion-regexp (xform-collection) + (let ((abcdef (funcall xform-collection '("abc" "def"))) + (+abba (funcall xform-collection '("abc" "abba" "def")))) + (let ((completion-regexp-list '("."))) + (should (equal (try-completion "a" abcdef) "abc")) + (should (equal (try-completion "a" +abba) "ab")) + (should (equal (try-completion "abc" +abba) t)) + (should (equal (try-completion "abcd" +abba) nil))) + (let ((completion-regexp-list '("X"))) + (should-not (try-completion "a" abcdef)) + (should-not (try-completion "a" +abba)) + (should-not (try-completion "abc" +abba)) + (should-not (try-completion "abcd" +abba))))) + +(defun minibuf-tests--all-completions (xform-collection) + (let* ((abcdef (funcall xform-collection '("abc" "def"))) + (+abba (funcall xform-collection '("abc" "abba" "def")))) + (should (equal (all-completions "a" abcdef) '("abc"))) + (should (equal (all-completions "a" +abba) '("abc" "abba"))) + (should (equal (all-completions "abc" +abba) '("abc"))) + (should (equal (all-completions "abcd" +abba) nil)))) + +(defun minibuf-tests--all-completions-pred (xform-collection collection-member) + (let* ((abcdef (funcall xform-collection '("abc" "def"))) + (abcdef-member (funcall collection-member abcdef)) + (+abba (funcall xform-collection '("abc" "abba" "def"))) + (+abba-member (funcall collection-member +abba))) + (should (equal (all-completions "a" abcdef abcdef-member) '("abc"))) + (should (equal (all-completions "a" +abba +abba-member) '("abc" "abba"))) + (should (equal (all-completions "abc" +abba +abba-member) '("abc"))) + (should (equal (all-completions "abcd" +abba +abba-member) nil)) + (should-not (all-completions "a" abcdef #'ignore)) + (should-not (all-completions "a" +abba #'ignore)) + (should-not (all-completions "abc" +abba #'ignore)) + (should-not (all-completions "abcd" +abba #'ignore)))) + +(defun minibuf-tests--all-completions-regexp (xform-collection) + (let ((abcdef (funcall xform-collection '("abc" "def"))) + (+abba (funcall xform-collection '("abc" "abba" "def")))) + (let ((completion-regexp-list '("."))) + (should (equal (all-completions "a" abcdef) '("abc"))) + (should (equal (all-completions "a" +abba) '("abc" "abba"))) + (should (equal (all-completions "abc" +abba) '("abc"))) + (should (equal (all-completions "abcd" +abba) nil))) + (let ((completion-regexp-list '("X"))) + (should-not (all-completions "a" abcdef)) + (should-not (all-completions "a" +abba)) + (should-not (all-completions "abc" +abba)) + (should-not (all-completions "abcd" +abba))))) + +(defun minibuf-tests--test-completion (xform-collection) + (let* ((abcdef (funcall xform-collection '("abc" "def"))) + (+abba (funcall xform-collection '("abc" "abba" "def")))) + (should (test-completion "abc" abcdef)) + (should (test-completion "def" +abba)) + (should (test-completion "abba" +abba)) + (should-not (test-completion "abcd" +abba)))) + +(defun minibuf-tests--test-completion-pred (xform-collection collection-member) + (let* ((abcdef (funcall xform-collection '("abc" "def"))) + (abcdef-member (funcall collection-member abcdef)) + (+abba (funcall xform-collection '("abc" "abba" "def"))) + (+abba-member (funcall collection-member +abba))) + (should (test-completion "abc" abcdef abcdef-member)) + (should (test-completion "def" +abba +abba-member)) + (should (test-completion "abba" +abba +abba-member)) + (should-not (test-completion "abcd" +abba +abba-member)) + (should-not (test-completion "abc" abcdef #'ignore)) + (should-not (test-completion "def" +abba #'ignore)) + (should-not (test-completion "abba" +abba #'ignore)) + (should-not (test-completion "abcd" +abba #'ignore)))) + +(defun minibuf-tests--test-completion-regexp (xform-collection) + (let ((abcdef (funcall xform-collection '("abc" "def"))) + (+abba (funcall xform-collection '("abc" "abba" "def")))) + (let ((completion-regexp-list '("."))) + (should (test-completion "abc" abcdef)) + (should (test-completion "def" +abba)) + (should (test-completion "abba" +abba)) + (should-not (test-completion "abcd" +abba))) + (let ((completion-regexp-list '("X"))) + (should-not (test-completion "abc" abcdef)) + (should-not (test-completion "def" +abba)) + (should-not (test-completion "abba" +abba)) + (should-not (test-completion "abcd" +abba))))) + + +;;; Tests for `try-completion'. +(ert-deftest try-completion-string-list () + (minibuf-tests--try-completion #'identity)) +(ert-deftest try-completion-string-list-predicate () + (minibuf-tests--try-completion-pred + #'identity #'minibuf-tests--memq-of-collection)) +(ert-deftest try-completion-string-list-completion-regexp () + (minibuf-tests--try-completion-regexp #'identity)) + +(ert-deftest try-completion-symbol-list () + (minibuf-tests--try-completion + #'minibuf-tests--strings-to-symbol-list)) +(ert-deftest try-completion-symbol-list-predicate () + (minibuf-tests--try-completion-pred + #'minibuf-tests--strings-to-symbol-list + #'minibuf-tests--memq-of-collection)) +(ert-deftest try-completion-symbol-list-completion-regexp () + (minibuf-tests--try-completion-regexp + #'minibuf-tests--strings-to-symbol-list)) + +(ert-deftest try-completion-symbol-alist () + (minibuf-tests--try-completion + #'minibuf-tests--strings-to-symbol-alist)) +(ert-deftest try-completion-symbol-alist-predicate () + (minibuf-tests--try-completion-pred + #'minibuf-tests--strings-to-symbol-alist + #'minibuf-tests--memq-of-collection)) +(ert-deftest try-completion-symbol-alist-completion-regexp () + (minibuf-tests--try-completion-regexp + #'minibuf-tests--strings-to-symbol-alist)) + +(ert-deftest try-completion-string-alist () + (minibuf-tests--try-completion + #'minibuf-tests--strings-to-string-alist)) +(ert-deftest try-completion-string-alist-predicate () + (minibuf-tests--try-completion-pred + #'minibuf-tests--strings-to-string-alist + #'minibuf-tests--memq-of-collection)) +(ert-deftest try-completion-string-alist-completion-regexp () + (minibuf-tests--try-completion-regexp + #'minibuf-tests--strings-to-string-alist)) + +(ert-deftest try-completion-obarray () + (minibuf-tests--try-completion + #'minibuf-tests--strings-to-obarray)) +(ert-deftest try-completion-obarray-predicate () + (minibuf-tests--try-completion-pred + #'minibuf-tests--strings-to-obarray + #'minibuf-tests--part-of-obarray)) +(ert-deftest try-completion-obarray-completion-regexp () + (minibuf-tests--try-completion-regexp + #'minibuf-tests--strings-to-obarray)) + +(ert-deftest try-completion-string-hashtable () + (minibuf-tests--try-completion + #'minibuf-tests--strings-to-string-hashtable)) +(ert-deftest try-completion-string-hashtable-predicate () + (minibuf-tests--try-completion-pred + #'minibuf-tests--strings-to-string-hashtable + #'minibuf-tests--part-of-hashtable)) +(ert-deftest try-completion-string-hashtable-completion-regexp () + (minibuf-tests--try-completion-regexp + #'minibuf-tests--strings-to-string-hashtable)) + +(ert-deftest try-completion-symbol-hashtable () + (minibuf-tests--try-completion + #'minibuf-tests--strings-to-symbol-hashtable)) +(ert-deftest try-completion-symbol-hashtable-predicate () + (minibuf-tests--try-completion-pred + #'minibuf-tests--strings-to-symbol-hashtable + #'minibuf-tests--part-of-hashtable)) +(ert-deftest try-completion-symbol-hashtable-completion-regexp () + (minibuf-tests--try-completion-regexp + #'minibuf-tests--strings-to-symbol-hashtable)) + + +;;; Tests for `all-completions'. + +(ert-deftest all-completions-string-list () + (minibuf-tests--all-completions #'identity)) +(ert-deftest all-completions-string-list-predicate () + (minibuf-tests--all-completions-pred + #'identity #'minibuf-tests--memq-of-collection)) +(ert-deftest all-completions-string-list-completion-regexp () + (minibuf-tests--all-completions-regexp #'identity)) + +(ert-deftest all-completions-symbol-list () + (minibuf-tests--all-completions + #'minibuf-tests--strings-to-symbol-list)) +(ert-deftest all-completions-symbol-list-predicate () + (minibuf-tests--all-completions-pred + #'minibuf-tests--strings-to-symbol-list + #'minibuf-tests--memq-of-collection)) +(ert-deftest all-completions-symbol-list-completion-regexp () + (minibuf-tests--all-completions-regexp + #'minibuf-tests--strings-to-symbol-list)) + +(ert-deftest all-completions-symbol-alist () + (minibuf-tests--all-completions + #'minibuf-tests--strings-to-symbol-alist)) +(ert-deftest all-completions-symbol-alist-predicate () + (minibuf-tests--all-completions-pred + #'minibuf-tests--strings-to-symbol-alist + #'minibuf-tests--memq-of-collection)) +(ert-deftest all-completions-symbol-alist-completion-regexp () + (minibuf-tests--all-completions-regexp + #'minibuf-tests--strings-to-symbol-alist)) + +(ert-deftest all-completions-string-alist () + (minibuf-tests--all-completions + #'minibuf-tests--strings-to-string-alist)) +(ert-deftest all-completions-string-alist-predicate () + (minibuf-tests--all-completions-pred + #'minibuf-tests--strings-to-string-alist + #'minibuf-tests--memq-of-collection)) +(ert-deftest all-completions-string-alist-completion-regexp () + (minibuf-tests--all-completions-regexp + #'minibuf-tests--strings-to-string-alist)) + +(ert-deftest all-completions-obarray () + (minibuf-tests--all-completions + #'minibuf-tests--strings-to-obarray)) +(ert-deftest all-completions-obarray-predicate () + (minibuf-tests--all-completions-pred + #'minibuf-tests--strings-to-obarray + #'minibuf-tests--part-of-obarray)) +(ert-deftest all-completions-obarray-completion-regexp () + (minibuf-tests--all-completions-regexp + #'minibuf-tests--strings-to-obarray)) + +(ert-deftest all-completions-string-hashtable () + (minibuf-tests--all-completions + #'minibuf-tests--strings-to-string-hashtable)) +(ert-deftest all-completions-string-hashtable-predicate () + (minibuf-tests--all-completions-pred + #'minibuf-tests--strings-to-string-hashtable + #'minibuf-tests--part-of-hashtable)) +(ert-deftest all-completions-string-hashtable-completion-regexp () + (minibuf-tests--all-completions-regexp + #'minibuf-tests--strings-to-string-hashtable)) + +(ert-deftest all-completions-symbol-hashtable () + (minibuf-tests--all-completions + #'minibuf-tests--strings-to-symbol-hashtable)) +(ert-deftest all-completions-symbol-hashtable-predicate () + (minibuf-tests--all-completions-pred + #'minibuf-tests--strings-to-symbol-hashtable + #'minibuf-tests--part-of-hashtable)) +(ert-deftest all-completions-symbol-hashtable-completion-regexp () + (minibuf-tests--all-completions-regexp + #'minibuf-tests--strings-to-symbol-hashtable)) + + +;;; Tests for `test-completion'. + +(ert-deftest test-completion-string-list () + (minibuf-tests--test-completion #'identity)) +(ert-deftest test-completion-string-list-predicate () + (minibuf-tests--test-completion-pred + #'identity #'minibuf-tests--memq-of-collection)) +(ert-deftest test-completion-string-list-completion-regexp () + (minibuf-tests--test-completion-regexp #'identity)) + +(ert-deftest test-completion-symbol-list () + (minibuf-tests--test-completion + #'minibuf-tests--strings-to-symbol-list)) +(ert-deftest test-completion-symbol-list-predicate () + (minibuf-tests--test-completion-pred + #'minibuf-tests--strings-to-symbol-list + #'minibuf-tests--memq-of-collection)) +(ert-deftest test-completion-symbol-list-completion-regexp () + (minibuf-tests--test-completion-regexp + #'minibuf-tests--strings-to-symbol-list)) + +(ert-deftest test-completion-symbol-alist () + (minibuf-tests--test-completion + #'minibuf-tests--strings-to-symbol-alist)) +(ert-deftest test-completion-symbol-alist-predicate () + (minibuf-tests--test-completion-pred + #'minibuf-tests--strings-to-symbol-alist + #'minibuf-tests--memq-of-collection)) +(ert-deftest test-completion-symbol-alist-completion-regexp () + (minibuf-tests--test-completion-regexp + #'minibuf-tests--strings-to-symbol-alist)) + +(ert-deftest test-completion-string-alist () + (minibuf-tests--test-completion + #'minibuf-tests--strings-to-string-alist)) +(ert-deftest test-completion-string-alist-predicate () + (minibuf-tests--test-completion-pred + #'minibuf-tests--strings-to-string-alist + #'minibuf-tests--memq-of-collection)) +(ert-deftest test-completion-string-alist-completion-regexp () + (minibuf-tests--test-completion-regexp + #'minibuf-tests--strings-to-string-alist)) + +(ert-deftest test-completion-obarray () + (minibuf-tests--test-completion + #'minibuf-tests--strings-to-obarray)) +(ert-deftest test-completion-obarray-predicate () + (minibuf-tests--test-completion-pred + #'minibuf-tests--strings-to-obarray + #'minibuf-tests--part-of-obarray)) +(ert-deftest test-completion-obarray-completion-regexp () + (minibuf-tests--test-completion-regexp + #'minibuf-tests--strings-to-obarray)) + +(ert-deftest test-completion-string-hashtable () + (minibuf-tests--test-completion + #'minibuf-tests--strings-to-string-hashtable)) +(ert-deftest test-completion-string-hashtable-predicate () + (minibuf-tests--test-completion-pred + #'minibuf-tests--strings-to-string-hashtable + #'minibuf-tests--part-of-hashtable)) +(ert-deftest test-completion-string-hashtable-completion-regexp () + (minibuf-tests--test-completion-regexp + #'minibuf-tests--strings-to-string-hashtable)) + +(ert-deftest test-completion-symbol-hashtable () + (minibuf-tests--test-completion + #'minibuf-tests--strings-to-symbol-hashtable)) +(ert-deftest test-completion-symbol-hashtable-predicate () + (minibuf-tests--test-completion-pred + #'minibuf-tests--strings-to-symbol-hashtable + ;; The predicate recieves a string as the key in this case. + (lambda (table) + (let ((in-table (minibuf-tests--part-of-hashtable table))) + (lambda (k v) (funcall in-table (intern k) v)))))) +(ert-deftest test-completion-symbol-hashtable-completion-regexp () + (minibuf-tests--test-completion-regexp + #'minibuf-tests--strings-to-symbol-hashtable)) + + +;;; minibuf-tests.el ends here -- 2.9.3 --=-=-= Content-Type: text/plain Content-Disposition: attachment; filename=v1-0002-Give-test-completion-s-PREDICATE-the-hashtable-ke.patch Content-Description: patch >From 6b587c804c6a98b30de984e58e56b9ba3794810a Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Sun, 27 Nov 2016 14:41:02 -0500 Subject: [PATCH v1 2/2] Give test-completion's PREDICATE the hashtable key For hashtable entries with symbol keys, `test-completion' would convert the key to a string before calling PREDICATE, unlike `try-completion' and `all-completions'. * src/minibuf.c (Ftest_completion): Pass original key from hashtable. --- src/minibuf.c | 33 +++++++++++++++++---------------- test/src/minibuf-tests.el | 5 +---- 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/src/minibuf.c b/src/minibuf.c index 6c694cb..7c5af34 100644 --- a/src/minibuf.c +++ b/src/minibuf.c @@ -1736,26 +1736,27 @@ DEFUN ("test-completion", Ftest_completion, Stest_completion, 2, 3, 0, else if (HASH_TABLE_P (collection)) { struct Lisp_Hash_Table *h = XHASH_TABLE (collection); - Lisp_Object key = Qnil; i = hash_lookup (h, string, NULL); if (i >= 0) - tem = HASH_KEY (h, i); + { + tem = HASH_KEY (h, i); + goto found_matching_key; + } else for (i = 0; i < HASH_TABLE_SIZE (h); ++i) - if (!NILP (HASH_HASH (h, i)) - && (key = HASH_KEY (h, i), - SYMBOLP (key) ? key = Fsymbol_name (key) : key, - STRINGP (key)) - && EQ (Fcompare_strings (string, make_number (0), Qnil, - key, make_number (0) , Qnil, - completion_ignore_case ? Qt : Qnil), - Qt)) - { - tem = key; - break; - } - if (!STRINGP (tem)) - return Qnil; + { + if (NILP (HASH_HASH (h, i))) continue; + tem = HASH_KEY (h, i); + Lisp_Object strkey = (SYMBOLP (tem) ? Fsymbol_name (tem) : tem); + if (!STRINGP (strkey)) continue; + if (EQ (Fcompare_strings (string, Qnil, Qnil, + strkey, Qnil, Qnil, + completion_ignore_case ? Qt : Qnil), + Qt)) + goto found_matching_key; + } + return Qnil; + found_matching_key: ; } else return call3 (collection, string, predicate, Qlambda); diff --git a/test/src/minibuf-tests.el b/test/src/minibuf-tests.el index 98b8614..82ac037 100644 --- a/test/src/minibuf-tests.el +++ b/test/src/minibuf-tests.el @@ -394,10 +394,7 @@ minibuf-tests--test-completion-regexp (ert-deftest test-completion-symbol-hashtable-predicate () (minibuf-tests--test-completion-pred #'minibuf-tests--strings-to-symbol-hashtable - ;; The predicate recieves a string as the key in this case. - (lambda (table) - (let ((in-table (minibuf-tests--part-of-hashtable table))) - (lambda (k v) (funcall in-table (intern k) v)))))) + #'minibuf-tests--part-of-hashtable)) (ert-deftest test-completion-symbol-hashtable-completion-regexp () (minibuf-tests--test-completion-regexp #'minibuf-tests--strings-to-symbol-hashtable)) -- 2.9.3 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Tue Nov 29 21:04:24 2016 Received: (at 24966) by debbugs.gnu.org; 30 Nov 2016 02:04:24 +0000 Received: from localhost ([127.0.0.1]:46704 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cBuG0-00009v-42 for submit@debbugs.gnu.org; Tue, 29 Nov 2016 21:04:24 -0500 Received: from mail-qk0-f178.google.com ([209.85.220.178]:34567) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cBuFy-00009j-Fm for 24966@debbugs.gnu.org; Tue, 29 Nov 2016 21:04:23 -0500 Received: by mail-qk0-f178.google.com with SMTP id q130so7959679qke.1 for <24966@debbugs.gnu.org>; Tue, 29 Nov 2016 18:04:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=udel-edu.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=xsMpXEsb+oO7mO5UEabXWnc1W6oarsbZEeE4uTgLg3g=; b=VcWNIUUgPNA8iyqUYeD9OWJeLm5YvTkoaHGsqyRbgBDgG/6I+zZS9Mrpt7GiQ4j3ab ezPTdIkTlbDVEkWb5YRG6By20wZSpjsesZy/w/V1I3lZPR6YBWSoXbHJKKlfxUSv1KML 4jpqnppT4jiaddoJ8u5O8KdyhXVAJUJ77Qguy44yVH+VEo0nqmmGz0cCOKIxIyyBHz3X LzB6D3YrhEN19hgov+76VuWvdILY+mXChh0MzSorXpFW4roU4e2lHCyq3u7eduiKIwHM b0ZWeiO8dY5hKzGIo1ebAwiPzFnPPlQ3FAODp9+U74jR1KdHyXWL2LqAfeTIZCIZD8qt Vc1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=xsMpXEsb+oO7mO5UEabXWnc1W6oarsbZEeE4uTgLg3g=; b=akyzMxcjm4OqIa6qzisNRvBaT2IfIPe5uV6PteLh+z4BIcIDEr8KWwVMkNK0L3HYjF ctgwKZoja3bQFFslch34xHmPW15uB4YHFw00RXpeQMeR7RqFTzTpsSW1OmVkykGSw9Fs fYo+vUmQxID4YhfbLmNG38f+3jWPUXG3ujQU+l8XPfBCCprHOWVv9gCSxIfd/kOpEvJF ohJQkF7WrZ2K72rVGAk2iLaZhLNWy6Gp0mE4YPo+tCiY7amS6zIRjgx5wP9Nyn44OcRQ E+cBQ694VdZq001wpTeYmKxlAwpczdBXasdIdmzGKaynutG7S6P3sdMKs3wosDT8EDAG oA9w== X-Gm-Message-State: AKaTC00ep/xrA851EVLDepmmLkQz08z7lgLgz6LgACy5NCFA3CzfUoXQ0JAfzUAxR/+wkOHe X-Received: by 10.55.74.1 with SMTP id x1mr28886809qka.316.1480471456961; Tue, 29 Nov 2016 18:04:16 -0800 (PST) Received: from holos.localdomain ([69.250.222.218]) by smtp.gmail.com with ESMTPSA id 33sm32319895qtq.1.2016.11.29.18.04.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 Nov 2016 18:04:15 -0800 (PST) Received: by holos.localdomain (Postfix, from userid 1000) id 3504860D62; Tue, 29 Nov 2016 21:04:15 -0500 (EST) Date: Tue, 29 Nov 2016 21:04:15 -0500 From: Mark Oteiza To: npostavs@users.sourceforge.net Subject: Re: bug#24966: 26.0.50; test-completion with alist COLLECTION calls PREDICATE incorrectly Message-ID: <20161130020415.GA23610@holos.localdomain> References: <87shqnpxym.fsf@udel.edu> <87fumljw98.fsf@users.sourceforge.net> <87eg1wisck.fsf_-_@users.sourceforge.net> <20161128205917.GA17197@holos.localdomain> <878ts3hsh7.fsf@users.sourceforge.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <878ts3hsh7.fsf@users.sourceforge.net> User-Agent: Mutt/1.7.1+60 (b22c5d0e299d) (2016-10-04) X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 24966 Cc: 24966@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) On 28/11/16 at 10:31pm, npostavs@users.sourceforge.net wrote: > Noam Postavsky writes: > > > On Mon, Nov 28, 2016 at 3:59 PM, Mark Oteiza wrote: > >>> > >>> npostavs@users.sourceforge.net writes: > >>> > > >>> > I tentatively suggest the patch below, but I want to add some tests > >>> > before commiting anything. > >>> > >>> While adding tests, I found another inconsistency: when given a > >>> hashtable with symbol keys, test-completion passes the symbol-name to > >>> PREDICATE, while all-completions and try-completion pass the original > >>> symbol key. Here are two patches, the first for this bug, and the > >>> second for the other inconsistency. > >> > >> The first hunk of 2/2 isn't applying here. > > > > Oh, that's probably because I generated it with -w, so some whitespace > > changes are missing in 1/2. I'll post a full patch tonight. > > Here are the same patches with full whitespace changes. Thanks, all is well here with these patches From debbugs-submit-bounces@debbugs.gnu.org Mon Dec 05 20:50:48 2016 Received: (at 24966) by debbugs.gnu.org; 6 Dec 2016 01:50:48 +0000 Received: from localhost ([127.0.0.1]:57509 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cE4u8-0002gT-4l for submit@debbugs.gnu.org; Mon, 05 Dec 2016 20:50:48 -0500 Received: from mail-qk0-f169.google.com ([209.85.220.169]:34138) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cE4u6-0002gG-0v for 24966@debbugs.gnu.org; Mon, 05 Dec 2016 20:50:46 -0500 Received: by mail-qk0-f169.google.com with SMTP id q130so178456375qke.1 for <24966@debbugs.gnu.org>; Mon, 05 Dec 2016 17:50:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=udel-edu.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=6icTuByubtECY+/RmwUwuIDo3f/RSq3LnEc07YrKxbc=; b=JtwseyDcThDX19CrMhB9jw+mNJSQEQsUra4VTc5+yNKupPIFh7/dq/h2cDCi/A0BVz iKYSksP7DnLpeGZESbNXfuGf64G8ju9kpY1fUGrc9p4CBpg7FF0ppcpD8hJeLaO9ghqi anerqHzVNWvS0TsE7Ui58RyGT+N2SOjwrci98P9rdytBOyCRzyZuobHHZlIqsmU1kawo xsFLTe5/rLpVCriVn2lj4FDolMDlr2w5uaCSl7Uy4QWTlNZjh5SbWF3VcmBEqaeGCptI QE8jJCIkn7B90sdxh+7OtQS7ejvEYNIGcHo9nKO8536bnNgx1yC/8P6g3OHReaqCcLZe ynZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=6icTuByubtECY+/RmwUwuIDo3f/RSq3LnEc07YrKxbc=; b=XNjK+1k6FdAsrkpl3S1kaLt5khzDD6drtvqojrcmdQc4p4rrQAMOa5vn5kHBPI9Gn7 0O+NY6NwIuxNqYoNPXW6q05MYchX8YurF0V7i8fsaiHPkRH1G1ndkaxBY5CDi0zKUeib g0S0uWV9Ch2VwrcpPCbf6KGK40z8UF6yrc1HTP+5ZQnKSpIwmudwKmlwrf5R8wfZuPn0 2jBh/H7116MtdehPMbuGzb4OQuVka7lyk+8qwtGysQfUFHED8963S3lHtvbTB2LIIILj 8aA4xlA4unVpDyMygIa6JEInVvxX+d/xXnp68iapa2tKDz4O/7tWzZt3O4Qj8nwsKH8J XJsw== X-Gm-Message-State: AKaTC02gUENnTJ9fFJViFx0M+9ABTZbE/QisDozbdoMHoGeXiGjrLqPcPvL/jSOd0eS4OsX2 X-Received: by 10.55.175.198 with SMTP id y189mr50429840qke.293.1480989040284; Mon, 05 Dec 2016 17:50:40 -0800 (PST) Received: from holos.localdomain ([69.250.222.218]) by smtp.gmail.com with ESMTPSA id r15sm10865485qte.9.2016.12.05.17.50.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Dec 2016 17:50:39 -0800 (PST) Received: by holos.localdomain (Postfix, from userid 1000) id 5923660D63; Mon, 5 Dec 2016 20:50:38 -0500 (EST) Date: Mon, 5 Dec 2016 20:50:38 -0500 From: Mark Oteiza To: npostavs@users.sourceforge.net Subject: Re: bug#24966: 26.0.50; test-completion with alist COLLECTION calls PREDICATE incorrectly Message-ID: <20161206015038.GA25281@holos.localdomain> References: <87shqnpxym.fsf@udel.edu> <87fumljw98.fsf@users.sourceforge.net> <87eg1wisck.fsf_-_@users.sourceforge.net> <20161128205917.GA17197@holos.localdomain> <878ts3hsh7.fsf@users.sourceforge.net> <20161130020415.GA23610@holos.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20161130020415.GA23610@holos.localdomain> User-Agent: Mutt/1.7.1+65 (d6c10244793f) (2016-10-04) X-Spam-Score: 0.5 (/) X-Debbugs-Envelope-To: 24966 Cc: 24966@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.5 (/) On 29/11/16 at 09:04pm, Mark Oteiza wrote: > On 28/11/16 at 10:31pm, npostavs@users.sourceforge.net wrote: > > Noam Postavsky writes: > > > > > On Mon, Nov 28, 2016 at 3:59 PM, Mark Oteiza wrote: > > >>> > > >>> npostavs@users.sourceforge.net writes: > > >>> > > > >>> > I tentatively suggest the patch below, but I want to add some tests > > >>> > before commiting anything. > > >>> > > >>> While adding tests, I found another inconsistency: when given a > > >>> hashtable with symbol keys, test-completion passes the symbol-name to > > >>> PREDICATE, while all-completions and try-completion pass the original > > >>> symbol key. Here are two patches, the first for this bug, and the > > >>> second for the other inconsistency. > > >> > > >> The first hunk of 2/2 isn't applying here. > > > > > > Oh, that's probably because I generated it with -w, so some whitespace > > > changes are missing in 1/2. I'll post a full patch tonight. > > > > Here are the same patches with full whitespace changes. > > Thanks, all is well here with these patches Anything holding back applying these? From debbugs-submit-bounces@debbugs.gnu.org Tue Dec 06 22:30:43 2016 Received: (at 24966) by debbugs.gnu.org; 7 Dec 2016 03:30:43 +0000 Received: from localhost ([127.0.0.1]:58645 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cESwN-0007i9-6o for submit@debbugs.gnu.org; Tue, 06 Dec 2016 22:30:43 -0500 Received: from mail-io0-f174.google.com ([209.85.223.174]:34488) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cESwK-0007hk-Ee; Tue, 06 Dec 2016 22:30:40 -0500 Received: by mail-io0-f174.google.com with SMTP id c21so634973946ioj.1; Tue, 06 Dec 2016 19:30:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=ndpR9iCJUYVJtUIIt4h/hIujDn4u+vxwH5Sxvh4Xo/M=; b=As4N0OFezVo0pdzP8Ve4BlT3jTqdrMNBCtxdsBXYOwnsvhPNzGJjaUjSwv9GiVuN9E u/SghesJ86tPvzJnJ9jkx7TCkIaJGG9MG4Gu89UotOzVi0BIFd7aGrgoIZx0J0QVXuQ6 DwvEosBYGFfTtSjghF/FCmjeOzkSFI/hJfvAsuU1CH547lSCq/qPnoQ2KK7nGZRN8IQe H0s8cOgCrDqFYvkKxXleSLYIMx/DzQg/NKtjWRVNYG5PPiTt8JO9GyTJUYuCinUR8UU3 CYuZU5/ytjKRcECMFUFuEmGYsICwnjPhhbuSg+TPf0bfafbaMh0C3H9xqnlIpZzBW2Qn mB+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:references:date :in-reply-to:message-id:user-agent:mime-version; bh=ndpR9iCJUYVJtUIIt4h/hIujDn4u+vxwH5Sxvh4Xo/M=; b=YgQJPGh0hA6CaJaY/r3gKekOw7Qe20w12TH50uiXI7x5lOc8Mil2NdDt53pBDi56qj mBBOHioQHEPG86a5vNtu8GKzT3XfSOrsMCIydPGoXR6wAyPTUeybzWin5gOvxkW028Ez 6qzkKPX8ZljEfVPl28m6g4kC+mc0emhBJlxozDN7jXjNaPvhfzztWfGamhJqdDBDW1U6 gfUYk4oZ/62qgU/ZMi+ItykT0Gy7OLWNtNjCNedmRT70q2MzQu32syVkVxPgC5ssIuBJ BM1MgM8xaq7wYpYdsAeQsyeoSyzUY0HdpnCqFfQxYUc8ko9A/Z1Lnab7cN1rjFpbeEgz 1Y8A== X-Gm-Message-State: AKaTC01VkC3zzqLdBfDJwdW2tjktapz/1v0dlp0GmBIZN2tW6koAnQBzOAYPZwW4eQKS2Q== X-Received: by 10.36.80.74 with SMTP id m71mr504585itb.122.1481081434572; Tue, 06 Dec 2016 19:30:34 -0800 (PST) Received: from zony ([45.2.7.65]) by smtp.googlemail.com with ESMTPSA id i200sm2689773itb.0.2016.12.06.19.30.33 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 06 Dec 2016 19:30:34 -0800 (PST) From: npostavs@users.sourceforge.net To: Mark Oteiza Subject: Re: bug#24966: 26.0.50; test-completion with alist COLLECTION calls PREDICATE incorrectly References: <87shqnpxym.fsf@udel.edu> <87fumljw98.fsf@users.sourceforge.net> <87eg1wisck.fsf_-_@users.sourceforge.net> <20161128205917.GA17197@holos.localdomain> <878ts3hsh7.fsf@users.sourceforge.net> <20161130020415.GA23610@holos.localdomain> <20161206015038.GA25281@holos.localdomain> Date: Tue, 06 Dec 2016 22:31:34 -0500 In-Reply-To: <20161206015038.GA25281@holos.localdomain> (Mark Oteiza's message of "Mon, 5 Dec 2016 20:50:38 -0500") Message-ID: <87lgvsfm95.fsf@users.sourceforge.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.2 (/) X-Debbugs-Envelope-To: 24966 Cc: 24966@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.2 (/) tags 24966 fixed close 24966 quit Mark Oteiza writes: > On 29/11/16 at 09:04pm, Mark Oteiza wrote: >> > >>> >> > >>> npostavs@users.sourceforge.net writes: >> > >>> >> > >>> While adding tests, I found another inconsistency: when given a >> > >>> hashtable with symbol keys, test-completion passes the symbol-name to >> > >>> PREDICATE, while all-completions and try-completion pass the original >> > >>> symbol key. Here are two patches, the first for this bug, and the >> > >>> second for the other inconsistency. >> >> Thanks, all is well here with these patches > > Anything holding back applying these? I was waiting to see if there were any comments, especially about the second patch, but it's been long enough by now. Pushed as 60fe6301, 2a3420d9. From unknown Sat Jun 21 10:37:49 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Wed, 04 Jan 2017 12:24:05 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator