[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/vlf 3cfa9b1 273/310: Refactor vlf-query-replace and don
From: |
Stefan Monnier |
Subject: |
[elpa] externals/vlf 3cfa9b1 273/310: Refactor vlf-query-replace and don't adjust batch size if only |
Date: |
Sat, 28 Nov 2020 00:33:30 -0500 (EST) |
branch: externals/vlf
commit 3cfa9b19350375512e1b06b2275bef413bec3ab4
Author: Andrey Kotlarski <m00naticus@gmail.com>
Commit: Andrey Kotlarski <m00naticus@gmail.com>
Refactor vlf-query-replace and don't adjust batch size if only
statistics are enabled.
---
vlf-search.el | 65 +++++++++++++++++++++++++----------------------------------
vlf-tune.el | 2 +-
2 files changed, 29 insertions(+), 38 deletions(-)
diff --git a/vlf-search.el b/vlf-search.el
index 7a67467..5be45b7 100644
--- a/vlf-search.el
+++ b/vlf-search.el
@@ -328,45 +328,36 @@ Assume `hexl-mode' is active."
(defun vlf-query-replace (regexp to-string &optional delimited backward)
"Query replace over whole file matching REGEXP with TO-STRING.
-Third arg DELIMITED (prefix arg if interactive), if non-nil, means replace
+Third arg DELIMITED (prefix arg if interactive), if non-nil, replace
only matches surrounded by word boundaries. A negative prefix arg means
replace BACKWARD."
- (interactive
- (let ((common (query-replace-read-args
- (concat "Query replace over whole file"
- (if current-prefix-arg
- (if (eq current-prefix-arg '-)
- " backward"
- " word")
- "")
- " regexp")
- t)))
- (list (nth 0 common) (nth 1 common) (nth 2 common) (nth 3 common))))
- (query-replace-regexp regexp to-string delimited nil nil backward)
- (if (buffer-modified-p)
- (save-buffer))
- (let ((match-found t)
- (automatic (eq (lookup-key query-replace-map
- (vector last-input-event))
- 'automatic)))
- (while (and match-found (if backward
- (not (zerop vlf-start-pos))
- (< vlf-end-pos vlf-file-size)))
- (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
- nil nil backward)
- (setq automatic (eq (lookup-key query-replace-map
- (vector last-input-event))
- 'automatic)))
- (backward (while (re-search-backward regexp nil t)
- (replace-match to-string)))
- (t (while (re-search-forward regexp nil t)
- (replace-match to-string))))
- (if (buffer-modified-p)
- (save-buffer))))))
+ (interactive (let ((common (query-replace-read-args
+ (concat "Query replace over whole file"
+ (if current-prefix-arg
+ (if (eq current-prefix-arg '-)
+ " backward"
+ " word")
+ "")
+ " regexp")
+ t)))
+ (list (nth 0 common) (nth 1 common) (nth 2 common)
+ (nth 3 common))))
+ (let ((not-automatic t))
+ (while (vlf-re-search regexp 1 backward
+ (min 1024 (/ vlf-batch-size 8)))
+ (cond (not-automatic
+ (query-replace-regexp regexp to-string delimited
+ nil nil backward)
+ (setq not-automatic
+ (not (eq (lookup-key query-replace-map
+ (vector last-input-event))
+ 'automatic))))
+ (backward (while (re-search-backward regexp nil t)
+ (replace-match to-string)))
+ (t (while (re-search-forward regexp nil t)
+ (replace-match to-string))))
+ (if (buffer-modified-p)
+ (save-buffer)))))
(provide 'vlf-search)
diff --git a/vlf-tune.el b/vlf-tune.el
index eb0fa81..c2fe69a 100644
--- a/vlf-tune.el
+++ b/vlf-tune.el
@@ -382,7 +382,7 @@ Suitable for multiple batch operations."
Best considered where primitive operations total is closest to
`vlf-tune-load-time'. If MIN-IDX and MAX-IDX are given,
confine search to this region."
- (if vlf-tune-enabled
+ (if (eq vlf-tune-enabled t)
(progn
(setq min-idx (max 0 (or min-idx 0))
max-idx (min (or max-idx vlf-tune-max)
- [elpa] externals/vlf 8ba5bea 229/310: Don't run vlf-after-batch-functions hook in vlf-build-occur., (continued)
- [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, 2020/11/28
- [elpa] externals/vlf 3cfa9b1 273/310: Refactor vlf-query-replace and don't adjust batch size if only,
Stefan Monnier <=
- [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
- [elpa] externals/vlf b14c912 290/310: Copy around buffer specific profile vectors when forking new buffers., Stefan Monnier, 2020/11/28