mirror of
https://github.com/m00natic/vlfi.git
synced 2025-01-18 20:10:47 +00:00
Add vlf-batch-size tuning in vlf-occur.
This commit is contained in:
parent
5379943cd7
commit
70a81077ab
17
vlf-occur.el
17
vlf-occur.el
@ -182,7 +182,7 @@ Prematurely ending indexing will still show what's found so far."
|
||||
|
||||
(defun vlf-build-occur (regexp vlf-buffer)
|
||||
"Build occur style index for REGEXP over VLF-BUFFER."
|
||||
(let ((tramp-verbose (if (boundp 'tramp-verbose)
|
||||
(let* ((tramp-verbose (if (boundp 'tramp-verbose)
|
||||
(min tramp-verbose 2)))
|
||||
(case-fold-search t)
|
||||
(line 1)
|
||||
@ -196,9 +196,14 @@ Prematurely ending indexing will still show what's found so far."
|
||||
"*")))
|
||||
(line-regexp (concat "\\(?5:[\n\C-m]\\)\\|\\(?10:"
|
||||
regexp "\\)"))
|
||||
(batch-step (/ vlf-batch-size 8))
|
||||
(batch-step (min 1024 (/ vlf-batch-size 8)))
|
||||
(is-hexl (derived-mode-p 'hexl-mode))
|
||||
(end-of-file nil)
|
||||
(time (float-time))
|
||||
(tune-types (let ((base '(:insert :encode)))
|
||||
(if is-hexl
|
||||
(nconc '(:hexl :dehexlify) base)
|
||||
base)))
|
||||
(reporter (make-progress-reporter
|
||||
(concat "Building index for " regexp "...")
|
||||
vlf-start-pos vlf-file-size)))
|
||||
@ -254,6 +259,7 @@ Prematurely ending indexing will still show what's found so far."
|
||||
total-matches))))))))
|
||||
(setq end-of-file (= vlf-end-pos vlf-file-size))
|
||||
(unless end-of-file
|
||||
(vlf-tune-best tune-types)
|
||||
(let ((batch-move (- vlf-end-pos batch-step)))
|
||||
(vlf-move-to-batch (if (or is-hexl
|
||||
(< match-end-pos
|
||||
@ -273,7 +279,8 @@ Prematurely ending indexing will still show what's found so far."
|
||||
(set-buffer-modified-p nil)
|
||||
(if (zerop total-matches)
|
||||
(progn (kill-buffer occur-buffer)
|
||||
(message "No matches for \"%s\"" regexp))
|
||||
(message "No matches for \"%s\" (%f secs)"
|
||||
regexp (- (float-time) time)))
|
||||
(let ((file buffer-file-name)
|
||||
(dir default-directory))
|
||||
(with-current-buffer occur-buffer
|
||||
@ -291,7 +298,9 @@ in file: %s" total-matches line regexp file)
|
||||
vlf-occur-regexp regexp
|
||||
vlf-occur-hexl is-hexl
|
||||
vlf-occur-lines line)))
|
||||
(display-buffer occur-buffer)))))
|
||||
(display-buffer occur-buffer)
|
||||
(message "Occur finished for \"%s\" (%f secs)"
|
||||
regexp (- (float-time) time))))))
|
||||
|
||||
|
||||
;; save, load vlf-occur data
|
||||
|
Loading…
x
Reference in New Issue
Block a user