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

Fix file size determination after save and move vlf-with-undo-disabled

macro before vlf-mode declaration.
This commit is contained in:
Andrey Kotlarski 2013-12-12 02:07:25 +02:00
parent ea46386cbc
commit 2e2bca6999

25
vlf.el
View File

@ -100,6 +100,15 @@ Possible values are: nil to never use it;
map)
"Prefixed keymap for `vlf-mode'.")
(defmacro vlf-with-undo-disabled (&rest body)
"Execute BODY with temporarily disabled undo."
`(let ((undo-enabled (not (eq buffer-undo-list t))))
(if undo-enabled
(buffer-disable-undo))
(unwind-protect (progn ,@body)
(if undo-enabled
(buffer-enable-undo)))))
(define-minor-mode vlf-mode
"Mode to browse large files in."
:lighter " VLF"
@ -334,15 +343,6 @@ Ask for confirmation if NOCONFIRM is nil."
(interactive "nGoto to chunk: ")
(vlf-move-to-batch (* (1- n) vlf-batch-size)))
(defmacro vlf-with-undo-disabled (&rest body)
"Execute BODY with temporarily disabled undo."
`(let ((undo-enabled (not (eq buffer-undo-list t))))
(if undo-enabled
(buffer-disable-undo))
(unwind-protect (progn ,@body)
(if undo-enabled
(buffer-enable-undo)))))
(defun vlf-no-modifications ()
"Ensure there are no buffer modifications."
(if (buffer-modified-p)
@ -971,14 +971,13 @@ Save anyway? ")))
(progn
(write-region nil nil buffer-file-name vlf-start-pos t)
(when (zerop vlf-file-size) ;new file
(setq vlf-file-size region-length
vlf-end-pos region-length
vlf-start-pos 1)
(setq vlf-file-size (vlf-get-file-size buffer-file-name)
vlf-end-pos vlf-file-size)
(vlf-update-buffer-name)))
(if (< 0 size-change)
(vlf-file-shift-back size-change)
(vlf-file-shift-forward (- size-change)))
(vlf-verify-size)
(setq vlf-file-size (vlf-get-file-size buffer-file-name))
(vlf-move-to-chunk-2 vlf-start-pos
(if (< (- vlf-end-pos vlf-start-pos)
vlf-batch-size)