branch: externals/vlf
commit 03f323337ba40a3bfc5d91ff976a2daf8b1adb43
Author: Andrey Kotlarski <[email protected]>
Commit: Andrey Kotlarski <[email protected]>
Don't reinsert content and move on successful search.
---
vlfi.el | 33 ++++++++++++++++++---------------
1 file changed, 18 insertions(+), 15 deletions(-)
diff --git a/vlfi.el b/vlfi.el
index 4575548..6e9c60c 100644
--- a/vlfi.el
+++ b/vlfi.el
@@ -331,21 +331,24 @@ OP-TYPE specifies the file operation being performed over
FILENAME."
"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-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)
- (prog1 (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))))
+ (let ((success (zerop to-find)))
+ (or success
+ (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)
+ (or success (goto-char match-end))
+ (prog1 (cond (success t)
+ ((< to-find count)
+ (message "Moved to the %d match which is last"
+ (- 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."