diff options
author | Lars Ingebrigtsen <larsi@gnus.org> | 2018-04-17 15:27:47 +0200 |
---|---|---|
committer | Lars Ingebrigtsen <larsi@gnus.org> | 2018-04-17 15:27:47 +0200 |
commit | 85433b94a4b09a72e19e06e0fb5c269ad5e07c23 (patch) | |
tree | 7c59525dace2503ae7ca6c4150483a78563f1cc5 | |
parent | 392003d1d7f8372474d233e50cc9980e0e17527c (diff) | |
download | emacs-scratch/prop-search.tar.gz |
Try to make backwards search work and fail againscratch/prop-search
Perhaps it'll have to be two separate functions anyway, because there
are too many tiny different details...
-rw-r--r-- | lisp/emacs-lisp/text-property-search.el | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/lisp/emacs-lisp/text-property-search.el b/lisp/emacs-lisp/text-property-search.el index 4d4e391da8d..4e36b0f0903 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 |