[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/vlf f4ee23c 156/310: Fix chunk end adjustment and save
From: |
Stefan Monnier |
Subject: |
[elpa] externals/vlf f4ee23c 156/310: Fix chunk end adjustment and save for current and older Emacsen. |
Date: |
Sat, 28 Nov 2020 00:33:06 -0500 (EST) |
branch: externals/vlf
commit f4ee23c07f5af1a242c5832446723564d8956766
Author: Andrey Kotlarski <m00naticus@gmail.com>
Commit: Andrey Kotlarski <m00naticus@gmail.com>
Fix chunk end adjustment and save for current and older Emacsen.
---
vlf.el | 78 +++++++++++++++++++++++++++++++++++++++---------------------------
1 file changed, 46 insertions(+), 32 deletions(-)
diff --git a/vlf.el b/vlf.el
index 0d38428..e9f559c 100644
--- a/vlf.el
+++ b/vlf.el
@@ -373,9 +373,8 @@ Return t if move hasn't been canceled."
(inhibit-read-only t))
(cond ((< end edit-end)
(vlf-with-undo-disabled
- (delete-region (byte-to-position (1+
- (- end
- vlf-start-pos)))
+ (delete-region (byte-to-position
+ (1+ (- end vlf-start-pos)))
(point-max))))
((< edit-end end)
(let ((edit-end-pos (point-max)))
@@ -432,43 +431,58 @@ Return t if move hasn't been canceled."
(defun vlf-adjust-chunk (start end &optional adjust-start adjust-end
position)
- "Adjust chunk at absolute START to END till content can be \
+ "Adjust chunk at absolute START to END till content can be\
properly decoded. ADJUST-START determines if trying to prepend bytes\
to the beginning, ADJUST-END - append to the end.
Use buffer POSITION as start if given.
Return number of bytes moved back for proper decoding and number of
bytes added to the end."
- (let ((position (or position (point-min)))
- (shift-start 0)
- (shift-end 0)
- (chunk-size (- end start)))
- ;; adjust beginning
+ (let ((shift-start 0)
+ (shift-end 0))
(if adjust-start
- (while (and (not (zerop start))
- (< shift-start 4)
- (< 4 (abs (- chunk-size
- (length (encode-coding-region
- position (point-max)
- buffer-file-coding-system
- t))))))
- (setq shift-start (1+ shift-start)
- start (1- start)
- chunk-size (1+ chunk-size))
- (delete-region position (point-max))
- (goto-char position)
- (insert-file-contents buffer-file-name nil start end)))
- ;; adjust end
- (when (and adjust-end (< end vlf-file-size))
- (let ((expected-size (buffer-size))) ; in case partial symbol is not
displayed
- (while (and (= expected-size (buffer-size))
- (< end vlf-file-size))
- (setq shift-end (1+ shift-end)
- end (1+ end))
- (delete-region position (point-max))
- (goto-char position)
- (insert-file-contents buffer-file-name nil start end))))
+ (let ((position (or position (point-min)))
+ (chunk-size (- end start)))
+ (while (and (not (zerop start))
+ (< shift-start 4)
+ (< 4 (abs (- chunk-size
+ (length (encode-coding-region
+ position (point-max)
+ buffer-file-coding-system
+ t))))))
+ (setq shift-start (1+ shift-start)
+ start (1- start)
+ chunk-size (1+ chunk-size))
+ (delete-region position (point-max))
+ (goto-char position)
+ (insert-file-contents buffer-file-name nil start end))))
+ (if adjust-end
+ (cond ((vlf-partial-decode-shown-p) ;remove raw bytes from end
+ (goto-char (point-max))
+ (while (eq (char-charset (preceding-char)) 'eight-bit)
+ (setq shift-end (1- shift-end))
+ (delete-char -1)))
+ ((< end vlf-file-size) ;add bytes until new character is
displayed
+ (let ((position (or position (point-min)))
+ (expected-size (buffer-size)))
+ (while (and (progn
+ (setq shift-end (1+ shift-end)
+ end (1+ end))
+ (delete-region position (point-max))
+ (goto-char position)
+ (insert-file-contents buffer-file-name
+ nil start end)
+ (< end vlf-file-size))
+ (= expected-size (buffer-size))))))))
(cons shift-start shift-end)))
+(defun vlf-partial-decode-shown-p ()
+ "Determine if partial decode codes are displayed.
+This seems to be the case with GNU/Emacs before 24.4."
+ (cond ((< emacs-major-version 24) t)
+ ((< 24 emacs-major-version) nil)
+ (t ;; TODO: use (< emacs-minor-version 4) after 24.4 release
+ (string-lessp emacs-version "24.3.5"))))
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; search
- [elpa] externals/vlf b14c912 290/310: Copy around buffer specific profile vectors when forking new buffers., (continued)
- [elpa] externals/vlf b14c912 290/310: Copy around buffer specific profile vectors when forking new buffers., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf b300137 292/310: Encode smaller region to detect cut point overall offset in vlf-occur, Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 86be483 293/310: Improve search precision., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf a8ba836 298/310: Fix issue where tramp-verbose is bound to nil., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 25e16ef 303/310: Fix broken link in README, Stefan Monnier, 2020/11/28
- [elpa] externals/vlf b62bc04 301/310: Issue 31 Make vlf-batch-size configurable in the remote case, Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 55e0c40 300/310: Explicitly set coding-system-for-read to the current coding when not, Stefan Monnier, 2020/11/28
- [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 <=
- [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, 2020/11/28
- [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