unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@linkov.net>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: 36486@debbugs.gnu.org, Stefan Kangas <stefan@marxist.se>
Subject: bug#36486: [PATCH] Add tests for text-property-search to check prop-match-value
Date: Fri, 12 Jul 2019 21:47:27 +0300	[thread overview]
Message-ID: <87tvbrm6o0.fsf@mail.linkov.net> (raw)
In-Reply-To: <m3sgrbtj32.fsf@gnus.org> (Lars Ingebrigtsen's message of "Fri, 12 Jul 2019 16:37:21 +0200")

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

>> -                      (not (equal val p-val))))))
>> +                      (not (if (and (listp p-val) (not (listp val)))
>> +                               (member val p-val)
>> +                             (equal val p-val)))))))
>
> No, that's not an acceptable change, I think -- this function is a
> search primitive, not a DWIM thing.  There's an abundance of things that
> can be stored in text properties, to be compared with any number of
> predicates.  You're trying to special-case it to search for faces, for
> some reason, and that's not what it's for.

Then it's possible to add lambda to `predicate' arg in interactive spec only
like below.

> If you want a function to search for faces, that's something you can
> write (based on this function), but that's not what this function is for.

Of course, I can write and add it to ~/.emacs.  But the question is:
do you think this is generally useful?  For example, to search
hi-lock properties, etc.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: text-property-search-value.4.patch --]
[-- Type: text/x-diff, Size: 1203 bytes --]

diff --git a/lisp/emacs-lisp/text-property-search.el b/lisp/emacs-lisp/text-property-search.el
index 41ca07057e..867094539f 100644
--- a/lisp/emacs-lisp/text-property-search.el
+++ b/lisp/emacs-lisp/text-property-search.el
@@ -54,10 +54,16 @@ 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 (lambda (val p-val)
+                            (not (if (and (listp p-val) (not (listp val)))
+                                     (member val p-val)
+                                   (equal val p-val)))))))
   (cond
    ;; No matches at the end of the buffer.
    ((eobp)

  reply	other threads:[~2019-07-12 18:47 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-03  9:44 bug#36486: [PATCH] Add tests for text-property-search to check prop-match-value Stefan Kangas
2019-07-06 14:25 ` Lars Ingebrigtsen
2019-07-07 22:59   ` Juri Linkov
2019-07-08 16:18     ` Lars Ingebrigtsen
2019-07-08 20:51       ` Juri Linkov
2019-07-08 21:54         ` Lars Ingebrigtsen
2019-07-09 20:31           ` Juri Linkov
2019-07-09 21:52             ` Lars Ingebrigtsen
2019-07-10 22:29               ` Juri Linkov
2019-07-11 14:17                 ` Lars Ingebrigtsen
2019-07-11 22:08                   ` Juri Linkov
2019-07-12 14:37                     ` Lars Ingebrigtsen
2019-07-12 18:47                       ` Juri Linkov [this message]
2019-07-12 23:40                         ` Lars Ingebrigtsen

Reply instructions:

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

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

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=87tvbrm6o0.fsf@mail.linkov.net \
    --to=juri@linkov.net \
    --cc=36486@debbugs.gnu.org \
    --cc=larsi@gnus.org \
    --cc=stefan@marxist.se \
    /path/to/YOUR_REPLY

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

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

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).