From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#36486: [PATCH] Add tests for text-property-search to check prop-match-value Date: Fri, 12 Jul 2019 01:08:06 +0300 Organization: LINKOV.NET Message-ID: <87muhkw7l9.fsf@mail.linkov.net> References: <87pnmndyu8.fsf@mouse.gnus.org> <87pnmlzbzt.fsf@mail.linkov.net> <874l3w5jwy.fsf@mail.linkov.net> <87r26zgdbq.fsf@mail.linkov.net> <87o921mskm.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="128145"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (x86_64-pc-linux-gnu) Cc: 36486@debbugs.gnu.org, Stefan Kangas To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Jul 12 00:09:12 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hlhFV-000XA9-Ii for geb-bug-gnu-emacs@m.gmane.org; Fri, 12 Jul 2019 00:09:10 +0200 Original-Received: from localhost ([::1]:45524 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hlhFT-0004FW-Gh for geb-bug-gnu-emacs@m.gmane.org; Thu, 11 Jul 2019 18:09:07 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:34091) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hlhFP-0004F8-NA for bug-gnu-emacs@gnu.org; Thu, 11 Jul 2019 18:09:04 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hlhFO-00039i-Iz for bug-gnu-emacs@gnu.org; Thu, 11 Jul 2019 18:09:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:58385) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hlhFO-00039S-5s for bug-gnu-emacs@gnu.org; Thu, 11 Jul 2019 18:09:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hlhFN-0005Zu-Vz for bug-gnu-emacs@gnu.org; Thu, 11 Jul 2019 18:09:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 11 Jul 2019 22:09:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 36486 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch fixed Original-Received: via spool by 36486-submit@debbugs.gnu.org id=B36486.156288292621416 (code B ref 36486); Thu, 11 Jul 2019 22:09:01 +0000 Original-Received: (at 36486) by debbugs.gnu.org; 11 Jul 2019 22:08:46 +0000 Original-Received: from localhost ([127.0.0.1]:38973 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hlhF8-0005ZM-61 for submit@debbugs.gnu.org; Thu, 11 Jul 2019 18:08:46 -0400 Original-Received: from fossa.birch.relay.mailchannels.net ([23.83.209.62]:3187) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hlhF6-0005ZE-TB for 36486@debbugs.gnu.org; Thu, 11 Jul 2019 18:08:45 -0400 X-Sender-Id: dreamhost|x-authsender|jurta@jurta.org Original-Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id BC4702C1FE4; Thu, 11 Jul 2019 22:08:43 +0000 (UTC) Original-Received: from pdx1-sub0-mail-a86.g.dreamhost.com (100-96-35-167.trex.outbound.svc.cluster.local [100.96.35.167]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 38FB32C1FEE; Thu, 11 Jul 2019 22:08:43 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|jurta@jurta.org Original-Received: from pdx1-sub0-mail-a86.g.dreamhost.com ([TEMPUNAVAIL]. [64.90.62.162]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384) by 0.0.0.0:2500 (trex/5.17.3); Thu, 11 Jul 2019 22:08:43 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|jurta@jurta.org X-MailChannels-Auth-Id: dreamhost X-Fumbling-Lonely: 267b650f08ce5c7e_1562882923599_1264750504 X-MC-Loop-Signature: 1562882923599:3803002218 X-MC-Ingress-Time: 1562882923599 Original-Received: from pdx1-sub0-mail-a86.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a86.g.dreamhost.com (Postfix) with ESMTP id 764D980EC0; Thu, 11 Jul 2019 15:08:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=linkov.net; h=from:to:cc :subject:in-reply-to:references:date:message-id:mime-version :content-type; s=linkov.net; bh=XJ51PvSN1DJxtadEuAzDW4Mz13Q=; b= 0+F8NY72XHlaAv0x9Trf25Qi1x3i92hzIZ2U3y98v63jnjM/3hMaQwoeSNqCmTrc VxId2pQ+DOG2FqPzewWTusiBP0bRnhT76xuBXoSuRAIGUe+YzjBQZkJslZNTNTUY DjuXxJqwco43NjVcOL+v8snAZkZzvtFTO+uWH1dm0N4= Original-Received: from mail.jurta.org (m91-129-110-101.cust.tele2.ee [91.129.110.101]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: jurta@jurta.org) by pdx1-sub0-mail-a86.g.dreamhost.com (Postfix) with ESMTPSA id B78ED80EBE; Thu, 11 Jul 2019 15:08:35 -0700 (PDT) X-DH-BACKEND: pdx1-sub0-mail-a86 In-Reply-To: (Lars Ingebrigtsen's message of "Thu, 11 Jul 2019 16:17:22 +0200") X-VR-OUT-STATUS: OK X-VR-OUT-SCORE: -100 X-VR-OUT-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgeduvddrgeelgddtjecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucggtfgfnhhsuhgsshgtrhhisggvpdfftffgtefojffquffvnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvffujghofhgffffkgggtsehmtderredtreejnecuhfhrohhmpefluhhrihcunfhinhhkohhvuceojhhurhhisehlihhnkhhovhdrnhgvtheqnecukfhppeeluddruddvledruddutddruddtudenucfrrghrrghmpehmohguvgepshhmthhppdhhvghlohepmhgrihhlrdhjuhhrthgrrdhorhhgpdhinhgvthepledurdduvdelrdduuddtrddutddupdhrvghtuhhrnhdqphgrthhhpefluhhrihcunfhinhhkohhvuceojhhurhhisehlihhnkhhovhdrnhgvtheqpdhmrghilhhfrhhomhepjhhurhhisehlihhnkhhovhdrnhgvthdpnhhrtghpthhtoheplhgrrhhsihesghhnuhhsrdhorhhgnecuvehluhhsthgvrhfuihiivgeptd X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:162737 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable >>> I don't understand -- this will still return a symbol. (And error ou= t >>> if you enter stuff like "foo bar".) >> >> Yes, entering a symbol returns a symbol, entering a string >> like "foo bar" returns a string "foo bar" literally. > > Oh, right. Hm. Well, entering things with "..." is very unusual in > Emacs prompts, so if we want that, the prompt should at least say that > that's what's expected... Fixed in the following patch. >> Currently text-property-search-forward has more problems: >> today I needed to search the property =E2=80=98face=E2=80=99 with the = value >> =E2=80=98hi-yellow=E2=80=99 in the buffer with regexps highlighted by = hi-lock.el. >> Executing interactively: >> >> M-x text-property-search-forward RET face RET hi-yellow RET >> >> failed to find the property because all hi-lock occurrences were >> combined with font-lock text properties, i.e. all they had the >> property =E2=80=98face=E2=80=99 with the value =E2=80=98(hi-yellow fon= t-lock-keyword-face)=E2=80=99 >> and text-property-search-forward fails to find a value in the list >> of values. > > Yes, you can't really use text-property-search-forward to do that in an= y > meaningful manner, which is why I didn't add that to the interactive > bit. It's a function useful almost only when programming, and the only > useful interactive thing is to vaguely poke around in the buffer. Implemented in this patch: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=text-property-search-value.3.patch diff --git a/lisp/emacs-lisp/text-property-search.el b/lisp/emacs-lisp/text-property-search.el index 41ca07057e..a44516992a 100644 --- a/lisp/emacs-lisp/text-property-search.el +++ b/lisp/emacs-lisp/text-property-search.el @@ -54,10 +54,13 @@ text-property-search-forward that's matching), and `prop-match-value' (the value of PROPERTY at the start of the region)." (interactive - (list - (let ((string (completing-read "Search for property: " obarray))) - (when (> (length string) 0) - (intern string obarray))))) + (let* ((property (completing-read "Search for property: " obarray)) + (property (when (> (length property) 0) + (intern property obarray))) + (value (when property + (read-from-minibuffer "Search for property value (quote strings): " + nil nil t nil "nil")))) + (list property value))) (cond ;; No matches at the end of the buffer. ((eobp) @@ -200,7 +203,9 @@ text-property--match-p (setq predicate #'equal)) ((eq predicate nil) (setq predicate (lambda (val p-val) - (not (equal val p-val)))))) + (not (if (and (listp p-val) (not (listp val))) + (member val p-val) + (equal val p-val))))))) (funcall predicate value prop-value)) (provide 'text-property-search) --=-=-=--