emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] scratch/prop-search 0051ed2 1/2: Revert the -backward-rela


From: Lars Ingebrigtsen
Subject: [Emacs-diffs] scratch/prop-search 0051ed2 1/2: Revert the -backward-related changes
Date: Tue, 17 Apr 2018 12:23:12 -0400 (EDT)

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

    Revert the -backward-related changes
---
 lisp/emacs-lisp/text-property-search.el | 56 ++++++---------------------------
 1 file changed, 9 insertions(+), 47 deletions(-)

diff --git a/lisp/emacs-lisp/text-property-search.el 
b/lisp/emacs-lisp/text-property-search.el
index 4e36b0f..40644dc 100644
--- a/lisp/emacs-lisp/text-property-search.el
+++ b/lisp/emacs-lisp/text-property-search.el
@@ -58,53 +58,18 @@ value of PROPERTY at the start of the region."
     (let ((string (completing-read "Search for property: " obarray)))
       (when (> (length string) 0)
         (intern string obarray)))))
-  (text-property--search #'next-single-property-change #'point-max
-                         property value predicate not-immediate
-                         (point)))
-
-(defun text-property-search-backward (property &optional value predicate
-                                               not-immediate)
-  "Search for the next region that has text property PROPERTY set to VALUE.
-See `text-property-search-forward' for further documentation."
-  (interactive
-   (list
-    (let ((string (completing-read "Search for property: " obarray)))
-      (when (> (length string) 0)
-        (intern string obarray)))))
-  (let ((match
-         (text-property--search #'text-property--previous-change #'point-min
-                                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
-      ;; point to the correct place.
-      (cl-rotatef (prop-match-beginning match) (prop-match-end match))
-      (setf (prop-match-beginning match) (1+ (prop-match-beginning match)))
-      (setf (prop-match-end match) (1+ (prop-match-end match))))
-    match))
-
-(defun text-property--previous-change (position prop &optional object limit)
-  (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
-                                        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 start property)
+  (if (and (text-property--match-p value (get-text-property (point) property)
                                    predicate)
            (not not-immediate))
-      (text-property--find-end (point) property value predicate
-                               next-func extreme-func)
+      (text-property--find-end (point) property value predicate)
     (let ((origin (point))
           (ended nil)
           pos)
       ;; Fix the next candidate.
       (while (not ended)
-        (setq pos (funcall next-func (point) property))
+        (setq pos (next-single-property-change (point) property))
         (if (not pos)
             (progn
               (goto-char origin)
@@ -113,18 +78,16 @@ See `text-property-search-forward' for further 
documentation."
           (if (text-property--match-p value (get-text-property (point) 
property)
                                       predicate)
               (setq ended
-                    (text-property--find-end (point) property value predicate
-                                             next-func extreme-func))
+                    (text-property--find-end (point) property value predicate))
             ;; Skip past this section of non-matches.
-            (setq pos (funcall next-func (point) property))
+            (setq pos (next-single-property-change (point) property))
             (unless pos
               (goto-char origin)
               (setq ended t)))))
       (and (not (eq ended t))
            ended))))
 
-(defun text-property--find-end (start property value predicate
-                                      next-func extreme-func)
+(defun text-property--find-end (start property value predicate)
   (let (end)
     (if (and value
              (null predicate))
@@ -133,10 +96,10 @@ See `text-property-search-forward' for further 
documentation."
         ;; property has different values, all non-matching value.
         (let ((ended nil))
           (while (not ended)
-            (setq end (funcall next-func (point) property))
+            (setq end (next-single-property-change (point) property))
             (if (not end)
                 (progn
-                  (goto-char (funcall extreme-func))
+                  (goto-char (point-max))
                   (setq end (point)
                         ended t))
               (goto-char end)
@@ -144,8 +107,7 @@ See `text-property-search-forward' for further 
documentation."
                        value (get-text-property (point) property) predicate)
                 (setq ended t)))))
       ;; End this at the first place the property changes value.
-      (setq end (funcall next-func (point) property nil
-                         (funcall extreme-func)))
+      (setq end (next-single-property-change (point) property nil (point-max)))
       (goto-char end))
     (make-prop-match :beginning start
                      :end end



reply via email to

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