mirror of
https://github.com/m00natic/vlfi.git
synced 2025-11-15 06:15:34 +00:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a01e9ed416 | ||
|
|
25e16ef85d | ||
|
|
df677c128f | ||
|
|
b62bc04612 | ||
|
|
55e0c404c8 | ||
|
|
eaa3629227 | ||
|
|
a8ba8363b2 |
@@ -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
|
||||
|
||||
20
vlf-base.el
20
vlf-base.el
@@ -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
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
14
vlf.el
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user