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

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

[elpa] externals/vlf c812288 017/310: Fix small issues with forward sear


From: Stefan Monnier
Subject: [elpa] externals/vlf c812288 017/310: Fix small issues with forward search and add report progress.
Date: Sat, 28 Nov 2020 00:32:38 -0500 (EST)

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

    Fix small issues with forward search and add report progress.
---
 vlfi.el | 48 ++++++++++++++++++++++++++++--------------------
 1 file changed, 28 insertions(+), 20 deletions(-)

diff --git a/vlfi.el b/vlfi.el
index 121b84b..e6dd2db 100644
--- a/vlfi.el
+++ b/vlfi.el
@@ -228,26 +228,34 @@ OP-TYPE specifies the file operation being performed over 
FILENAME."
   (let ((start vlfi-start-pos)
         (end vlfi-end-pos)
         (pos (point))
-        (to-find count))
-    (catch 'end-of-file
-      (while (not (zerop to-find))
-        (cond ((re-search-forward regexp nil t)
-               (setq to-find (1- to-find)))
-              ((= vlfi-end-pos vlfi-file-size)
-               (throw 'end-of-file nil))
-              (t (vlfi-next-batch 1)))))
-    (or (zerop to-find)
-        (if (< to-find count)
-            (message "Moved to the %d match which is last"
-                     (- count to-find))
-          (let ((inhibit-read-only t))
-            (insert-file-contents buffer-file-name nil start end))
-          (goto-char pos)
-          (setq vlfi-start-pos start
-                vlfi-end-pos end)
-          (set-buffer-modified-p nil)
-          (vlfi-update-buffer-name)
-          (message "Not found")))))
+        (to-find count)
+        (search-reporter (make-progress-reporter
+                          (concat "Searching for " regexp)
+                          vlfi-start-pos vlfi-file-size)))
+    (unwind-protect
+        (catch 'end-of-file
+          (while (not (zerop to-find))
+            (cond ((re-search-forward regexp nil t)
+                   (setq to-find (1- to-find)))
+                  ((= vlfi-end-pos vlfi-file-size)
+                   (throw 'end-of-file nil))
+                  (t (vlfi-next-batch 1)
+                     (progress-reporter-update search-reporter
+                                               vlfi-end-pos)))))
+      (progress-reporter-done search-reporter)
+      (or (zerop to-find)
+          (if (< to-find count)
+              (message "Moved to the %d match which is last"
+                       (- count to-find))
+            (let ((inhibit-read-only t))
+              (erase-buffer)
+              (insert-file-contents buffer-file-name nil start end))
+            (goto-char pos)
+            (setq vlfi-start-pos start
+                  vlfi-end-pos end)
+            (set-buffer-modified-p nil)
+            (vlfi-update-buffer-name)
+            (message "Not found"))))))
 
 (provide 'vlfi)
 



reply via email to

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