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

Keep stable cursor position when moving through chunks.

This commit is contained in:
Andrey Kotlarski 2013-03-30 02:45:51 +02:00
parent fb9aa670cc
commit 9e27aeb057

10
vlfi.el
View File

@ -121,7 +121,8 @@ When prefix argument is negative
((< vlfi-file-size end) ((< vlfi-file-size end)
(setq end vlfi-file-size)))) (setq end vlfi-file-size))))
(let ((inhibit-read-only t) (let ((inhibit-read-only t)
(do-append (< append 0))) (do-append (< append 0))
(pos (point)))
(if do-append (if do-append
(goto-char (point-max)) (goto-char (point-max))
(setq vlfi-start-pos (- end vlfi-batch-size)) (setq vlfi-start-pos (- end vlfi-batch-size))
@ -130,7 +131,8 @@ When prefix argument is negative
(if do-append (if do-append
vlfi-end-pos vlfi-end-pos
vlfi-start-pos) vlfi-start-pos)
end)) end)
(goto-char pos))
(setq vlfi-end-pos end)) (setq vlfi-end-pos end))
(set-buffer-modified-p nil) (set-buffer-modified-p nil)
(vlfi-update-buffer-name)) (vlfi-update-buffer-name))
@ -147,7 +149,8 @@ When prefix argument is negative
(let ((inhibit-read-only t) (let ((inhibit-read-only t)
(start (max 0 (- vlfi-start-pos (* vlfi-batch-size (start (max 0 (- vlfi-start-pos (* vlfi-batch-size
(abs prepend))))) (abs prepend)))))
(do-prepend (< prepend 0))) (do-prepend (< prepend 0))
(pos (- (point-max) (point))))
(if do-prepend (if do-prepend
(goto-char (point-min)) (goto-char (point-min))
(setq vlfi-end-pos (+ start vlfi-batch-size)) (setq vlfi-end-pos (+ start vlfi-batch-size))
@ -156,6 +159,7 @@ When prefix argument is negative
(if do-prepend (if do-prepend
vlfi-start-pos vlfi-start-pos
vlfi-end-pos)) vlfi-end-pos))
(goto-char (- (point-max) pos))
(setq vlfi-start-pos start)) (setq vlfi-start-pos start))
(set-buffer-modified-p nil) (set-buffer-modified-p nil)
(vlfi-update-buffer-name)) (vlfi-update-buffer-name))