1
0
mirror of https://github.com/m00natic/vlfi.git synced 2025-11-15 06:15:34 +00:00

7 Commits
1.7 ... 1.7.1

Author SHA1 Message Date
Andrey Kotlarski
a01e9ed416 Minor README additions. 2017-11-20 23:25:27 +02:00
George D. Plymale II
25e16ef85d Fix broken link in README
This fixes the link to the ELPA page.
2017-11-20 23:24:33 +02:00
Dan Harms
df677c128f Issue 35: make mode-line batch indicators more accurate 2017-08-30 21:48:26 +03:00
Dan Harms
b62bc04612 Issue 31 Make vlf-batch-size configurable in the remote case 2017-07-14 02:52:01 +03:00
Andrey Kotlarski
55e0c404c8 Explicitly set coding-system-for-read to the current coding when not
inserting from the beginning.
2017-05-01 19:32:18 +03:00
Nil Geisweiller
eaa3629227 Fix cursor position after search
After searching forward (resp. backward) the cursor should be at the
end (resp. the beginning) of the match. That way one can jump to the
next match by running again the command.
2017-03-31 02:13:14 +03:00
Andrey Kotlarski
a8ba8363b2 Fix issue where tramp-verbose is bound to nil. 2016-10-30 17:40:59 +02:00
6 changed files with 37 additions and 19 deletions

View File

