emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/vlf ac382e9 032/310: Add temporary highlight of match.


From: Stefan Monnier
Subject: [elpa] externals/vlf ac382e9 032/310: Add temporary highlight of match.
Date: Sat, 28 Nov 2020 00:32:41 -0500 (EST)

branch: externals/vlf
commit ac382e90dcaabed8da0b0436c028162bef7e0196
Author: Andrey Kotlarski <m00naticus@gmail.com>
Commit: Andrey Kotlarski <m00naticus@gmail.com>

    Add temporary highlight of match.
---
 vlfi.el | 37 +++++++++++++++++++++++--------------
 1 file changed, 23 insertions(+), 14 deletions(-)

diff --git a/vlfi.el b/vlfi.el
index 90ea5ea..302e8af 100644
--- a/vlfi.el
+++ b/vlfi.el
@@ -316,22 +316,31 @@ OP-TYPE specifies the file operation being performed over 
FILENAME."
                        (progress-reporter-update search-reporter
                                                  vlfi-end-pos)))))
           (progress-reporter-done search-reporter))
-      (vlfi-end-search (if backward match-start-pos match-end-pos)
-                       count to-find))))
-
-(defun vlfi-end-search (match-pos count to-find)
-  "Move to chunk surrounding MATCH-POS.
+      (if backward
+          (vlfi-end-search match-end-pos match-start-pos
+                           count to-find)
+        (vlfi-end-search match-start-pos match-end-pos
+                         count to-find)))))
+
+(defun vlfi-end-search (match-pos-start match-pos-end count to-find)
+  "Move to chunk surrounding MATCH-POS-START and MATCH-POS-END.
 According to COUNT and left TO-FIND show if search has been
 successful.  Return nil if nothing found."
-  (vlfi-move-to-batch (- match-pos (/ vlfi-batch-size 2)))
-  (goto-char (- match-pos vlfi-start-pos))
-  (cond ((zerop to-find) t)
-        ((< to-find count)
-         (message "Moved to the %d match which is last found"
-                  (- count to-find))
-         t)
-        (t (message "Not found")
-           nil)))
+  (vlfi-move-to-batch (- match-pos-start (/ vlfi-batch-size 2)))
+  (let* ((match-end (- match-pos-end vlfi-start-pos))
+         (overlay (make-overlay (- match-pos-start vlfi-start-pos)
+                                match-end)))
+    (overlay-put overlay 'face 'region)
+    (goto-char match-end)
+    (cond ((zerop to-find) t)
+          ((< to-find count)
+           (message "Moved to the %d match which is last found"
+                    (- count to-find))
+           t)
+          (t (message "Not found")
+             nil))
+    (sit-for 0.1)
+    (delete-overlay overlay)))
 
 (defun vlfi-re-search-forward (regexp count)
   "Search forward for REGEXP prefix COUNT number of times."



reply via email to

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