[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/vlf 274c5ab 233/310: Perform search, occur and ediff op
From: |
Stefan Monnier |
Subject: |
[elpa] externals/vlf 274c5ab 233/310: Perform search, occur and ediff operations over hexl content instead |
Date: |
Sat, 28 Nov 2020 00:33:22 -0500 (EST) |
branch: externals/vlf
commit 274c5ab903de05c25699e1ffcb9e951a3d15fa18
Author: Andrey Kotlarski <m00naticus@gmail.com>
Commit: Andrey Kotlarski <m00naticus@gmail.com>
Perform search, occur and ediff operations over hexl content instead
over raw data when hexl-mode is active.
---
vlf-ediff.el | 18 ++++++++-----
vlf-occur.el | 22 ++++++++-------
vlf-search.el | 86 ++++++++++++++++++++++++++++++++---------------------------
vlf.el | 25 +++++++++--------
4 files changed, 85 insertions(+), 66 deletions(-)
diff --git a/vlf-ediff.el b/vlf-ediff.el
index 2b7c63f..866ddc2 100644
--- a/vlf-ediff.el
+++ b/vlf-ediff.el
@@ -161,12 +161,14 @@ logical chunks in case there is no difference at the
current ones."
(point-max-A (point-max))
(font-lock-A font-lock-mode)
(min-file-size vlf-file-size)
- (forward-p (eq next-func 'vlf-next-chunk)))
+ (forward-p (eq next-func 'vlf-next-chunk))
+ (is-hexl (derived-mode-p 'hexl-mode)))
(font-lock-mode 0)
(set-buffer buffer-B)
(run-hook-with-args 'vlf-before-batch-functions 'ediff)
(setq buffer-B (current-buffer)
- min-file-size (min min-file-size vlf-file-size))
+ min-file-size (min min-file-size vlf-file-size)
+ is-hexl (or is-hexl (derived-mode-p 'hexl-mode)))
(let ((tramp-verbose (if (boundp 'tramp-verbose)
(min tramp-verbose 2)))
(end-B (= vlf-start-pos vlf-end-pos))
@@ -187,7 +189,7 @@ logical chunks in case there is no difference at the
current ones."
buffer-B (point-min) (point-max)))
(with-current-buffer ediff-buffer
(ediff-update-diffs)
- (and (not end-A) (not end-B)
+ (and (not end-A) (not end-B) (not is-hexl)
(vlf-ediff-refine buffer-A
buffer-B))
(zerop ediff-number-of-differences))))
@@ -221,9 +223,10 @@ logical chunks in case there is no difference at the
current ones."
(vlf-beginning-of-file))
(set-buffer ediff-buffer)
(ediff-update-diffs)
- (if (or (not forward-p)
- (and (not end-A) (not end-B)))
- (vlf-ediff-refine buffer-A buffer-B)))
+ (or is-hexl
+ (if (or (not forward-p)
+ (and (not end-A) (not end-B)))
+ (vlf-ediff-refine buffer-A buffer-B))))
(setq done t))
(unless done
(set-buffer buffer-A)
@@ -234,7 +237,8 @@ logical chunks in case there is no difference at the
current ones."
(vlf-move-to-chunk (car chunk-B) (cdr chunk-B))
(set-buffer ediff-buffer)
(ediff-update-diffs)
- (vlf-ediff-refine buffer-A buffer-B))
+ (or is-hexl
+ (vlf-ediff-refine buffer-A buffer-B)))
(set-buffer buffer-A)
(if font-lock-A (font-lock-mode 1))
(run-hook-with-args 'vlf-after-batch-functions 'ediff)
diff --git a/vlf-occur.el b/vlf-occur.el
index cea885e..977267a 100644
--- a/vlf-occur.el
+++ b/vlf-occur.el
@@ -165,6 +165,7 @@ Prematurely ending indexing will still show what's found so
far."
(line-regexp (concat "\\(?5:[\n\C-m]\\)\\|\\(?10:"
regexp "\\)"))
(batch-step (/ vlf-batch-size 8))
+ (is-hexl (derived-mode-p 'hexl-mode))
(end-of-file nil)
(reporter (make-progress-reporter
(concat "Building index for " regexp "...")
@@ -222,14 +223,17 @@ Prematurely ending indexing will still show what's found
so far."
(setq end-of-file (= vlf-end-pos vlf-file-size))
(unless end-of-file
(let ((batch-move (- vlf-end-pos batch-step)))
- (vlf-move-to-batch (if (< batch-move match-end-pos)
- match-end-pos
- batch-move) t))
- (goto-char (if (< vlf-start-pos match-end-pos)
- (or (byte-to-position (- match-end-pos
- vlf-start-pos))
- (point-min))
- (point-min)))
+ (vlf-move-to-batch (if (or is-hexl
+ (< match-end-pos
+ batch-move))
+ batch-move
+ match-end-pos) t))
+ (goto-char (if (or is-hexl
+ (<= match-end-pos vlf-start-pos))
+ (point-min)
+ (or (byte-to-position (- match-end-pos
+ vlf-start-pos))
+ (point-min))))
(setq last-match-line 0
last-line-pos (line-beginning-position))
(progress-reporter-update reporter vlf-end-pos))))
@@ -243,7 +247,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 in %d lines for \"%s\" \
+ (format "%d matches from %d lines for \"%s\" \
in file: %s" total-matches line regexp file)
'face 'underline))
(set-buffer-modified-p nil)
diff --git a/vlf-search.el b/vlf-search.el
index 0462cb2..3b81d57 100644
--- a/vlf-search.el
+++ b/vlf-search.el
@@ -43,6 +43,7 @@ BATCH-STEP is amount of overlap between successive chunks."
(match-start-pos (+ vlf-start-pos (position-bytes (point))))
(match-end-pos match-start-pos)
(to-find count)
+ (is-hexl (derived-mode-p 'hexl-mode))
(font-lock font-lock-mode)
(reporter (make-progress-reporter
(concat "Searching for " regexp "...")
@@ -72,16 +73,18 @@ BATCH-STEP is amount of overlap between successive chunks."
(- vlf-batch-size
batch-step))))
(vlf-move-to-batch
- (if (< match-start-pos batch-move)
- (- match-start-pos vlf-batch-size)
- batch-move) t))
- (goto-char (if (< match-start-pos
- vlf-end-pos)
- (or (byte-to-position
+ (if (or is-hexl
+ (<= batch-move match-start-pos))
+ batch-move
+ (- match-start-pos vlf-batch-size)) t))
+ (goto-char (if (or is-hexl
+ (<= vlf-end-pos
+ match-start-pos))
+ (point-max)
+ (or (byte-to-position
(- match-start-pos
vlf-start-pos))
- (point-max))
- (point-max)))
+ (point-max))))
(progress-reporter-update
reporter (- vlf-file-size
vlf-start-pos)))))
@@ -100,15 +103,17 @@ BATCH-STEP is amount of overlap between successive
chunks."
(throw 'end-of-file nil))
(t (let ((batch-move (- vlf-end-pos batch-step)))
(vlf-move-to-batch
- (if (< batch-move match-end-pos)
- match-end-pos
- batch-move) t))
- (goto-char (if (< vlf-start-pos match-end-pos)
- (or (byte-to-position
+ (if (or is-hexl
+ (< match-end-pos batch-move))
+ batch-move
+ match-end-pos) t))
+ (goto-char (if (or is-hexl
+ (<= match-end-pos vlf-start-pos))
+ (point-min)
+ (or (byte-to-position
(- match-end-pos
vlf-start-pos))
- (point-min))
- (point-min)))
+ (point-min))))
(progress-reporter-update reporter
vlf-end-pos)))))
(progress-reporter-done reporter))
@@ -189,6 +194,7 @@ Search is performed chunk by chunk in `vlf-batch-size'
memory."
(start-pos vlf-start-pos)
(end-pos vlf-end-pos)
(pos (point))
+ (is-hexl (derived-mode-p 'hexl-mode))
(font-lock font-lock-mode)
(success nil))
(font-lock-mode 0)
@@ -203,19 +209,20 @@ Search is performed chunk by chunk in `vlf-batch-size'
memory."
(inhibit-read-only t))
(setq n (1- n))
(vlf-with-undo-disabled
- (while (and (< (- end start) n)
- (< n (- vlf-file-size start)))
- (erase-buffer)
- (insert-file-contents-literally buffer-file-name
- nil start end)
- (goto-char (point-min))
- (while (re-search-forward "[\n\C-m]" nil t)
- (setq n (1- n)))
- (vlf-verify-size)
- (setq start end
- end (min vlf-file-size
- (+ start vlf-batch-size)))
- (progress-reporter-update reporter start))
+ (or is-hexl
+ (while (and (< (- end start) n)
+ (< n (- vlf-file-size start)))
+ (erase-buffer)
+ (insert-file-contents-literally buffer-file-name
+ nil start end)
+ (goto-char (point-min))
+ (while (re-search-forward "[\n\C-m]" nil t)
+ (setq n (1- n)))
+ (vlf-verify-size)
+ (setq start end
+ end (min vlf-file-size
+ (+ start vlf-batch-size)))
+ (progress-reporter-update reporter start)))
(when (< n (- vlf-file-size end))
(vlf-move-to-chunk-2 start end)
(goto-char (point-min))
@@ -229,17 +236,18 @@ Search is performed chunk by chunk in `vlf-batch-size'
memory."
(inhibit-read-only t))
(setq n (- n))
(vlf-with-undo-disabled
- (while (and (< (- end start) n) (< n end))
- (erase-buffer)
- (insert-file-contents-literally buffer-file-name nil
- start end)
- (goto-char (point-max))
- (while (re-search-backward "[\n\C-m]" nil t)
- (setq n (1- n)))
- (setq end start
- start (max 0 (- end vlf-batch-size)))
- (progress-reporter-update reporter
- (- vlf-file-size end)))
+ (or is-hexl
+ (while (and (< (- end start) n) (< n end))
+ (erase-buffer)
+ (insert-file-contents-literally buffer-file-name
+ nil start end)
+ (goto-char (point-max))
+ (while (re-search-backward "[\n\C-m]" nil t)
+ (setq n (1- n)))
+ (setq end start
+ start (max 0 (- end vlf-batch-size)))
+ (progress-reporter-update reporter
+ (- vlf-file-size end))))
(when (< n end)
(vlf-move-to-chunk-2 start end)
(goto-char (point-max))
diff --git a/vlf.el b/vlf.el
index 2e3c9a1..da837a5 100644
--- a/vlf.el
+++ b/vlf.el
@@ -2,7 +2,7 @@
;; Copyright (C) 2006, 2012-2014 Free Software Foundation, Inc.
-;; Version: 1.5
+;; Version: 1.6
;; Keywords: large files, utilities
;; Maintainer: Andrey Kotlarski <m00naticus@gmail.com>
;; Authors: 2006 Mathias Dahl <mathias.dahl@gmail.com>
@@ -207,23 +207,26 @@ When prefix argument is negative
ad-do-it))
;; hexl mode integration
-(defun vlf-hexl-before (&optional operation)
+(defun vlf-hexl-disable (&optional operation)
"Temporarily disable `hexl-mode' for OPERATION."
- (when (derived-mode-p 'hexl-mode)
+ (when (and (derived-mode-p 'hexl-mode)
+ (or (not operation)
+ (eq operation 'write)))
+ (if (consp buffer-undo-list)
+ (setq buffer-undo-list nil))
(hexl-mode-exit)
(set (make-local-variable 'vlf-restore-hexl-mode) operation)))
-(defun vlf-hexl-after (&optional operation)
- "Re-enable `hexl-mode' if active before OPERATION."
- (when (and (boundp 'vlf-restore-hexl-mode)
- (eq vlf-restore-hexl-mode operation))
+(defun vlf-hexl-enable (&optional _operation)
+ "Re-enable `hexl-mode' if active before _OPERATION."
+ (when (boundp 'vlf-restore-hexl-mode)
(hexl-mode)
(kill-local-variable 'vlf-restore-hexl-mode)))
-(add-hook 'vlf-before-batch-functions 'vlf-hexl-before)
-(add-hook 'vlf-after-batch-functions 'vlf-hexl-after)
-(add-hook 'vlf-before-chunk-update 'vlf-hexl-before)
-(add-hook 'vlf-after-chunk-update 'vlf-hexl-after)
+(add-hook 'vlf-before-batch-functions 'vlf-hexl-disable)
+(add-hook 'vlf-after-batch-functions 'vlf-hexl-enable)
+(add-hook 'vlf-before-chunk-update 'vlf-hexl-disable)
+(add-hook 'vlf-after-chunk-update 'vlf-hexl-enable)
(eval-after-load "hexl"
'(progn
- [elpa] externals/vlf 1a1ce27 212/310: Add progress reporters for the optimized part of line search., (continued)
- [elpa] externals/vlf 1a1ce27 212/310: Add progress reporters for the optimized part of line search., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf e747de4 204/310: Unify and optimize deletion., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 9510c70 215/310: Retry decoding when the initial attempt seems wrong., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 5c604c4 211/310: Optimize vlf-goto-line not to decode batches as long as possible., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf a71ee32 216/310: Skip adjustment in some cases of overlapping chunk., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf b235cf9 224/310: Execute vlf-after-batch-functions hook even on user quit command before, Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 6bb60b7 225/310: Fix hexl scroll up called from scroll down behavior., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 924d6b1 219/310: Revert to using insert-file-contents instead of manual decoding., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 859c1e4 223/310: Fix hook names., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 694d1de 235/310: Allow vlf-occur results be saved to file and later reused., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 274c5ab 233/310: Perform search, occur and ediff operations over hexl content instead,
Stefan Monnier <=
- [elpa] externals/vlf d9cc6fb 264/310: Fix vlf-tune-optimal-load in case best value prunes slower times leaving, Stefan Monnier, 2020/11/28
- [elpa] externals/vlf d1a6800 284/310: Move vlf information from buffer name to the mode line., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf a7be713 283/310: Set vlf-tune-max with proper value in case RAM size is wrongly, Stefan Monnier, 2020/11/28
- [elpa] externals/vlf bc398d6 291/310: - don't adjust start on next occur batch, Stefan Monnier, 2020/11/28
- [elpa] externals/vlf a01e9ed 304/310: Minor README additions., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 31b292d 305/310: fixed large-file-warning-threshold error, Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 63d23ac 309/310: Make vlf handle nil large-file-warning-threshold value, Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 70a8107 243/310: Add vlf-batch-size tuning in vlf-occur., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf f3212ec 251/310: Fix measure approximation and allow tuning to just over half file, Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 11c7af4 253/310: Change handling of measurement values to support approximations., Stefan Monnier, 2020/11/28