2013-08-06 02:02:02 +03:00
|
|
|
* View Large Files
|
2013-01-12 17:05:25 +02:00
|
|
|
|
2014-01-21 01:34:32 +02:00
|
|
|
Emacs minor mode that allows viewing, editing, searching and comparing
|
2014-09-07 22:16:06 +03:00
|
|
|
large files in batches, trading memory for processor time. Batch size
|
|
|
|
can be adjusted on the fly and bounds the memory that is to be used
|
|
|
|
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.
|
2013-02-02 16:12:30 +02:00
|
|
|
|
2014-02-23 00:32:11 +02:00
|
|
|
This is development version of the GNU ELPA [[http://elpa.gnu.org/packages/vlf][VLF]] package. Here's what
|
|
|
|
it offers in a nutshell:
|
2013-04-14 19:55:39 +03:00
|
|
|
|
2014-09-26 14:14:16 +03:00
|
|
|
- automatic adjustment of batch size for optimal performance and
|
|
|
|
responsiveness
|
|
|
|
- regular expression search and replace over whole file
|
|
|
|
- [[http://www.emacswiki.org/emacs/OccurMode][Occur]] like indexing
|
|
|
|
- by batch [[http://www.emacswiki.org/emacs/EdiffMode][Ediff]] comparison
|
|
|
|
- automatic scrolling of batches
|
2014-08-10 18:48:36 +03:00
|
|
|
- chunk editing (save is immediate if size hasn't changed, done in
|
|
|
|
constant memory determined by current batch size otherwise)
|
2013-04-13 23:10:47 +03:00
|
|
|
- options to jump to beginning, end or arbitrary file chunk
|
2014-09-26 14:14:16 +03:00
|
|
|
- smooth integration with [[http://www.emacswiki.org/emacs/HexlMode][hexl-mode]]
|
|
|
|
- works with [[http://www.emacswiki.org/emacs/TrampMode][TRAMP]] so accessing network files is fine and quick
|
2013-04-13 23:10:47 +03:00
|
|
|
- newly added content is acknowledged if file has changed size
|
|
|
|
meanwhile
|
2014-08-10 18:48:36 +03:00
|
|
|
- as it's a minor mode, font locking and functionality of the
|
2014-09-26 14:14:16 +03:00
|
|
|
respective major mode and other minor modes is also present
|
2014-02-23 00:32:11 +02:00
|
|
|
- can be added as option to automatically open large files
|
2013-04-17 12:33:04 +03:00
|
|
|
|
|
|
|
GNU Emacs 23 and 24 are supported.
|
|
|
|
|
|
|
|
* Overview and tips
|
|
|
|
|
2013-08-25 17:57:43 +03:00
|
|
|
M-x vlf PATH-TO-FILE
|
2013-04-17 12:33:04 +03:00
|
|
|
|
2013-04-17 13:11:40 +03:00
|
|
|
** Unicode
|
|
|
|
|
2013-04-17 12:33:04 +03:00
|
|
|
Emacs' Unicode support is leveraged so you'll not see bare bytes but
|
2013-04-17 13:11:40 +03:00
|
|
|
characters decoded as if file is normally opened. This holds for
|
2014-02-23 00:32:11 +02:00
|
|
|
editing, search, indexing and comparison.
|
2013-04-17 12:33:04 +03:00
|
|
|
|
2013-05-02 14:25:39 +03:00
|
|
|
** 32-bit GNU Emacs
|
2013-04-17 13:11:40 +03:00
|
|
|
|
2013-05-01 02:02:28 +03:00
|
|
|
Regular Emacs integers are used, so if you use 32-bit Emacs without
|
2014-02-23 00:32:11 +02:00
|
|
|
bignum support, *VLF* will not work with files over 512 MB (maximum
|
2014-01-01 15:43:14 +02:00
|
|
|
integer value).
|
2013-04-17 13:11:40 +03:00
|
|
|
|
2013-04-17 12:33:04 +03:00
|
|
|
* Detail usage
|
|
|
|
|
2013-12-11 03:21:08 +02:00
|
|
|
** Applicability
|
|
|
|
|
2014-01-07 01:47:39 +02:00
|
|
|
To have *vlf* offered as choice when opening large files:
|
|
|
|
|
2014-09-07 22:16:06 +03:00
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
|
|
(require 'vlf-integrate)
|
|
|
|
#+END_SRC
|
2014-01-07 01:47:39 +02:00
|
|
|
|
2014-02-23 00:32:11 +02:00
|
|
|
You can control when *vlf-mode* is invoked or offered with the
|
|
|
|
*vlf-application* customization option. By default it will offer
|
|
|
|
*VLF* when opening large files. There are also options to never use
|
|
|
|
it (you can still call *vlf* command explicitly); to use it without
|
|
|
|
asking for large files or to invoke it on all files. Here's example
|
|
|
|
setup such that *vlf-mode* automatically launches for large files:
|
2013-12-11 03:21:08 +02:00
|
|
|
|
2014-09-07 22:16:06 +03:00
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
|
|
(custom-set-variables
|
|
|
|
'(vlf-application 'dont-ask))
|
|
|
|
#+END_SRC
|
2013-12-11 03:21:08 +02:00
|
|
|
|
2014-01-01 16:47:04 +02:00
|
|
|
*** Disable for specific mode
|
|
|
|
|
2014-02-23 00:32:11 +02:00
|
|
|
To disable automatic usage of *VLF* for a major mode, add it to
|
2014-01-01 16:47:04 +02:00
|
|
|
*vlf-forbidden-modes-list*.
|
|
|
|
|
|
|
|
*** Disable for specific function
|
|
|
|
|
2014-02-23 00:32:11 +02:00
|
|
|
To disable automatic usage of *VLF* for a function, for example named
|
2014-01-01 16:47:04 +02:00
|
|
|
*func* defined in file *file.el*:
|
|
|
|
|
2014-09-07 22:16:06 +03:00
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
|
|
(vlf-disable-for-function func "file")
|
|
|
|
#+END_SRC
|
2014-01-01 16:47:04 +02:00
|
|
|
|
2013-12-11 03:21:08 +02:00
|
|
|
** Keymap
|
|
|
|
|
2014-02-23 00:32:11 +02:00
|
|
|
All *VLF* operations are grouped under the *C-c C-v* prefix by
|
|
|
|
default. Here's example how to add another prefix (*C-x v*):
|
2013-12-11 03:21:08 +02:00
|
|
|
|
2014-09-07 22:16:06 +03:00
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
|
|
(eval-after-load "vlf"
|
|
|
|
'(define-key vlf-prefix-map "\C-xv" vlf-mode-map))
|
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
** Batch size control
|
|
|
|
|
|
|
|
By default *VLF* gathers statistics over how primitive operations
|
|
|
|
perform over file and gradually adjusts batch size for better user
|
|
|
|
experience. Operations involving multiple batches are tuned more
|
|
|
|
adventurously. Overall the more jumping around, searching, indexing,
|
|
|
|
the better performance should get.
|
|
|
|
|
|
|
|
The *vlf-tune-max* option specifies maximum size in bytes a batch
|
|
|
|
could eventually get while tuning.
|
|
|
|
|
|
|
|
Profiling and tuning can be disabled by:
|
|
|
|
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
|
|
(custom-set-variables
|
|
|
|
'(vlf-tune-enabled nil))
|
|
|
|
#+END_SRC
|
2013-12-11 03:21:08 +02:00
|
|
|
|
2014-09-07 22:16:06 +03:00
|
|
|
Or set *vlf-tune-enabled* to '*stats* to profile but not change batch
|
|
|
|
size.
|
2013-04-17 12:33:04 +03:00
|
|
|
|
2014-01-21 01:32:21 +02:00
|
|
|
Use *M-x vlf-set-batch-size* to change batch size and update chunk
|
2014-09-07 22:16:06 +03:00
|
|
|
immediately. Default size offered is the best according to tune
|
|
|
|
statistics so far.
|
2014-01-21 01:32:21 +02:00
|
|
|
|
2013-12-03 02:54:33 +02:00
|
|
|
*C-c C-v +* and *C-c C-v -* control current batch size by factors
|
|
|
|
of 2.
|
2013-04-17 12:33:04 +03:00
|
|
|
|
2013-04-17 13:19:37 +03:00
|
|
|
** Move around
|
2013-04-17 12:33:04 +03:00
|
|
|
|
2014-08-10 18:48:36 +03:00
|
|
|
Scrolling automatically triggers move to previous or next chunk at the
|
|
|
|
beginning or end respectively of the current one.
|
2013-12-13 17:22:10 +02:00
|
|
|
|
2013-12-11 03:21:08 +02:00
|
|
|
*C-c C-v n* and *C-c C-v p* move batch by batch. With positive
|
2013-12-03 02:54:33 +02:00
|
|
|
prefix argument they move prefix number of batches. With negative -
|
|
|
|
append prefix number of batches.
|
2013-04-17 12:33:04 +03:00
|
|
|
|
2013-12-11 03:21:08 +02:00
|
|
|
*C-c C-v SPC* displays batch starting from current point.
|
2013-12-07 20:18:07 +02:00
|
|
|
|
2013-12-03 02:54:33 +02:00
|
|
|
*C-c C-v [* and *C-c C-v ]* take you to the beginning and end of file
|
|
|
|
respectively.
|
2013-04-17 12:33:04 +03:00
|
|
|
|
2013-12-03 02:54:33 +02:00
|
|
|
*C-c C-v j* jumps to given chunk. To see where you are in file and
|
|
|
|
how many chunks there are (using the current batch size), look at the
|
2013-12-04 14:00:24 +02:00
|
|
|
parenthesized part of the buffer name, batch size is also indicated at
|
|
|
|
the end.
|
2013-04-17 12:33:04 +03:00
|
|
|
|
2013-12-13 17:22:10 +02:00
|
|
|
** Follow point
|
|
|
|
|
2014-01-01 15:43:14 +02:00
|
|
|
Continuous chunk recenter around point in current buffer can be
|
|
|
|
toggled with *C-c C-v f*.
|
2013-12-13 17:22:10 +02:00
|
|
|
|
2014-09-26 14:14:16 +03:00
|
|
|
** Search and/or replace whole file
|
2013-04-17 12:33:04 +03:00
|
|
|
|
2013-12-03 02:54:33 +02:00
|
|
|
*C-c C-v s* and *C-c C-v r* search forward and backward respectively
|
2014-09-26 14:14:16 +03:00
|
|
|
over the whole file, batch by batch. *C-c C-v %* does search and
|
|
|
|
query replace saving intermediate changes.
|
2013-04-17 12:33:04 +03:00
|
|
|
|
2013-05-01 02:02:28 +03:00
|
|
|
** Occur over whole file
|
|
|
|
|
2014-09-07 22:16:06 +03:00
|
|
|
*C-c C-v o* builds index over whole file for given regular expression
|
|
|
|
just like *M-x occur*. Note that even if you prematurely stop it with
|
|
|
|
*C-g*, it will still show what's found so far.
|
2013-05-01 02:02:28 +03:00
|
|
|
|
2014-08-17 22:45:09 +03:00
|
|
|
Result buffer uses *vlf-occur-mode* which allows to optionally open
|
2014-09-07 22:16:06 +03:00
|
|
|
new *VLF* buffer on jump to match (using *C-u* before hitting RET or
|
|
|
|
*o*), thus having multiple simultaneous views of the same file. Also
|
|
|
|
results can be serialized to file for later reuse.
|
2014-08-17 22:45:09 +03:00
|
|
|
|
2013-05-02 14:25:39 +03:00
|
|
|
** Jump to line
|
|
|
|
|
2014-09-07 22:16:06 +03:00
|
|
|
*C-c C-v l* jumps to given line in file. With negative argument,
|
|
|
|
lines are counted from the end of file.
|
2013-05-02 14:25:39 +03:00
|
|
|
|
2013-12-03 02:54:33 +02:00
|
|
|
** Edit and save
|
2013-04-17 12:33:04 +03:00
|
|
|
|
2013-12-03 02:54:33 +02:00
|
|
|
If editing doesn't change size of the chunk, only this chunk is saved.
|
2014-09-07 22:16:06 +03:00
|
|
|
Otherwise the remaining part of the file is adjusted batch by batch.
|
2014-09-26 14:14:16 +03:00
|
|
|
*vlf-save-in-place* customization option controls if temporary file
|
|
|
|
should be used in such case.
|
2014-01-13 01:35:01 +02:00
|
|
|
|
|
|
|
** By batch Ediff
|
|
|
|
|
|
|
|
Use *M-x vlf-ediff-files* and *M-x vlf-ediff-buffers* to compare
|
|
|
|
files/buffers batch by batch (batch size is queried in case of files
|
|
|
|
or taken from the first buffer in case of buffers). Moving after the
|
|
|
|
last difference in current chunk searches for following one with
|
|
|
|
difference. The other way around if looking for difference before the
|
|
|
|
first one.
|
2014-02-23 00:32:11 +02:00
|
|
|
|
2014-09-26 14:14:16 +03:00
|
|
|
* Extend
|
2014-02-23 00:32:11 +02:00
|
|
|
|
|
|
|
** Move hooks
|
|
|
|
|
|
|
|
A couple of hooks are run whenever updating chunk:
|
|
|
|
*vlf-before-chunk-update* and *vlf-after-chunk-update*.
|
|
|
|
|
|
|
|
** Batch move hooks
|
|
|
|
|
|
|
|
Some operations may trigger multiple chunk moves. There are a couple
|
|
|
|
of hooks that run in such cases: *vlf-before-batch-functions* and
|
2014-08-10 18:48:36 +03:00
|
|
|
*vlf-after-batch-functions*. They are passed one argument which
|
2014-02-23 00:32:11 +02:00
|
|
|
specifies type of operation that runs. Possible values are the
|
|
|
|
symbols: *write*, *ediff*, *occur*, *search* and *goto-line*.
|