[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/vlf 28646fb 148/310: Reduce scope of vlf-with-undo-disa
From: |
Stefan Monnier |
Subject: |
[elpa] externals/vlf 28646fb 148/310: Reduce scope of vlf-with-undo-disabled usages. |
Date: |
Sat, 28 Nov 2020 00:33:04 -0500 (EST) |
branch: externals/vlf
commit 28646fbfeeb4c5c4f17413bc2d5ef4f5a00bb800
Author: Andrey Kotlarski <m00naticus@gmail.com>
Commit: Andrey Kotlarski <m00naticus@gmail.com>
Reduce scope of vlf-with-undo-disabled usages.
---
vlf.el | 76 ++++++++++++++++++++++++++++++++++--------------------------------
1 file changed, 39 insertions(+), 37 deletions(-)
diff --git a/vlf.el b/vlf.el
index ce0855b..f6cf4ed 100644
--- a/vlf.el
+++ b/vlf.el
@@ -109,8 +109,10 @@
vlf-file-size))))
(remove-hook 'write-file-functions 'vlf-write t)
(let ((pos (+ vlf-start-pos (position-bytes (point)))))
- (erase-buffer)
- (insert-file-contents buffer-file-name)
+ (vlf-with-undo-disabled
+ (erase-buffer)
+ (insert-file-contents buffer-file-name))
+ (set-visited-file-modtime)
(set-buffer-modified-p nil)
(goto-char (byte-to-position pos)))
(rename-buffer (file-name-nondirectory buffer-file-name) t))))
@@ -401,22 +403,22 @@ Return t if move hasn't been canceled."
(defun vlf-move-to-chunk-2 (start end)
"Unconditionally move to chunk determined by START END."
- (vlf-with-undo-disabled
- (setq vlf-start-pos (max 0 start)
- vlf-end-pos (min end vlf-file-size))
- (let ((inhibit-read-only t)
- (pos (position-bytes (point))))
- (erase-buffer)
- (insert-file-contents buffer-file-name nil
- vlf-start-pos vlf-end-pos)
- (let ((shifts (vlf-adjust-chunk vlf-start-pos vlf-end-pos t
- t)))
- (setq vlf-start-pos (- vlf-start-pos (car shifts))
- vlf-end-pos (+ vlf-end-pos (cdr shifts)))
- (goto-char (or (byte-to-position (+ pos (car shifts)))
- (point-max)))))
- (set-buffer-modified-p nil)
- (set-visited-file-modtime)))
+ (setq vlf-start-pos (max 0 start)
+ vlf-end-pos (min end vlf-file-size))
+ (let ((inhibit-read-only t)
+ (pos (position-bytes (point))))
+ (vlf-with-undo-disabled
+ (erase-buffer)
+ (insert-file-contents buffer-file-name nil
+ vlf-start-pos vlf-end-pos)
+ (let ((shifts (vlf-adjust-chunk vlf-start-pos vlf-end-pos t
+ t)))
+ (setq vlf-start-pos (- vlf-start-pos (car shifts))
+ vlf-end-pos (+ vlf-end-pos (cdr shifts)))
+ (goto-char (or (byte-to-position (+ pos (car shifts)))
+ (point-max))))))
+ (set-buffer-modified-p nil)
+ (set-visited-file-modtime))
(defun vlf-adjust-chunk (start end &optional adjust-start adjust-end
position)
@@ -886,12 +888,12 @@ Save anyway? ")))
(defun vlf-file-shift-back (size-change)
"Shift file contents SIZE-CHANGE bytes back."
(write-region nil nil buffer-file-name vlf-start-pos t)
- (vlf-with-undo-disabled
- (let ((read-start-pos vlf-end-pos)
- (coding-system-for-write 'no-conversion)
- (reporter (make-progress-reporter "Adjusting file content..."
- vlf-end-pos
- vlf-file-size)))
+ (let ((read-start-pos vlf-end-pos)
+ (coding-system-for-write 'no-conversion)
+ (reporter (make-progress-reporter "Adjusting file content..."
+ vlf-end-pos
+ vlf-file-size)))
+ (vlf-with-undo-disabled
(while (vlf-shift-batch read-start-pos (- read-start-pos
size-change))
(setq read-start-pos (+ read-start-pos vlf-batch-size))
@@ -899,10 +901,10 @@ Save anyway? ")))
;; pad end with space
(erase-buffer)
(vlf-verify-size)
- (insert-char 32 size-change)
- (write-region nil nil buffer-file-name (- vlf-file-size
- size-change) t)
- (progress-reporter-done reporter))))
+ (insert-char 32 size-change))
+ (write-region nil nil buffer-file-name (- vlf-file-size
+ size-change) t)
+ (progress-reporter-done reporter)))
(defun vlf-shift-batch (read-pos write-pos)
"Read `vlf-batch-size' bytes from READ-POS and write them \
@@ -919,13 +921,13 @@ back at WRITE-POS. Return nil if EOF is reached, t
otherwise."
(defun vlf-file-shift-forward (size-change)
"Shift file contents SIZE-CHANGE bytes forward.
Done by saving content up front and then writing previous batch."
- (vlf-with-undo-disabled
- (let ((read-size (max (/ vlf-batch-size 2) size-change))
- (read-pos vlf-end-pos)
- (write-pos vlf-start-pos)
- (reporter (make-progress-reporter "Adjusting file content..."
- vlf-start-pos
- vlf-file-size)))
+ (let ((read-size (max (/ vlf-batch-size 2) size-change))
+ (read-pos vlf-end-pos)
+ (write-pos vlf-start-pos)
+ (reporter (make-progress-reporter "Adjusting file content..."
+ vlf-start-pos
+ vlf-file-size)))
+ (vlf-with-undo-disabled
(when (vlf-shift-batches read-size read-pos write-pos t)
(setq write-pos (+ read-pos size-change)
read-pos (+ read-pos read-size))
@@ -934,8 +936,8 @@ Done by saving content up front and then writing previous
batch."
(while (vlf-shift-batches read-size read-pos write-pos nil)
(setq write-pos (+ read-pos size-change)
read-pos (+ read-pos read-size))
- (progress-reporter-update reporter write-pos))))
- (progress-reporter-done reporter))))
+ (progress-reporter-update reporter write-pos)))))
+ (progress-reporter-done reporter)))
(defun vlf-shift-batches (read-size read-pos write-pos hide-read)
"Append READ-SIZE bytes of file starting at READ-POS.
- [elpa] externals/vlf 4eaf763 297/310: Rename vlf-integrate.el to vlf-setup.el, (continued)
- [elpa] externals/vlf 4eaf763 297/310: Rename vlf-integrate.el to vlf-setup.el, Stefan Monnier, 2020/11/28
- [elpa] externals/vlf efffeb5 310/310: Bump vlf version after previous fix, Stefan Monnier, 2020/11/28
- [elpa] externals/vlf f4aa108 308/310: * vlf.el: Use GPL version 3, Stefan Monnier, 2020/11/28
- [elpa] externals/vlf f4ee23c 156/310: Fix chunk end adjustment and save for current and older Emacsen., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 2e2bca6 169/310: Fix file size determination after save and move vlf-with-undo-disabled, Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 290c4ac 176/310: Fix save with adjustment., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf d88080f 178/310: Don't apply VLF over ebrowse and TAGS databases., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 4d82c78 197/310: - don't nullify default buffer coding system, Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 117935d 200/310: Add progress reporter when searching for difference., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf bfcbfd3 132/310: Make error message more descriptive., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 28646fb 148/310: Reduce scope of vlf-with-undo-disabled usages.,
Stefan Monnier <=
- [elpa] externals/vlf 72fec35 162/310: Update README and bump version., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 65b4d74 170/310: Refactor vlf-write., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 099adab 171/310: Fix abort-if-file-too-large advice not to activate VLF in case of empty, Stefan Monnier, 2020/11/28
- [elpa] externals/vlf c58d0d8 180/310: Shift buffer-undo-list elements when chunk beginning moves., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 4f99eaa 183/310: Fixes to tiny chunk moves., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 7794b2c 185/310: Merge branch 'shift-undo' into chunk-move, Stefan Monnier, 2020/11/28
- [elpa] externals/vlf d7766f2 209/310: Update documentation and mark autoloaded functions as interactive., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 5d30eb4 206/310: Use single ediff pass to adjust borders. Protect against user, Stefan Monnier, 2020/11/28
- [elpa] externals/vlf ffac697 217/310: Keep undo list after occur or unsuccessful line search., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf b05255b 220/310: Add hooks to run around chunk moves and batch operations. Don't err, Stefan Monnier, 2020/11/28