mirror of
https://github.com/m00natic/vlfi.git
synced 2025-01-31 10:10:48 +00:00
Add regex search forward functionality.
This commit is contained in:
parent
e693e8f24a
commit
853386f82e
29
vlfi.el
29
vlfi.el
@ -61,6 +61,7 @@
|
|||||||
(lambda () "Decrease vlfi batch size by factor of 2."
|
(lambda () "Decrease vlfi batch size by factor of 2."
|
||||||
(interactive)
|
(interactive)
|
||||||
(vlfi-change-batch-size t)))
|
(vlfi-change-batch-size t)))
|
||||||
|
(define-key map "\C-c\C-s" 'vlfi-re-search-forward)
|
||||||
map)
|
map)
|
||||||
"Keymap for `vlfi-mode'.")
|
"Keymap for `vlfi-mode'.")
|
||||||
|
|
||||||
@ -220,6 +221,34 @@ OP-TYPE specifies the file operation being performed over FILENAME."
|
|||||||
;;;###autoload
|
;;;###autoload
|
||||||
(fset 'abort-if-file-too-large 'vlfi-if-file-too-large)
|
(fset 'abort-if-file-too-large 'vlfi-if-file-too-large)
|
||||||
|
|
||||||
|
;;; search
|
||||||
|
(defun vlfi-re-search-forward (regexp &optional count)
|
||||||
|
"Search for REGEXP COUNT number of times."
|
||||||
|
(interactive "sSearch: \np")
|
||||||
|
(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")))))
|
||||||
|
|
||||||
(provide 'vlfi)
|
(provide 'vlfi)
|
||||||
|
|
||||||
;;; vlfi.el ends here
|
;;; vlfi.el ends here
|
||||||
|
Loading…
x
Reference in New Issue
Block a user