[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/vlf 6ea7a2a 065/310: Add macro for file size determinat
From: |
Stefan Monnier |
Subject: |
[elpa] externals/vlf 6ea7a2a 065/310: Add macro for file size determination. |
Date: |
Sat, 28 Nov 2020 00:32:48 -0500 (EST) |
branch: externals/vlf
commit 6ea7a2aa1e994b60fa7954df85810e5cf1ba3e87
Author: Andrey Kotlarski <m00naticus@gmail.com>
Commit: Andrey Kotlarski <m00naticus@gmail.com>
Add macro for file size determination.
---
vlfi.el | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/vlfi.el b/vlfi.el
index 41a72cb..52d4af2 100644
--- a/vlfi.el
+++ b/vlfi.el
@@ -94,7 +94,7 @@ buffer. You can customize number of bytes displayed by
customizing
(interactive "fFile to open: \nP")
(with-current-buffer (generate-new-buffer "*vlfi*")
(setq buffer-file-name file
- vlfi-file-size (nth 7 (file-attributes file)))
+ vlfi-file-size (vlfi-get-file-size file))
(vlfi-insert-file from-end)
(vlfi-mode)
(switch-to-buffer (current-buffer))))
@@ -179,6 +179,10 @@ with the prefix argument DECREASE it is halved."
"Update the current buffer name."
(rename-buffer (vlfi-format-buffer-name) t))
+(defmacro vlfi-get-file-size (file)
+ "Get size in bytes of FILE."
+ `(nth 7 (file-attributes ,file)))
+
(defun vlfi-insert-file (&optional from-end)
"Insert first chunk of current file contents in current buffer.
With FROM-END prefix, start from the back."
@@ -222,7 +226,7 @@ When prefix argument is negative
(let ((end (+ vlfi-end-pos (* vlfi-batch-size
(abs append)))))
(when (< vlfi-file-size end) ; re-check file size
- (setq vlfi-file-size (nth 7 (file-attributes buffer-file-name)))
+ (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)
@@ -278,8 +282,7 @@ Adjust according to file start/end and show
`vlfi-batch-size' bytes."
(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
- (nth 7 (file-attributes buffer-file-name))
+ (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))))
(let ((inhibit-read-only t)
@@ -295,8 +298,7 @@ Adjust according to file start/end and show
`vlfi-batch-size' bytes."
(defun vlfi-move-to-chunk (start end)
"Move to chunk determined by START END."
(if (< vlfi-file-size end) ; re-check file size
- (setq vlfi-file-size (nth 7
- (file-attributes buffer-file-name))))
+ (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))
(let ((inhibit-read-only t)
@@ -497,7 +499,7 @@ 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 (nth 7 (file-attributes buffer-file-name)))
+ (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
@@ -543,7 +545,7 @@ Done by saving content up front and then writing previous
batch."
"Read SIZE bytes in READ-BUFFER starting from READ-POS.
Then write contents of WRITE-BUFFER to buffer file at WRITE-POS.
Return nil if EOF is reached, t otherwise."
- (let* ((file-size (nth 7 (file-attributes buffer-file-name)))
+ (let* ((file-size (vlfi-get-file-size buffer-file-name))
(read-more (< read-pos file-size)))
(when read-more
;; read
- [elpa] externals/vlf 56134a8 050/310: Make vlfi usable under GNU Emacs 23., (continued)
- [elpa] externals/vlf 56134a8 050/310: Make vlfi usable under GNU Emacs 23., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 24675d8 054/310: Manage modification times when attempting to save., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf c4f87f9 048/310: Move save interception to vlfi-mode., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf c14c7f0 058/310: Add shift forward of file contents when edited chunk grows in size., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf e115e7e 053/310: Add custom revert function., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 2edbb6b 004/310: Add vlf as an option when opening large files., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 80ca6b6 037/310: Fix vlfi invocation when prompted for large files., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 03f3233 039/310: Don't reinsert content and move on successful search., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 2525ebf 049/310: Improvements to file saving., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf cedd0b4 059/310: Fix spaces and indent., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 6ea7a2a 065/310: Add macro for file size determination.,
Stefan Monnier <=
- [elpa] externals/vlf 91fecb7 023/310: Simplify key-bindings., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 8e65e13 029/310: Refactor and simplify search procedures. Always use batch sized, Stefan Monnier, 2020/11/28
- [elpa] externals/vlf db3d2af 043/310: Update version, README and commentary section., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 467154a 047/310: Add documentation., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf a3c405f 051/310: Make detection of buffer size change on save more correct when dealing, Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 7985f0f 052/310: Fix `vlfi-if-file-too-large' to be more tolerable on GNU Emacs 23., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 8637ce5 062/310: Update README and version., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 4cbefde 067/310: Optimize chunk save buffers for multiple insert/erase operations., Stefan Monnier, 2020/11/28
- [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