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

Minor adjustments:

- fix batch position formatting
- unconditionally update chunk on revert
- do nothing if same chunk is requested in `vlf-move-to-chunk'
This commit is contained in:
Andrey Kotlarski 2013-08-26 00:39:51 +03:00
parent 9b22b74f21
commit ae2237d7ea

26
vlf.el
View File

@ -196,8 +196,7 @@ with the prefix argument DECREASE it is halved."
(format "%s(%s)[%d/%d](%d)" (format "%s(%s)[%d/%d](%d)"
(file-name-nondirectory buffer-file-name) (file-name-nondirectory buffer-file-name)
(file-size-human-readable vlf-file-size) (file-size-human-readable vlf-file-size)
(/ (+ vlf-start-pos (/ (- vlf-end-pos vlf-start-pos) 2)) (/ vlf-end-pos vlf-batch-size)
vlf-batch-size)
(/ vlf-file-size vlf-batch-size) (/ vlf-file-size vlf-batch-size)
vlf-batch-size)) vlf-batch-size))
@ -242,7 +241,7 @@ Ask for confirmation if NOCONFIRM is nil."
(if (or noconfirm (if (or noconfirm
(yes-or-no-p (format "Revert buffer from file %s? " (yes-or-no-p (format "Revert buffer from file %s? "
buffer-file-name))) buffer-file-name)))
(vlf-move-to-chunk vlf-start-pos vlf-end-pos))) (vlf-move-to-chunk-2 vlf-start-pos vlf-end-pos)))
(defun vlf-jump-to-chunk (n) (defun vlf-jump-to-chunk (n)
"Go to to chunk N." "Go to to chunk N."
@ -300,16 +299,19 @@ When given MINIMAL flag, skip non important operations."
(defun vlf-move-to-chunk (start end &optional minimal) (defun vlf-move-to-chunk (start end &optional minimal)
"Move to chunk determined by START END. "Move to chunk determined by START END.
When given MINIMAL flag, skip non important operations." When given MINIMAL flag, skip non important operations.
(vlf-verify-size) If same as current chunk is requested, do nothing."
(if (buffer-modified-p) (unless (and (= start vlf-start-pos)
(if (vlf-move-to-chunk-1 start end) (= end vlf-end-pos))
(or minimal (vlf-update-buffer-name))) (vlf-verify-size)
(vlf-move-to-chunk-2 start end) (if (buffer-modified-p)
(or minimal (vlf-update-buffer-name)))) (if (vlf-move-to-chunk-1 start end)
(or minimal (vlf-update-buffer-name)))
(vlf-move-to-chunk-2 start end)
(or minimal (vlf-update-buffer-name)))))
(defun vlf-move-to-chunk-1 (start end) (defun vlf-move-to-chunk-1 (start end)
"Move to chunk determined by START END keeping as much edits. "Move to chunk determined by START END keeping as much edits if any.
Return t if move hasn't been canceled." Return t if move hasn't been canceled."
(let ((modified (buffer-modified-p)) (let ((modified (buffer-modified-p))
(start (max 0 start)) (start (max 0 start))
@ -369,7 +371,7 @@ Return t if move hasn't been canceled."
t)))) t))))
(defun vlf-move-to-chunk-2 (start end) (defun vlf-move-to-chunk-2 (start end)
"Move to chunk determined by START END." "Unconditionally move to chunk determined by START END."
(setq vlf-start-pos (max 0 start) (setq vlf-start-pos (max 0 start)
vlf-end-pos (min end vlf-file-size)) vlf-end-pos (min end vlf-file-size))
(let ((inhibit-read-only t) (let ((inhibit-read-only t)