Subject: bug#36486: [PATCH] Add tests for text-property-search to check prop-match-value

From: Juri Linkov <[email-masked]>
Date: Fri, 12 Jul 2019 21:47:27 +0300

>> -                      (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.

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)