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

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

[elpa] externals/vlf 0d2c096 258/310: Restore batch size and hexl mode i


From: Stefan Monnier
Subject: [elpa] externals/vlf 0d2c096 258/310: Restore batch size and hexl mode in case of failed search or occur.
Date: Sat, 28 Nov 2020 00:33:27 -0500 (EST)

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

    Restore batch size and hexl mode in case of failed search or occur.
---
 vlf-occur.el  |  8 +++++---
 vlf-search.el | 32 +++++++++++++++++++++-----------
 2 files changed, 26 insertions(+), 14 deletions(-)

diff --git a/vlf-occur.el b/vlf-occur.el
index 5e53cfb..a41f448 100644
--- a/vlf-occur.el
+++ b/vlf-occur.el
@@ -200,7 +200,8 @@ Prematurely ending indexing will still show what's found so 
far."
     (let ((start-pos vlf-start-pos)
           (end-pos vlf-end-pos)
           (pos (point))
-          (batch-size vlf-batch-size))
+          (batch-size vlf-batch-size)
+          (is-hexl (derived-mode-p 'hexl-mode)))
       (vlf-tune-batch (if (derived-mode-p 'hexl-mode)
                           '(:hexl :dehexlify :insert :encode)
                         '(:insert :encode)))
@@ -209,8 +210,9 @@ Prematurely ending indexing will still show what's found so 
far."
        (goto-char (point-min))
        (unwind-protect (vlf-build-occur regexp (current-buffer))
          (vlf-move-to-chunk start-pos end-pos)
-         (goto-char pos)))
-      (setq vlf-batch-size batch-size)))
+         (if is-hexl (vlf-tune-hexlify))
+         (goto-char pos)
+         (setq vlf-batch-size batch-size)))))
   (run-hook-with-args 'vlf-after-batch-functions 'occur))
 
 (defun vlf-build-occur (regexp vlf-buffer)
diff --git a/vlf-search.el b/vlf-search.el
index 7b2f02b..45fe1c9 100644
--- a/vlf-search.el
+++ b/vlf-search.el
@@ -33,7 +33,8 @@
                              &optional reporter time)
   "Search for REGEXP COUNT number of times forward or BACKWARD.
 BATCH-STEP is amount of overlap between successive chunks.
-Use existing REPORTER and start TIME if given."
+Use existing REPORTER and start TIME if given.
+Return t if search has been at least partially successful."
   (if (<= count 0)
       (error "Count must be positive"))
   (run-hook-with-args 'vlf-before-batch-functions 'search)
@@ -125,15 +126,18 @@ Use existing REPORTER and start TIME if given."
                                                   vlf-end-pos)))))
            (progress-reporter-done reporter))
        (set-buffer-modified-p nil)
+       (if is-hexl (vlf-tune-hexlify))
        (if font-lock (font-lock-mode 1))
-       (if backward
-           (vlf-goto-match match-chunk-start match-chunk-end
-                           match-end-pos match-start-pos
-                           count to-find time)
-         (vlf-goto-match match-chunk-start match-chunk-end
-                         match-start-pos match-end-pos
-                         count to-find time))
-       (run-hook-with-args 'vlf-after-batch-functions 'search)))))
+       (let ((result
+              (if backward
+                  (vlf-goto-match match-chunk-start match-chunk-end
+                                  match-end-pos match-start-pos
+                                  count to-find time)
+                (vlf-goto-match match-chunk-start match-chunk-end
+                                match-start-pos match-end-pos
+                                count to-find time))))
+         (run-hook-with-args 'vlf-after-batch-functions 'search)
+         result)))))
 
 (defun vlf-goto-match (match-chunk-start match-chunk-end
                                          match-pos-start match-pos-end
@@ -179,7 +183,9 @@ Search is performed chunk by chunk in `vlf-batch-size' 
memory."
                                       (if regexp-history
                                           (car regexp-history)))
                          (or current-prefix-arg 1))))
-  (vlf-re-search regexp count nil (min 1024 (/ vlf-batch-size 8))))
+  (let ((batch-size vlf-batch-size))
+    (or (vlf-re-search regexp count nil (min 1024 (/ vlf-batch-size 8)))
+        (setq vlf-batch-size batch-size))))
 
 (defun vlf-re-search-backward (regexp count)
   "Search backward for REGEXP prefix COUNT number of times.
@@ -189,7 +195,9 @@ Search is performed chunk by chunk in `vlf-batch-size' 
memory."
                                       (if regexp-history
                                           (car regexp-history)))
                          (or current-prefix-arg 1))))
-  (vlf-re-search regexp count t (min 1024 (/ vlf-batch-size 8))))
+  (let ((batch-size vlf-batch-size))
+    (or (vlf-re-search regexp count t (min 1024 (/ vlf-batch-size 8)))
+        (setq vlf-batch-size batch-size))))
 
 (defun vlf-goto-line (n)
   "Go to line N.  If N is negative, count from the end of file."
@@ -201,6 +209,7 @@ Search is performed chunk by chunk in `vlf-batch-size' 
memory."
                            (min tramp-verbose 2)))
         (start-pos vlf-start-pos)
         (end-pos vlf-end-pos)
+        (batch-size vlf-batch-size)
         (pos (point))
         (is-hexl (derived-mode-p 'hexl-mode))
         (font-lock font-lock-mode)
@@ -276,6 +285,7 @@ Search is performed chunk by chunk in `vlf-batch-size' 
memory."
          (vlf-move-to-chunk-2 start-pos end-pos))
         (vlf-update-buffer-name)
         (goto-char pos)
+        (setq vlf-batch-size batch-size)
         (message "Unable to find line"))
       (run-hook-with-args 'vlf-after-batch-functions 'goto-line))))
 



reply via email to

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