mirror of
https://github.com/m00natic/vlfi.git
synced 2025-01-18 12:05:31 +00:00
Restore batch size and hexl mode in case of failed search or occur.
This commit is contained in:
parent
d526ea8ef8
commit
0d2c096ed6
@ -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)
|
||||
|
@ -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))))
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user