1
0
mirror of https://github.com/m00natic/vlfi.git synced 2025-02-24 05:48:06 +00:00

Fix small issues with forward search and add report progress.

This commit is contained in:
Andrey Kotlarski 2013-03-29 17:38:21 +02:00
parent 81e4fe19ac
commit c812288ab7

48
vlfi.el
View File

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