emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] scratch/prop-search 85433b9: Try to make backwards search


From: Lars Ingebrigtsen
Subject: [Emacs-diffs] scratch/prop-search 85433b9: Try to make backwards search work and fail again
Date: Tue, 17 Apr 2018 09:28:00 -0400 (EDT)

branch: scratch/prop-search
commit 85433b94a4b09a72e19e06e0fb5c269ad5e07c23
Author: Lars Ingebrigtsen <address@hidden>
Commit: Lars Ingebrigtsen <address@hidden>

    Try to make backwards search work and fail again
    
    Perhaps it'll have to be two separate functions anyway, because there
    are too many tiny different details...
---
 lisp/emacs-lisp/text-property-search.el | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/lisp/emacs-lisp/text-property-search.el 
b/lisp/emacs-lisp/text-property-search.el
index 4d4e391..4e36b0f 100644
--- a/lisp/emacs-lisp/text-property-search.el
+++ b/lisp/emacs-lisp/text-property-search.el
@@ -59,7 +59,8 @@ value of PROPERTY at the start of the region."
       (when (> (length string) 0)
         (intern string obarray)))))
   (text-property--search #'next-single-property-change #'point-max
-                         property value predicate not-immediate))
+                         property value predicate not-immediate
+                         (point)))
 
 (defun text-property-search-backward (property &optional value predicate
                                                not-immediate)
@@ -72,7 +73,8 @@ See `text-property-search-forward' for further documentation."
         (intern string obarray)))))
   (let ((match
          (text-property--search #'text-property--previous-change #'point-min
-                                property value predicate not-immediate)))
+                                property value predicate not-immediate
+                                (max (1- (point)) (point-min)))))
     (when match
       ;; We have to exchange beginning and end since everything's
       ;; backwards when searching backwards.  Also adjust the end
@@ -83,16 +85,16 @@ See `text-property-search-forward' for further 
documentation."
     match))
 
 (defun text-property--previous-change (position prop &optional object limit)
-  (let ((pos (previous-single-property-change position prop
-                                              object limit)))
-    (and pos
-         (max (1- pos) (point-min)))))
+  (when-let ((pos (previous-single-property-change position prop
+                                                   object limit)))
+    (max (1- pos) (point-min))))
 
 (defun text-property--search (next-func extreme-func
-                                        property value predicate not-immediate)
+                                        property value predicate not-immediate
+                                        start)
   ;; We're standing in the property we're looking for, so find the
   ;; end.
-  (if (and (text-property--match-p value (get-text-property (point) property)
+  (if (and (text-property--match-p value (get-text-property start property)
                                    predicate)
            (not not-immediate))
       (text-property--find-end (point) property value predicate



reply via email to

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