[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

From: Juri Linkov
Subject: bug#36486: [PATCH] Add tests for text-property-search to check prop-match-value
Date: Fri, 12 Jul 2019 01:08:06 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (x86_64-pc-linux-gnu)

>>> I don't understand -- this will still return a symbol.  (And error out
>>> 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 ‘face’ with the value
>> ‘hi-yellow’ 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 ‘face’ with the value ‘(hi-yellow font-lock-keyword-face)’
>> 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 any
> 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:

diff --git a/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)."
-   (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)))
    ;; No matches at the end of the buffer.
@@ -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)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]