;;; Code:
-(defgroup vlf nil
- "View Large Files in Emacs."
- :prefix "vlf-"
- :group 'files)
+(defgroup vlf nil "View Large Files in Emacs."
+ :prefix "vlf-" :group 'files)
+
+(defcustom vlf-batch-size 1000000
+ "Defines how large each batch of file data initially is (in bytes)."
+ :group 'vlf :type 'integer)
(defcustom vlf-application 'ask
"Determines when `vlf' will be offered on opening files.
`ask' offer `vlf' when file size is beyond `large-file-warning-threshold';
`dont-ask' automatically use `vlf' for large files;
`always' use `vlf' for all files."
- :group 'vlf
- :type '(radio (const :format "%v " nil)
- (const :format "%v " ask)
- (const :format "%v " dont-ask)
- (const :format "%v" always)))
+ :group 'vlf :type '(radio (const :format "%v " nil)
+ (const :format "%v " ask)
+ (const :format "%v " dont-ask)
+ (const :format "%v" always)))
(defcustom vlf-forbidden-modes-list
'(archive-mode tar-mode jka-compr git-commit-mode image-mode
doc-view-mode doc-view-mode-maybe ebrowse-tree-mode)
"Major modes which VLF will not be automatically applied to."
- :group 'vlf
- :type '(list symbol))
+ :group 'vlf :type '(list symbol))
(unless (fboundp 'file-size-human-readable)
(defun file-size-human-readable (file-size)
(cadr mode)
mode)))
+(autoload 'vlf "vlf" "View Large FILE in batches." t)
+
(defadvice abort-if-file-too-large (around vlf-if-file-too-large
compile activate)
"If file SIZE larger than `large-file-warning-threshold', \
(vlf filename)
(error ""))
((and large-file-warning-threshold
- (< large-file-warning-threshold size))
+ (< large-file-warning-threshold size)
+ (< vlf-batch-size size))
(if (eq vlf-application 'dont-ask)
(progn (vlf filename)
(error ""))
((memq char '(?a ?A))
(error "Aborted"))))))))
-(eval-after-load "etags"
- '(progn
- (defadvice tags-verify-table (around vlf-tags-verify-table
- compile activate)
- "Temporarily disable `vlf-mode'."
- (let ((vlf-application nil))
- ad-do-it))
-
- (defadvice tag-find-file-of-tag-noselect
- (around vlf-tag-find-file-of-tag compile activate)
- "Temporarily disable `vlf-mode'."
- (let ((vlf-application nil))
- ad-do-it))))
-
+;; disable for some functions
+(defmacro vlf-disable-for-function (func file)
+ "Build advice to disable VLF during execution of FUNC\
+defined in FILE."
+ `(eval-after-load ,file
+ '(defadvice ,func (around ,(intern (concat "vlf-"
+ (symbol-name func)))
+ compile activate)
+ "Temporarily disable `vlf-mode'."
+ (let ((vlf-application nil))
+ ad-do-it))))
+
+(vlf-disable-for-function tags-verify-table "etags")
+(vlf-disable-for-function tag-find-file-of-tag-noselect "etags")
+(vlf-disable-for-function helm-etags-create-buffer "helm-tags")
+
+;; dired
(defun dired-vlf ()
"In Dired, visit the file on this line in VLF mode."
(interactive)