[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] scratch/prop-search 1d06b4e 2/2: Adjust the backwards resu
From: |
Lars Ingebrigtsen |
Subject: |
[Emacs-diffs] scratch/prop-search 1d06b4e 2/2: Adjust the backwards result to have the beginning first |
Date: |
Mon, 16 Apr 2018 18:31:46 -0400 (EDT) |
branch: scratch/prop-search
commit 1d06b4e56c998b3238f796b04f78f2a774667cda
Author: Lars Ingebrigtsen <address@hidden>
Commit: Lars Ingebrigtsen <address@hidden>
Adjust the backwards result to have the beginning first
---
lisp/emacs-lisp/subr-x.el | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/lisp/emacs-lisp/subr-x.el b/lisp/emacs-lisp/subr-x.el
index 79dd6c2..0c76764 100644
--- a/lisp/emacs-lisp/subr-x.el
+++ b/lisp/emacs-lisp/subr-x.el
@@ -297,8 +297,16 @@ See `text-property-search-forward' for further
documentation."
(let ((string (completing-read "Search for property: " obarray)))
(when (> (length string) 0)
(intern string obarray)))))
- (text-property--search #'text-property--previous-change #'point-min
- property value predicate not-immediate))
+ (let ((match
+ (text-property--search #'text-property--previous-change #'point-min
+ property value predicate not-immediate)))
+ (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-end match) (1+ (prop-match-end match))))
+ match))
(defun text-property--previous-change (position prop &optional object limit)
(let ((pos (previous-single-property-change position prop