[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/vlf fc689d5 071/310: Make coding system conversion on w
From: |
Stefan Monnier |
Subject: |
[elpa] externals/vlf fc689d5 071/310: Make coding system conversion on write more idiomatic. |
Date: |
Sat, 28 Nov 2020 00:32:49 -0500 (EST) |
branch: externals/vlf
commit fc689d5c88de58f46ceaab7789e212be99762c33
Author: Andrey Kotlarski <m00naticus@gmail.com>
Commit: Andrey Kotlarski <m00naticus@gmail.com>
Make coding system conversion on write more idiomatic.
---
vlfi.el | 52 +++++++++++++++++++++-------------------------------
1 file changed, 21 insertions(+), 31 deletions(-)
diff --git a/vlfi.el b/vlfi.el
index aeccb17..d6a8a3f 100644
--- a/vlfi.el
+++ b/vlfi.el
@@ -514,33 +514,25 @@ Save anyway? ")))
(vlfi-mode)
t))
-(defun vlfi-prepare-write-buffer ()
- "Optimize buffer for a lot of insert/erasure."
- (setq delay-mode-hooks t)
- (fundamental-mode)
- (buffer-disable-undo))
-
(defun vlfi-file-shift-back (size-change)
"Shift file contents SIZE-CHANGE bytes back."
- (let ((coding-system buffer-file-coding-system))
- (write-region nil nil buffer-file-name vlfi-start-pos t)
- (setq buffer-file-coding-system nil)
- (vlfi-prepare-write-buffer)
- (let ((read-start-pos vlfi-end-pos)
- (reporter (make-progress-reporter "Adjusting file content"
- vlfi-end-pos
- vlfi-file-size)))
- (while (vlfi-shift-batch read-start-pos (- read-start-pos
- size-change))
- (setq read-start-pos (+ read-start-pos vlfi-batch-size))
- (progress-reporter-update reporter read-start-pos))
- ;; pad end with space
- (erase-buffer)
- (insert-char 32 size-change)
- (write-region nil nil buffer-file-name (- vlfi-file-size
- size-change) t)
- (progress-reporter-done reporter))
- (setq buffer-file-coding-system coding-system)))
+ (write-region nil nil buffer-file-name vlfi-start-pos t)
+ (buffer-disable-undo)
+ (let ((read-start-pos vlfi-end-pos)
+ (coding-system-for-write 'no-conversion)
+ (reporter (make-progress-reporter "Adjusting file content"
+ vlfi-end-pos
+ vlfi-file-size)))
+ (while (vlfi-shift-batch read-start-pos (- read-start-pos
+ size-change))
+ (setq read-start-pos (+ read-start-pos vlfi-batch-size))
+ (progress-reporter-update reporter read-start-pos))
+ ;; pad end with space
+ (erase-buffer)
+ (insert-char 32 size-change)
+ (write-region nil nil buffer-file-name (- vlfi-file-size
+ size-change) t)
+ (progress-reporter-done reporter)))
(defun vlfi-shift-batch (read-pos write-pos)
"Read `vlfi-batch-size' bytes from READ-POS and write them \
@@ -560,13 +552,13 @@ Done by saving content up front and then writing previous
batch."
(let ((vlfi-buffer (current-buffer))
(temp-buffer (generate-new-buffer (concat " "
(buffer-name))))
- (coding-system buffer-file-coding-system))
+ (coding-system-for-write 'no-conversion))
(let ((file buffer-file-name))
(set-buffer temp-buffer)
(setq buffer-file-name file)
- (vlfi-prepare-write-buffer))
+ (buffer-disable-undo))
(set-buffer vlfi-buffer)
- (vlfi-prepare-write-buffer)
+ (buffer-disable-undo)
(let ((read-buffer temp-buffer)
(write-buffer vlfi-buffer)
(size (+ vlfi-batch-size size-change))
@@ -586,8 +578,7 @@ Done by saving content up front and then writing previous
batch."
(progress-reporter-update reporter write-pos))
(progress-reporter-done reporter))
(kill-buffer temp-buffer)
- (set-buffer vlfi-buffer)
- (setq buffer-file-coding-system coding-system)))
+ (set-buffer vlfi-buffer)))
(defun vlfi-shift-batches (size read-buffer read-pos
write-buffer write-pos)
@@ -600,7 +591,6 @@ Return nil if EOF is reached, t otherwise."
;; read
(set-buffer read-buffer)
(erase-buffer)
- (setq buffer-file-coding-system nil)
(insert-file-contents-literally buffer-file-name nil read-pos
(min file-size (+ read-pos
size))))
- [elpa] externals/vlf 152462a 166/310: Fix autoloads in last commit., (continued)
- [elpa] externals/vlf 152462a 166/310: Fix autoloads in last commit., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf e67895a 068/310: Optionally strip superfluous operations when inserting batches., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 6773248 104/310: Optimize a bit goto line., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 4134de0 177/310: Add intelligent recenter chunk around point functionality., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 9b22b74 134/310: Add gitignore., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 2dba838 140/310: In case original VLF buffer has been killed, try to find existing VLF, Stefan Monnier, 2020/11/28
- [elpa] externals/vlf efae918 138/310: Turn vlf into minor mode., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf e36492b 182/310: Optimize chunk jumping for current GNU Emacs releases. Fix moving by, Stefan Monnier, 2020/11/28
- [elpa] externals/vlf f1ade81 069/310: Add go to line command., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 3fb898e 070/310: Add automatic batching when scrolling., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf fc689d5 071/310: Make coding system conversion on write more idiomatic.,
Stefan Monnier <=
- [elpa] externals/vlf 74febeb 072/310: Remove ability to launch VLFI from file end. It's superseded by, Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 4699008 074/310: Make chunk adjusting automatic., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 538a9e6 075/310: Apply chunk decoding adjustment implicitly., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 0dc6d06 190/310: Completely decouple vlf integration from other functionality., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf c533bce 207/310: Add command to set batch size explicitly., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 177c680 147/310: Revert to showing batch size in buffer name instead of the mode-line., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf d6c7223 151/310: Delete obsolete vlfi.el., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 655805c 174/310: Fix vlf-next-batch-from-point behaviour near end of file., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf db1da30 175/310: Use buffer-file-truename for file size determination and remove, Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 429a8ff 196/310: Widen region when measuring encoded content length., Stefan Monnier, 2020/11/28