@@ -7,7 +7,7 @@ for operations on the file. This way multiple large files (like
terabytes or whatever) can be instantly and simultaneously accessed
without swapping and degraded performance.
This is development version of the GNU ELPA [[http://elpa.gnu.org/packages/vlf][VLF]] package. Here's what
This is development version of the GNU ELPA [[https://elpa.gnu.org/packages/vlf.html][VLF]] package. Here's what
it offers in a nutshell:
- automatic adjustment of batch size for optimal performance and
@@ -19,7 +19,9 @@ it offers in a nutshell:
- chunk editing (save is immediate if size hasn't changed, done in
constant memory determined by current batch size otherwise)
- options to jump to beginning, end or arbitrary file chunk
- smooth integration with [[http://www.emacswiki.org/emacs/HexlMode][hexl-mode]]
- proper dealing with multibyte encodings
- smooth integration with [[http://www.emacswiki.org/emacs/HexlMode][hexl-mode]], just turn it on and the HEX
editing will work in batches just the same
- works with [[http://www.emacswiki.org/emacs/TrampMode][TRAMP]] so accessing network files is fine and quick
- newly added content is acknowledged if file has changed size
meanwhile

View File

@@ -1,6 +1,6 @@
;;; vlf-base.el --- VLF primitive operations -*- lexical-binding: t -*-
;; Copyright (C) 2014-2015 Free Software Foundation, Inc.
;; Copyright (C) 2014-2017 Free Software Foundation, Inc.
;; Keywords: large files, chunk
;; Author: Andrey Kotlarski <m00naticus@gmail.com>
@@ -270,9 +270,11 @@ to the beginning, ADJUST-END - append to the end.
Use buffer POSITION as start if given.
Return number of bytes moved back for proper decoding and number of
bytes added to the end."
(setq adjust-start (and adjust-start (not (zerop start)))
adjust-end (and adjust-end (/= end vlf-file-size))
(setq adjust-end (and adjust-end (/= end vlf-file-size))
position (or position (point-min)))
(and adjust-start (<= start 4)
(setq adjust-start nil
start 0))
(goto-char position)
(let ((shift-start 0)
(shift-end 0)
@@ -294,7 +296,10 @@ bytes added to the end."
(defun vlf-insert-file-contents-1 (start end)
"Extract decoded file bytes START to END."
(vlf-tune-insert-file-contents start end))
(if (zerop start)
(vlf-tune-insert-file-contents start end)
(let ((coding-system-for-read buffer-file-coding-system))
(vlf-tune-insert-file-contents start end))))
(defun vlf-adjust-start (start end position adjust-end)
"Adjust chunk beginning at absolute START to END till content can\
@@ -307,9 +312,10 @@ Return number of bytes moved back for proper decoding."
(strict (or (= sample-end vlf-file-size)
(and (not adjust-end) (= sample-end end))))
(shift 0))
(while (and (progn (insert-file-contents buffer-file-name
nil safe-start sample-end)
(not (zerop safe-start)))
(while (and (let ((coding-system-for-read buffer-file-coding-system))
(insert-file-contents buffer-file-name
nil safe-start sample-end)
(not (zerop safe-start)))
(< shift 3)
(let ((diff (- chunk-size
(length

View File

@@ -170,7 +170,8 @@ logical chunks in case there is no difference at the current ones."
(setq buffer-B (current-buffer)
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)
(let ((tramp-verbose (if (and (boundp 'tramp-verbose)
tramp-verbose)
(min tramp-verbose 1)))
(end-B (= vlf-start-pos vlf-end-pos))
(chunk-B (cons vlf-start-pos vlf-end-pos))

View File

@@ -206,7 +206,8 @@ Prematurely ending indexing will still show what's found so far."
(defun vlf-build-occur (regexp vlf-buffer)
"Build occur style index for REGEXP over VLF-BUFFER."
(let* ((tramp-verbose (if (boundp 'tramp-verbose)
(let* ((tramp-verbose (if (and (boundp 'tramp-verbose)
tramp-verbose)
(min tramp-verbose 1)))
(case-fold-search t)
(line 1)

View File

@@ -48,7 +48,8 @@ Return t if search has been at least partially successful."
vlf-start-pos)
vlf-file-size)))
(or time (setq time (float-time)))
(let* ((tramp-verbose (if (boundp 'tramp-verbose)
(let* ((tramp-verbose (if (and (boundp 'tramp-verbose)
tramp-verbose)
(min tramp-verbose 1)))
(case-fold-search t)
(match-chunk-start vlf-start-pos)
@@ -139,10 +140,10 @@ Return t if search has been at least partially successful."
(let ((result
(if backward
(vlf-goto-match match-chunk-start match-chunk-end
match-end-pos match-start-pos
match-start-pos match-end-pos
count to-find time highlight)
(vlf-goto-match match-chunk-start match-chunk-end
match-start-pos match-end-pos
match-end-pos match-start-pos
count to-find time highlight))))
(run-hook-with-args 'vlf-after-batch-functions 'search)
result)))))
@@ -215,7 +216,8 @@ Search is performed chunk by chunk in `vlf-batch-size' memory."
(vlf-goto-line-hexl n)
(run-hook-with-args 'vlf-before-batch-functions 'goto-line)
(vlf-verify-size)
(let ((tramp-verbose (if (boundp 'tramp-verbose)
(let ((tramp-verbose (if (and (boundp 'tramp-verbose)
tramp-verbose)
(min tramp-verbose 1)))
(start-pos vlf-start-pos)
(end-pos vlf-end-pos)

14
vlf.el
View File

@@ -53,6 +53,10 @@ One argument is supplied that specifies current action. Possible
values are: `write', `ediff', `occur', `search', `goto-line'."
:group 'vlf :type 'hook)
(defcustom vlf-batch-size-remote 1024
"Defines size (in bytes) of a batch of file data when accessed remotely."
:group 'vlf :type 'integer)
(defvar hexl-bits)
(autoload 'vlf-write "vlf-write" "Write current chunk to file." t)
@@ -105,8 +109,8 @@ values are: `write', `ediff', `occur', `search', `goto-line'."
"Mode to browse large files in."
:group 'vlf :keymap vlf-prefix-map
:lighter (:eval (format " VLF[%d/%d](%s)"
(/ vlf-end-pos vlf-batch-size)
(/ vlf-file-size vlf-batch-size)
(ceiling vlf-end-pos vlf-batch-size)
(ceiling vlf-file-size vlf-batch-size)
(file-size-human-readable vlf-file-size)))
(cond (vlf-mode
(set (make-local-variable 'require-final-newline) nil)
@@ -172,8 +176,10 @@ Return newly created buffer."
(set-buffer vlf-buffer)
(set-visited-file-name file)
(set-buffer-modified-p nil)
(if (or minimal (file-remote-p file))
(set (make-local-variable 'vlf-batch-size) 1024))
(cond (minimal
(set (make-local-variable 'vlf-batch-size) 1024))
((file-remote-p file)
(set (make-local-variable 'vlf-batch-size) vlf-batch-size-remote)))
(vlf-mode 1)
(when minimal ;restore batch size to default value
(kill-local-variable 'vlf-batch-size)