1
0
mirror of https://github.com/m00natic/vlfi.git synced 2025-01-18 12:05:31 +00:00

Enlarge default batch size but keep is small on initial load of remote

files and on demand.
This commit is contained in:
Andrey Kotlarski 2014-08-23 00:09:44 +03:00
parent 569e4b2523
commit 2e9ff70d56
5 changed files with 16 additions and 12 deletions

View File

@ -27,7 +27,7 @@
;;; Code: ;;; Code:
(defcustom vlf-batch-size 1024 (defcustom vlf-batch-size 1000000
"Defines how large each batch of file data initially is (in bytes)." "Defines how large each batch of file data initially is (in bytes)."
:group 'vlf :type 'integer) :group 'vlf :type 'integer)
(put 'vlf-batch-size 'permanent-local t) (put 'vlf-batch-size 'permanent-local t)

View File

@ -34,7 +34,6 @@
"If non nil, specifies that ediff is done over VLF buffers.") "If non nil, specifies that ediff is done over VLF buffers.")
(make-variable-buffer-local 'vlf-ediff-session) (make-variable-buffer-local 'vlf-ediff-session)
;;;###autoload
(defun vlf-ediff-buffers (buffer-A buffer-B) (defun vlf-ediff-buffers (buffer-A buffer-B)
"Run batch by batch ediff over VLF buffers BUFFER-A and BUFFER-B. "Run batch by batch ediff over VLF buffers BUFFER-A and BUFFER-B.
Batch size is determined by the size in BUFFER-A. Batch size is determined by the size in BUFFER-A.
@ -93,10 +92,10 @@ respectively of difference list, runs ediff over the adjacent chunks."
dir-B))) dir-B)))
(ediff-get-default-file-name f 1))) (ediff-get-default-file-name f 1)))
(read-number "Batch size (in bytes): " vlf-batch-size)))) (read-number "Batch size (in bytes): " vlf-batch-size))))
(let ((buffer-A (vlf file-A))) (let ((buffer-A (vlf file-A t)))
(set-buffer buffer-A) (set-buffer buffer-A)
(vlf-set-batch-size batch-size) (vlf-set-batch-size batch-size)
(let ((buffer-B (vlf file-B))) (let ((buffer-B (vlf file-B t)))
(vlf-ediff-buffers buffer-A buffer-B)))) (vlf-ediff-buffers buffer-A buffer-B))))
(defadvice ediff-next-difference (around vlf-ediff-next-difference (defadvice ediff-next-difference (around vlf-ediff-next-difference

View File

@ -29,7 +29,7 @@
(defgroup vlf nil "View Large Files in Emacs." (defgroup vlf nil "View Large Files in Emacs."
:prefix "vlf-" :group 'files) :prefix "vlf-" :group 'files)
(defcustom vlf-batch-size 1024 (defcustom vlf-batch-size 1000000
"Defines how large each batch of file data initially is (in bytes)." "Defines how large each batch of file data initially is (in bytes)."
:group 'vlf :type 'integer) :group 'vlf :type 'integer)

View File

@ -123,7 +123,7 @@ EVENT may hold details of the invocation."
(match-pos (+ (get-text-property pos 'line-pos) (match-pos (+ (get-text-property pos 'line-pos)
pos-relative))) pos-relative)))
(cond (current-prefix-arg (cond (current-prefix-arg
(setq vlf-buffer (vlf file)) (setq vlf-buffer (vlf file t))
(or not-hexl (hexl-mode)) (or not-hexl (hexl-mode))
(switch-to-buffer occur-buffer)) (switch-to-buffer occur-buffer))
((not (buffer-live-p vlf-buffer)) ((not (buffer-live-p vlf-buffer))
@ -136,7 +136,7 @@ EVENT may hold details of the invocation."
not-hexl) not-hexl)
(setq vlf-buffer buf) (setq vlf-buffer buf)
(throw 'found t)))) (throw 'found t))))
(setq vlf-buffer (vlf file)) (setq vlf-buffer (vlf file t))
(or not-hexl (hexl-mode))) (or not-hexl (hexl-mode)))
(switch-to-buffer occur-buffer) (switch-to-buffer occur-buffer)
(setq vlf-occur-vlf-buffer vlf-buffer))) (setq vlf-occur-vlf-buffer vlf-buffer)))

15
vlf.el
View File

@ -145,17 +145,22 @@ values are: `write', `ediff', `occur', `search', `goto-line'."
(setq vlf-mode t)) (setq vlf-mode t))
;;;###autoload ;;;###autoload
(defun vlf (file) (defun vlf (file &optional minimal)
"View Large FILE in batches. "View Large FILE in batches. When MINIMAL load just a few bytes.
You can customize number of bytes displayed by customizing You can customize number of bytes displayed by customizing
`vlf-batch-size'. `vlf-batch-size'.
Return newly created buffer." Return newly created buffer."
(interactive "fFile to open: ") (interactive (list (read-file-name "File to open: ") nil))
(let ((vlf-buffer (generate-new-buffer "*vlf*"))) (let ((vlf-buffer (generate-new-buffer "*vlf*")))
(set-buffer vlf-buffer) (set-buffer vlf-buffer)
(set-visited-file-name file) (set-visited-file-name file)
(set-buffer-modified-p nil) (set-buffer-modified-p nil)
(if (or minimal (file-remote-p file))
(set (make-local-variable 'vlf-batch-size) 1024))
(vlf-mode 1) (vlf-mode 1)
(when minimal ;restore batch size to default value
(kill-local-variable 'vlf-batch-size)
(make-local-variable 'vlf-batch-size))
(switch-to-buffer vlf-buffer) (switch-to-buffer vlf-buffer)
vlf-buffer)) vlf-buffer))
@ -263,8 +268,8 @@ with the prefix argument DECREASE it is halved."
(vlf-verify-size) (vlf-verify-size)
(vlf-move-to-batch vlf-file-size)) (vlf-move-to-batch vlf-file-size))
(defun vlf-revert (&optional _ignore-auto noconfirm) (defun vlf-revert (&optional _auto noconfirm)
"Revert current chunk. Ignore _IGNORE-AUTO. "Revert current chunk. Ignore _AUTO.
Ask for confirmation if NOCONFIRM is nil." Ask for confirmation if NOCONFIRM is nil."
(interactive) (interactive)
(when (or noconfirm (when (or noconfirm