From 0dc6d0643e09e20175637215401b3191f6f8729e Mon Sep 17 00:00:00 2001 From: Andrey Kotlarski Date: Tue, 7 Jan 2014 01:47:39 +0200 Subject: [PATCH] Completely decouple vlf integration from other functionality. --- README.org | 10 ++++++++-- vlf-base.el | 5 +++++ vlf.el | 16 ++++++++++------ 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/README.org b/README.org index 538d44f..4c6abac 100644 --- a/README.org +++ b/README.org @@ -47,7 +47,13 @@ integer value). ** Applicability -You can control when vlf-mode is invoked or offered as choice with the +To have *vlf* offered as choice when opening large files: + +#+BEGIN_EXAMPLE +(require 'vlf-integrate) +#+END_EXAMPLE + +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 @@ -70,7 +76,7 @@ To disable automatic usage of VLF for a function, for example named *func* defined in file *file.el*: #+BEGIN_EXAMPLE -(vlf-disable-for-function func "file.el") +(vlf-disable-for-function func "file") #+END_EXAMPLE ** Keymap diff --git a/vlf-base.el b/vlf-base.el index fbc27ba..e78c199 100644 --- a/vlf-base.el +++ b/vlf-base.el @@ -35,6 +35,11 @@ (t ;; TODO: use (< emacs-minor-version 4) after 24.4 release (string-lessp emacs-version "24.3.5"))) "Indicates whether partial decode codes are displayed.") +(unless (fboundp 'file-size-human-readable) + (defun file-size-human-readable (file-size) + "Print FILE-SIZE in MB." + (format "%.3fMB" (/ file-size 1048576.0)))) + (defun vlf-move-to-chunk (start end &optional minimal) "Move to chunk determined by START END. diff --git a/vlf.el b/vlf.el index 467bece..015f67a 100644 --- a/vlf.el +++ b/vlf.el @@ -26,10 +26,12 @@ ;; Boston, MA 02111-1307, USA. ;;; Commentary: -;; This package provides the M-x vlf command, which visits part of a -;; large file without loading the entire file. -;; The buffer uses VLF mode, which defines several commands for +;; This package provides the M-x vlf command, which visits part of +;; large file without loading it entirely. +;; The buffer uses VLF mode, which provides several commands for ;; moving around, searching and editing selected part of file. +;; To have it offered when opening large files: +;; (require 'vlf-integrate) ;; This package was inspired by a snippet posted by Kevin Rodgers, ;; showing how to use `insert-file-contents' to extract part of a @@ -37,11 +39,13 @@ ;;; Code: -;;;###autoload -(require 'vlf-integrate) - (require 'vlf-base) +(defgroup vlf nil + "View Large Files in Emacs." + :prefix "vlf-" + :group 'files) + (defcustom vlf-batch-size 1024 "Defines how large each batch of file data is (in bytes)." :group 'vlf