[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/vlf 2c660b0 269/310: Fix positive goto-line search and
From: |
Stefan Monnier |
Subject: |
[elpa] externals/vlf 2c660b0 269/310: Fix positive goto-line search and make highlighting of match optional. |
Date: |
Sat, 28 Nov 2020 00:33:29 -0500 (EST) |
branch: externals/vlf
commit 2c660b064f5435425f00a6af1e14dee577ecf816
Author: Andrey Kotlarski <m00naticus@gmail.com>
Commit: Andrey Kotlarski <m00naticus@gmail.com>
Fix positive goto-line search and make highlighting of match optional.
---
vlf-search.el | 33 +++++++++++++++++++++------------
vlf.el | 2 +-
2 files changed, 22 insertions(+), 13 deletions(-)
diff --git a/vlf-search.el b/vlf-search.el
index df82cfd..7a67467 100644
--- a/vlf-search.el
+++ b/vlf-search.el
@@ -30,10 +30,11 @@
(require 'vlf)
(defun vlf-re-search (regexp count backward batch-step
- &optional reporter time)
+ &optional reporter time highlight)
"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.
+Highlight match if HIGHLIGHT is non nil.
Return t if search has been at least partially successful."
(if (<= count 0)
(error "Count must be positive"))
@@ -135,20 +136,22 @@ Return t if search has been at least partially
successful."
(if backward
(vlf-goto-match match-chunk-start match-chunk-end
match-end-pos match-start-pos
- count to-find time)
+ count to-find time highlight)
(vlf-goto-match match-chunk-start match-chunk-end
match-start-pos match-end-pos
- count to-find time))))
+ count to-find time highlight))))
(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
- count to-find time)
+ count to-find time
+ highlight)
"Move to MATCH-CHUNK-START MATCH-CHUNK-END surrounding\
MATCH-POS-START and MATCH-POS-END.
According to COUNT and left TO-FIND, show if search has been
successful. Use start TIME to report how much it took.
+Highlight match if HIGHLIGHT is non nil.
Return nil if nothing found."
(if (= count to-find)
(progn (vlf-move-to-chunk match-chunk-start match-chunk-end)
@@ -180,7 +183,9 @@ Return nil if nothing found."
(goto-char (or (byte-to-position (- match-pos-start
vlf-start-pos))
(point-max)))
- (unwind-protect (sit-for 1)
+ (if highlight
+ (unwind-protect (sit-for 1)
+ (delete-overlay overlay))
(delete-overlay overlay))
t))))
@@ -193,7 +198,8 @@ Search is performed chunk by chunk in `vlf-batch-size'
memory."
(car regexp-history)))
(or current-prefix-arg 1))))
(let ((batch-size vlf-batch-size))
- (or (vlf-re-search regexp count nil (min 1024 (/ vlf-batch-size 8)))
+ (or (vlf-re-search regexp count nil (min 1024 (/ vlf-batch-size 8))
+ nil nil t)
(setq vlf-batch-size batch-size))))
(defun vlf-re-search-backward (regexp count)
@@ -205,7 +211,8 @@ Search is performed chunk by chunk in `vlf-batch-size'
memory."
(car regexp-history)))
(or current-prefix-arg 1))))
(let ((batch-size vlf-batch-size))
- (or (vlf-re-search regexp count t (min 1024 (/ vlf-batch-size 8)))
+ (or (vlf-re-search regexp count t (min 1024 (/ vlf-batch-size 8))
+ nil nil t)
(setq vlf-batch-size batch-size))))
(defun vlf-goto-line (n)
@@ -255,8 +262,11 @@ Search is performed chunk by chunk in `vlf-batch-size'
memory."
(vlf-tune-batch '(:insert :encode))
(vlf-move-to-chunk-2 start (+ start vlf-batch-size))
(goto-char (point-min))
- (setq success (vlf-re-search "[\n\C-m]" n nil 0
- reporter time)))))
+ (setq success
+ (or (zerop n)
+ (when (vlf-re-search "[\n\C-m]" n nil 0
+ reporter time)
+ (forward-char) t))))))
(let ((start (max 0 (- vlf-file-size vlf-batch-size)))
(end vlf-file-size)
(reporter (make-progress-reporter
@@ -342,9 +352,8 @@ replace BACKWARD."
(while (and match-found (if backward
(not (zerop vlf-start-pos))
(< vlf-end-pos vlf-file-size)))
- (setq match-found (if backward
- (vlf-re-search-backward regexp 1)
- (vlf-re-search-forward regexp 1)))
+ (setq match-found (vlf-re-search regexp 1 backward
+ (min 1024 (/ vlf-batch-size 8))))
(when match-found
(cond ((not automatic)
(query-replace-regexp regexp to-string delimited
diff --git a/vlf.el b/vlf.el
index 9dea3f7..38b1f5b 100644
--- a/vlf.el
+++ b/vlf.el
@@ -60,7 +60,7 @@ values are: `write', `ediff', `occur', `search', `goto-line'."
"Search backward for REGEXP prefix COUNT number of times." t)
(autoload 'vlf-goto-line "vlf-search" "Go to line." t)
(autoload 'vlf-query-replace "vlf-search"
- "Replace some things after point matching REGEXP." t)
+ "Query replace regexp over whole file." t)
(autoload 'vlf-occur "vlf-occur"
"Make whole file occur style index for REGEXP." t)
(autoload 'vlf-toggle-follow "vlf-follow"
- [elpa] externals/vlf 6476c1b 227/310: Update README, wording, add links and information on hooks., (continued)
- [elpa] externals/vlf 6476c1b 227/310: Update README, wording, add links and information on hooks., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 8ba5bea 229/310: Don't run vlf-after-batch-functions hook in vlf-build-occur., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 569e4b2 237/310: Don't ask needles questions on changing helm batch and restore undo, Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 1f9ba7c 230/310: Use derived-mode-p., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 32ff2cb 239/310: Add bookkeeping module., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 5379943 242/310: Save times instead of speeds, compare on cumulative speed when tuning., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 0d9cc8e 245/310: Don't measure encoding of too small region when adjusting chunk start, Stefan Monnier, 2020/11/28
- [elpa] externals/vlf e8bb4a9 248/310: Apply batch size tuning on adjacent moves, search, save adjusting and, Stefan Monnier, 2020/11/28
- [elpa] externals/vlf d526ea8 257/310: Apply and restore batch size in more cases., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 9b6657b 260/310: Replace usage of conservative tune in single batch operations with load, Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 2c660b0 269/310: Fix positive goto-line search and make highlighting of match optional.,
Stefan Monnier <=
- [elpa] externals/vlf 3cfa9b1 273/310: Refactor vlf-query-replace and don't adjust batch size if only, Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 61599a0 274/310: Change linear tune to search only known measures and use it to, Stefan Monnier, 2020/11/28
- [elpa] externals/vlf a9c14e2 268/310: Add regexp query replace over whole file command., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 673ae08 277/310: Lower tramp verbosity level., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf ac8d400 276/310: Fixes to hexl-mode activation., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf f63ea96 272/310: Document new query replace and save options., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf e4a2e80 266/310: Optimize goto-line for hexl-mode, no need to search., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 7b9befe 275/310: - don't load unnecessary data at the end of search or occur, Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 842569a 270/310: Add ability to use temporary file when adjusting content on save., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf d579b7b 279/310: Workaround local maximum in batch tune., Stefan Monnier, 2020/11/28