[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/vlf 5aef3e1 078/310: Update file size changes more lazi
From: |
Stefan Monnier |
Subject: |
[elpa] externals/vlf 5aef3e1 078/310: Update file size changes more lazily. |
Date: |
Sat, 28 Nov 2020 00:32:50 -0500 (EST) |
branch: externals/vlf
commit 5aef3e1c2745f2ebc1d77be2b1688c1df7f2d465
Author: Andrey Kotlarski <m00naticus@gmail.com>
Commit: Andrey Kotlarski <m00naticus@gmail.com>
Update file size changes more lazily.
---
vlfi.el | 44 ++++++++++++++++++++++----------------------
1 file changed, 22 insertions(+), 22 deletions(-)
diff --git a/vlfi.el b/vlfi.el
index 85d3262..964e147 100644
--- a/vlfi.el
+++ b/vlfi.el
@@ -242,14 +242,11 @@ When prefix argument is supplied and positive
When prefix argument is negative
append next APPEND number of batches to the existing buffer."
(interactive "p")
- (let ((end (+ vlfi-end-pos (* vlfi-batch-size
- (abs append)))))
- (when (< vlfi-file-size end) ; re-check file size
- (setq vlfi-file-size (vlfi-get-file-size buffer-file-name))
- (cond ((= vlfi-end-pos vlfi-file-size)
- (error "Already at EOF"))
- ((< vlfi-file-size end)
- (setq end vlfi-file-size))))
+ (or (verify-visited-file-modtime)
+ (setq vlfi-file-size (vlfi-get-file-size buffer-file-name)))
+ (let ((end (min (+ vlfi-end-pos (* vlfi-batch-size
+ (abs append)))
+ vlfi-file-size)))
(let ((inhibit-read-only t)
(do-append (< append 0))
(pos (position-bytes (point))))
@@ -277,6 +274,8 @@ When prefix argument is negative
(interactive "p")
(if (zerop vlfi-start-pos)
(error "Already at BOF"))
+ (or (verify-visited-file-modtime)
+ (setq vlfi-file-size (vlfi-get-file-size buffer-file-name)))
(let ((inhibit-read-only t)
(start (max 0 (- vlfi-start-pos (* vlfi-batch-size
(abs prepend)))))
@@ -285,7 +284,8 @@ When prefix argument is negative
(position-bytes (point)))))
(if do-prepend
(goto-char (point-min))
- (setq vlfi-end-pos (+ start vlfi-batch-size))
+ (setq vlfi-end-pos (min (+ start vlfi-batch-size)
+ vlfi-file-size))
(erase-buffer))
(insert-file-contents buffer-file-name nil start
(if do-prepend
@@ -304,12 +304,13 @@ When prefix argument is negative
"Move to batch determined by START.
Adjust according to file start/end and show `vlfi-batch-size' bytes.
When given MINIMAL flag, skip non important operations."
+ (or (verify-visited-file-modtime)
+ (setq vlfi-file-size (vlfi-get-file-size buffer-file-name)))
(setq vlfi-start-pos (max 0 start)
- vlfi-end-pos (+ vlfi-start-pos vlfi-batch-size))
- (if (< vlfi-file-size vlfi-end-pos) ; re-check file size
- (setq vlfi-file-size (vlfi-get-file-size buffer-file-name)
- vlfi-end-pos (min vlfi-end-pos vlfi-file-size)
- vlfi-start-pos (max 0 (- vlfi-end-pos vlfi-batch-size))))
+ vlfi-end-pos (min (+ vlfi-start-pos vlfi-batch-size)
+ vlfi-file-size))
+ (if (= vlfi-file-size vlfi-end-pos) ; re-check file size
+ (setq vlfi-start-pos (max 0 (- vlfi-end-pos vlfi-batch-size))))
(let ((inhibit-read-only t)
(pos (position-bytes (point))))
(erase-buffer)
@@ -318,14 +319,13 @@ When given MINIMAL flag, skip non important operations."
(goto-char (or (byte-to-position (+ pos (vlfi-adjust-chunk)))
(point-max))))
(set-buffer-modified-p nil)
- (unless minimal
- (set-visited-file-modtime)
- (vlfi-update-buffer-name)))
+ (set-visited-file-modtime)
+ (or minimal(vlfi-update-buffer-name)))
(defun vlfi-move-to-chunk (start end &optional minimal)
"Move to chunk determined by START END.
When given MINIMAL flag, skip non important operations."
- (if (< vlfi-file-size end) ; re-check file size
+ (or (verify-visited-file-modtime)
(setq vlfi-file-size (vlfi-get-file-size buffer-file-name)))
(setq vlfi-start-pos (max 0 start)
vlfi-end-pos (min end vlfi-file-size))
@@ -337,9 +337,8 @@ When given MINIMAL flag, skip non important operations."
(goto-char (or (byte-to-position (+ pos (vlfi-adjust-chunk)))
(point-max))))
(set-buffer-modified-p nil)
- (unless minimal
- (set-visited-file-modtime)
- (vlfi-update-buffer-name)))
+ (set-visited-file-modtime)
+ (or minimal (vlfi-update-buffer-name)))
(defun vlfi-adjust-chunk ()
"Adjust chunk beginning until content can be properly decoded.
@@ -590,7 +589,8 @@ Save anyway? ")))
"Read `vlfi-batch-size' bytes from READ-POS and write them \
back at WRITE-POS. Return nil if EOF is reached, t otherwise."
(erase-buffer)
- (setq vlfi-file-size (vlfi-get-file-size buffer-file-name))
+ (or (verify-visited-file-modtime)
+ (setq vlfi-file-size (vlfi-get-file-size buffer-file-name)))
(let ((read-end (+ read-pos vlfi-batch-size)))
(insert-file-contents-literally buffer-file-name nil
read-pos
- [elpa] externals/vlf 473536e 073/310: Add adjust command for cases where chunk starts with part of multibyte symbol., (continued)
- [elpa] externals/vlf 473536e 073/310: Add adjust command for cases where chunk starts with part of multibyte symbol., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 2564c9a 006/310: Plug option for vlf when opening files on package load., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf c0d143b 011/310: Rename vlf to vlfi and update README., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 36411c3 022/310: Enhance search to cover in between chunk boundaries., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 88cf03c 030/310: Interactive change of batch size immediately updates content., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 995a7a0 042/310: Change some VLFI key-bindings not to override special-mode ones., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 0610822 046/310: Make saving with change of size correct., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf b52ca6c 063/310: Don't change encoding for edited chunk, leave it to the user in case, Stefan Monnier, 2020/11/28
- [elpa] externals/vlf a31be70 076/310: Update README and bump version., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf ca8ba42 077/310: Fix position handling to correctly deal with multibyte characters., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 5aef3e1 078/310: Update file size changes more lazily.,
Stefan Monnier <=
- [elpa] externals/vlf ba439de 083/310: Initial generation of vlfi-occur results., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 83eb8a5 080/310: Fixes for GNU Emacs 23., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 70719b0 089/310: Add vlfi-occur-show command for showing match but still staying in, Stefan Monnier, 2020/11/28
- [elpa] externals/vlf a5fec57 090/310: Mostly documentation and commentary added., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf fbc3a37 094/310: Add tip for ability to change major mode and more section hierarchy., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf fd9c258 096/310: Use permanent buffer local write hook and update README., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf fbe0814 097/310: Fix occur indexing not to skip last chunk., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 28255a2 098/310: Correctly print MB (for older emacsen)., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf ca13bea 101/310: Try utf-8 and if not successful, auto detect when adjusting chunk for, Stefan Monnier, 2020/11/28
- [elpa] externals/vlf ae775f8 107/310: Extend vlfi-goto-line to count lines from the end with negative, Stefan Monnier, 2020/11/28