[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/vlf cb47e19 139/310: Use temporary buffer for occur in
From: |
Stefan Monnier |
Subject: |
[elpa] externals/vlf cb47e19 139/310: Use temporary buffer for occur in case of modifications. |
Date: |
Sat, 28 Nov 2020 00:33:03 -0500 (EST) |
branch: externals/vlf
commit cb47e19128bac09026c44eb531a8a383ae665d65
Author: Andrey Kotlarski <m00naticus@gmail.com>
Commit: Andrey Kotlarski <m00naticus@gmail.com>
Use temporary buffer for occur in case of modifications.
---
vlf.el | 47 +++++++++++++++++++++++++++++------------------
1 file changed, 29 insertions(+), 18 deletions(-)
diff --git a/vlf.el b/vlf.el
index 1b6b13c..84049d7 100644
--- a/vlf.el
+++ b/vlf.el
@@ -101,13 +101,13 @@
(start (* (/ pos vlf-batch-size) vlf-batch-size)))
(goto-char (byte-to-position (- pos start)))
(vlf-move-to-batch start)))
+ (kill-local-variable 'revert-buffer-function)
(when (or (not large-file-warning-threshold)
(< vlf-file-size large-file-warning-threshold)
(y-or-n-p (format "Load whole file? (%s) "
(file-size-human-readable
vlf-file-size))))
(remove-hook 'write-file-functions 'vlf-write t)
- (kill-local-variable 'revert-buffer-function)
(let ((pos (+ vlf-start-pos (position-bytes (point)))))
(erase-buffer)
(insert-file-contents buffer-file-name)
@@ -472,7 +472,8 @@ bytes added to the end."
BATCH-STEP is amount of overlap between successive chunks."
(if (<= count 0)
(error "Count must be positive"))
- (let* ((match-chunk-start vlf-start-pos)
+ (let* ((case-fold-search t)
+ (match-chunk-start vlf-start-pos)
(match-chunk-end vlf-end-pos)
(match-start-pos (+ vlf-start-pos (position-bytes (point))))
(match-end-pos match-start-pos)
@@ -707,21 +708,32 @@ Prematurely ending indexing will still show what's found
so far."
(interactive (list (read-regexp "List lines matching regexp"
(if regexp-history
(car regexp-history)))))
- (let ((start-pos vlf-start-pos)
- (end-pos vlf-end-pos)
- (pos (point)))
- (vlf-beginning-of-file)
- (goto-char (point-min))
- (set-buffer-modified-p nil)
- (vlf-with-undo-disabled
- (unwind-protect (vlf-build-occur regexp)
- (set-buffer-modified-p nil)
- (vlf-move-to-chunk start-pos end-pos)
- (goto-char pos)))))
-
-(defun vlf-build-occur (regexp)
+ (if (buffer-modified-p) ;use temporary buffer not to interfere with
modifications
+ (let ((vlf-buffer (current-buffer))
+ (file buffer-file-name)
+ (batch-size vlf-batch-size))
+ (with-temp-buffer
+ (setq buffer-file-name file)
+ (set-buffer-modified-p nil)
+ (set (make-local-variable 'vlf-batch-size) batch-size)
+ (vlf-mode 1)
+ (goto-char (point-min))
+ (vlf-with-undo-disabled
+ (vlf-build-occur regexp vlf-buffer))))
+ (let ((start-pos vlf-start-pos)
+ (end-pos vlf-end-pos)
+ (pos (point)))
+ (vlf-beginning-of-file)
+ (goto-char (point-min))
+ (vlf-with-undo-disabled
+ (unwind-protect (vlf-build-occur regexp (current-buffer))
+ (vlf-move-to-chunk start-pos end-pos)
+ (goto-char pos))))))
+
+(defun vlf-build-occur (regexp vlf-buffer)
"Build occur style index for REGEXP."
- (let ((line 1)
+ (let ((case-fold-search t)
+ (line 1)
(last-match-line 0)
(last-line-pos (point-min))
(file buffer-file-name)
@@ -751,7 +763,6 @@ Prematurely ending indexing will still show what's found so
far."
last-line-pos (point))
(let* ((chunk-start vlf-start-pos)
(chunk-end vlf-end-pos)
- (vlf-buffer (current-buffer))
(line-pos (line-beginning-position))
(line-text (buffer-substring
line-pos (line-end-position))))
@@ -812,7 +823,7 @@ Prematurely ending indexing will still show what's found so
far."
(with-current-buffer occur-buffer
(goto-char (point-min))
(insert (propertize
- (format "%d matches from %d lines for \"%s\" \
+ (format "%d matches in %d lines for \"%s\" \
in file: %s" total-matches line regexp file)
'face 'underline))
(set-buffer-modified-p nil)
- [elpa] externals/vlf f3132c0 044/310: Keep current position when moving around chunks., (continued)
- [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
- [elpa] externals/vlf f23262e 057/310: Add shift back of file contents when edited chunk shrinks in size., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 2f201c5 061/310: Add jump to chunk command., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf d5f2a36 060/310: Rearrange code in sections., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 705f9ce 064/310: Add issue section to the README., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 9fad430 066/310: Fix positioning after save., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf e545769 128/310: Fix adjusting of end chunk bytes., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf ae2237d 135/310: Minor adjustments:, Stefan Monnier, 2020/11/28
- [elpa] externals/vlf cb47e19 139/310: Use temporary buffer for occur in case of modifications.,
Stefan Monnier <=
- [elpa] externals/vlf 7a14109 137/310: Fix search for GNU Emacs 23 (no assert)., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 452b7eb 141/310: Ensure there are no modifications when executing searches., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf a42247c 150/310: Automatically scroll to adjacent batch when start or end of chunk is, Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 959bbc7 155/310: Disable undo in cases of partial chunk move., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf a65f3a4 143/310: Check for unsaved changes before search query and don't enable undo if, Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 42e581d 144/310: Add command to unconditionally open fresh VLF buffer to visit occur, Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 3e8098a 149/310: Rename vlf-discard-edit -> vlf-refresh., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf c0a85cd 159/310: Fix position when moving to overlapping chunk., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 2aea17a 163/310: Fix behaviour when size is missing (creating file) in, Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 88924f9 164/310: Fix vlf-write behaviour for newly created file., Stefan Monnier, 2020/11/28