[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/vlf 375c96f 018/310: Add backward whole file search.
From: |
Stefan Monnier |
Subject: |
[elpa] externals/vlf 375c96f 018/310: Add backward whole file search. |
Date: |
Sat, 28 Nov 2020 00:32:38 -0500 (EST) |
branch: externals/vlf
commit 375c96f89be16e03e0f1db18d1673cff52baa338
Author: Andrey Kotlarski <m00naticus@gmail.com>
Commit: Andrey Kotlarski <m00naticus@gmail.com>
Add backward whole file search.
---
vlfi.el | 47 +++++++++++++++++++++++++++++++++++------------
1 file changed, 35 insertions(+), 12 deletions(-)
diff --git a/vlfi.el b/vlfi.el
index e6dd2db..537fcbe 100644
--- a/vlfi.el
+++ b/vlfi.el
@@ -62,6 +62,7 @@
(interactive)
(vlfi-change-batch-size t)))
(define-key map "\C-c\C-s" 'vlfi-re-search-forward)
+ (define-key map "\C-c\C-r" 'vlfi-re-search-backward)
map)
"Keymap for `vlfi-mode'.")
@@ -222,26 +223,38 @@ OP-TYPE specifies the file operation being performed over
FILENAME."
(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")
+(defun vlfi-re-search (regexp backward count)
+ "Search for REGEXP BACKWARD or forward COUNT number of times."
(let ((start vlfi-start-pos)
(end vlfi-end-pos)
(pos (point))
(to-find count)
(search-reporter (make-progress-reporter
(concat "Searching for " regexp)
- vlfi-start-pos vlfi-file-size)))
+ (if backward
+ (- vlfi-file-size vlfi-start-pos)
+ vlfi-start-pos)
+ vlfi-file-size)))
(unwind-protect
(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)
- (progress-reporter-update search-reporter
- vlfi-end-pos)))))
+ (if backward
+ (while (not (zerop to-find))
+ (cond ((re-search-backward regexp nil t)
+ (setq to-find (1- to-find)))
+ ((zerop vlfi-start-pos)
+ (throw 'end-of-file nil))
+ (t (vlfi-prev-batch 1)
+ (progress-reporter-update
+ search-reporter (- vlfi-file-size
+ vlfi-end-pos)))))
+ (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)
+ (progress-reporter-update search-reporter
+ vlfi-end-pos))))))
(progress-reporter-done search-reporter)
(or (zerop to-find)
(if (< to-find count)
@@ -257,6 +270,16 @@ OP-TYPE specifies the file operation being performed over
FILENAME."
(vlfi-update-buffer-name)
(message "Not found"))))))
+(defun vlfi-re-search-forward (regexp count)
+ "Search forward for REGEXP COUNT number of times."
+ (interactive "sSearch whole file: \np")
+ (vlfi-re-search regexp nil count))
+
+(defun vlfi-re-search-backward (regexp count)
+ "Search backward for REGEXP COUNT number of times."
+ (interactive "sSearch whole file backward: \np")
+ (vlfi-re-search regexp t count))
+
(provide 'vlfi)
;;; vlfi.el ends here
- [elpa] externals/vlf 3c2fb6b 111/310: Merge branch 'master' into chunk-opt2, (continued)
- [elpa] externals/vlf 3c2fb6b 111/310: Merge branch 'master' into chunk-opt2, Stefan Monnier, 2020/11/28
- [elpa] externals/vlf a0b8d5f 115/310: Merge pull request #3 from danlamanna/master, Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 8ed9192 117/310: Review fixes:, Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 298d8f5 118/310: Keep track of current batch encoded size and allow fluctuation when, Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 563d9ca 119/310: Fix vlfi-revert to revert on user confirmation., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 34dfbd2 121/310: Use set-visited-file-name and abstract getting current file size and, Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 6a1919d 001/310: Initial commit - original state of GNU ELPA vlf.el., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 2d0709b 003/310: Improvements to the existing functionality:, Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 59d5d2c 008/310: Add lexical-bind declaration., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 782b7e4 009/310: Make filename argument of `vlf-if-file-too-large' optional so it at, Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 375c96f 018/310: Add backward whole file search.,
Stefan Monnier <=
- [elpa] externals/vlf 30e4959 019/310: Add direct jumps to first and last chunks., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 42693f6 026/310: Update README., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf ac382e9 032/310: Add temporary highlight of match., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 9abee04 038/310: Merge branch 'master' into edit, Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 0ff2f3e 040/310: Merge branch 'master' into edit, Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 1948f3e 041/310: Make VLFI edit mode actually working., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 5405a30 045/310: Intercept buffer saving with vlfi-write., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf f3132c0 044/310: Keep current position when moving around chunks., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 8787186 055/310: Show paging according to batch size instead of percentage., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 8f6299c 056/310: Simplify detection of buffer size change., Stefan Monnier, 2020/11/28