1
0
mirror of https://github.com/m00natic/vlfi.git synced 2025-04-18 16:50:19 +01:00

Show paging according to batch size instead of percentage.

This commit is contained in:
Andrey Kotlarski 2013-04-12 01:01:42 +03:00
parent 24675d8741
commit 8787186619

11
vlfi.el
View File

@ -101,10 +101,11 @@ with the prefix argument DECREASE it is halved."
(defun vlfi-format-buffer-name () (defun vlfi-format-buffer-name ()
"Return format for vlfi buffer name." "Return format for vlfi buffer name."
(format "%s(%s)[%.2f%%%%](%d)" (format "%s(%s)[%d/%d](%d)"
(file-name-nondirectory buffer-file-name) (file-name-nondirectory buffer-file-name)
(file-size-human-readable vlfi-file-size) (file-size-human-readable vlfi-file-size)
(/ (* 100 vlfi-end-pos) (float vlfi-file-size)) (/ vlfi-end-pos vlfi-batch-size)
(/ vlfi-file-size vlfi-batch-size)
vlfi-batch-size)) vlfi-batch-size))
(defun vlfi-update-buffer-name () (defun vlfi-update-buffer-name ()
@ -120,7 +121,7 @@ When prefix argument is negative
(interactive "p") (interactive "p")
(let ((end (+ vlfi-end-pos (* vlfi-batch-size (let ((end (+ vlfi-end-pos (* vlfi-batch-size
(abs append))))) (abs append)))))
(when (< vlfi-file-size end) ; re-check file size (when (< vlfi-file-size end) ; re-check file size
(setq vlfi-file-size (nth 7 (file-attributes buffer-file-name))) (setq vlfi-file-size (nth 7 (file-attributes buffer-file-name)))
(cond ((= vlfi-end-pos vlfi-file-size) (cond ((= vlfi-end-pos vlfi-file-size)
(error "Already at EOF")) (error "Already at EOF"))
@ -197,7 +198,7 @@ Adjust according to file start/end and show `vlfi-batch-size' bytes."
(defun vlfi-move-to-chunk (start end) (defun vlfi-move-to-chunk (start end)
"Move to chunk determined by START END." "Move to chunk determined by START END."
(if (< vlfi-file-size end) ; re-check file size (if (< vlfi-file-size end) ; re-check file size
(setq vlfi-file-size (nth 7 (setq vlfi-file-size (nth 7
(file-attributes buffer-file-name)))) (file-attributes buffer-file-name))))
(setq vlfi-start-pos (max 0 start) (setq vlfi-start-pos (max 0 start)
@ -452,7 +453,7 @@ Remaining part of the file ["
(goto-char (point-max)) (goto-char (point-max))
(insert-file-contents buffer-file-name nil (insert-file-contents buffer-file-name nil
vlfi-end-pos vlfi-file-size) vlfi-end-pos vlfi-file-size)
(when (< 0 size-change) ; pad with empty characters (when (< 0 size-change) ; pad with empty characters
(goto-char (point-max)) (goto-char (point-max))
(insert-char 32 size-change)) (insert-char 32 size-change))
(vlfi-write-1) (vlfi-write-1)