[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/vlf 557d751 236/310: Be more precise on restoring hexl-
From: |
Stefan Monnier |
Subject: |
[elpa] externals/vlf 557d751 236/310: Be more precise on restoring hexl-mode after chunk update has been |
Date: |
Sat, 28 Nov 2020 00:33:23 -0500 (EST) |
branch: externals/vlf
commit 557d751f78c080a139b17bdef6d96b5388b218b9
Author: Andrey Kotlarski <m00naticus@gmail.com>
Commit: Andrey Kotlarski <m00naticus@gmail.com>
Be more precise on restoring hexl-mode after chunk update has been
canceled.
---
vlf-base.el | 174 ++++++++++++++++++++++++++++++------------------------------
1 file changed, 88 insertions(+), 86 deletions(-)
diff --git a/vlf-base.el b/vlf-base.el
index 1e9a1a0..7c94ce5 100644
--- a/vlf-base.el
+++ b/vlf-base.el
@@ -136,92 +136,94 @@ bytes added to the end."
(length (encode-coding-region
(point-min) (point-max)
buffer-file-coding-system t))))
- vlf-end-pos)))
- (cond
- ((or (< edit-end start) (< end vlf-start-pos)
- (not (verify-visited-file-modtime (current-buffer))))
- (when (or (not modified)
- (y-or-n-p "Chunk modified, are you sure? ")) ;full chunk
renewal
- (set-buffer-modified-p nil)
- (let ((shifts (vlf-move-to-chunk-2 start end)))
- (if restore-hexl (hexl-mode))
- shifts)))
- ((and (= start vlf-start-pos) (= end edit-end))
- (unless modified
- (let ((shifts (vlf-move-to-chunk-2 start end)))
- (if restore-hexl (hexl-mode))
- shifts)))
- ((or (and (<= start vlf-start-pos) (<= edit-end end))
- (not modified)
- (y-or-n-p "Chunk modified, are you sure? "))
- (run-hooks 'vlf-before-chunk-update)
- (when (and hexl (not restore-hexl))
- (if (consp buffer-undo-list)
- (setq buffer-undo-list nil))
- (hexl-mode-exit))
- (let ((shift-start 0)
- (shift-end 0))
- (let ((pos (+ (position-bytes (point)) vlf-start-pos))
- (inhibit-read-only t))
- (cond ((= end vlf-start-pos)
- (or (eq buffer-undo-list t)
- (setq buffer-undo-list nil))
- (vlf-with-undo-disabled (erase-buffer))
- (setq modified nil))
- ((< end edit-end)
- (setq end (car (vlf-delete-region
- (point-min) vlf-start-pos edit-end
- end (min (or (byte-to-position
- (- end vlf-start-pos))
- (point-min))
- (point-max))
- nil))))
- ((< edit-end end)
- (vlf-with-undo-disabled
- (setq shift-end (cdr (vlf-insert-file-contents
- vlf-end-pos end nil t
- (point-max)))))))
- (setq vlf-end-pos (+ end shift-end))
- (cond ((= start edit-end)
- (or (eq buffer-undo-list t)
- (setq buffer-undo-list nil))
- (vlf-with-undo-disabled
- (delete-region (point-min) (point)))
- (setq modified nil))
- ((< vlf-start-pos start)
- (let ((del-info (vlf-delete-region
- (point-min) vlf-start-pos
- vlf-end-pos start
- (min (or (byte-to-position
- (- start vlf-start-pos))
- (point))
- (point-max)) t)))
- (setq start (car del-info))
- (vlf-shift-undo-list (- (point-min)
- (cdr del-info)))))
- ((< start vlf-start-pos)
- (let ((edit-end-pos (point-max)))
- (vlf-with-undo-disabled
- (setq shift-start (car (vlf-insert-file-contents
- start vlf-start-pos t nil
- edit-end-pos)))
- (goto-char (point-min))
- (insert (delete-and-extract-region
- edit-end-pos (point-max))))
- (vlf-shift-undo-list (- (point-max)
- edit-end-pos)))))
- (setq start (- start shift-start))
- (goto-char (or (byte-to-position (- pos start))
- (byte-to-position (- pos vlf-start-pos))
- (point-max)))
- (setq vlf-start-pos start))
- (set-buffer-modified-p modified)
- (set-visited-file-modtime)
- (if hexl (hexl-mode))
- (run-hooks 'vlf-after-chunk-update)
- (cons shift-start shift-end)))
- (restore-hexl (hexl-mode)
- nil))))
+ vlf-end-pos))
+ (shifts
+ (cond
+ ((or (< edit-end start) (< end vlf-start-pos)
+ (not (verify-visited-file-modtime (current-buffer))))
+ (when (or (not modified)
+ (y-or-n-p "Chunk modified, are you sure? ")) ;full chunk
renewal
+ (set-buffer-modified-p nil)
+ (vlf-move-to-chunk-2 start end)))
+ ((and (= start vlf-start-pos) (= end edit-end))
+ (or modified
+ (vlf-move-to-chunk-2 start end)))
+ ((or (and (<= start vlf-start-pos) (<= edit-end end))
+ (not modified)
+ (y-or-n-p "Chunk modified, are you sure? "))
+ (run-hooks 'vlf-before-chunk-update)
+ (when (and hexl (not restore-hexl))
+ (if (consp buffer-undo-list)
+ (setq buffer-undo-list nil))
+ (hexl-mode-exit))
+ (let ((shift-start 0)
+ (shift-end 0))
+ (let ((pos (+ (position-bytes (point)) vlf-start-pos))
+ (inhibit-read-only t))
+ (cond ((= end vlf-start-pos)
+ (or (eq buffer-undo-list t)
+ (setq buffer-undo-list nil))
+ (vlf-with-undo-disabled (erase-buffer))
+ (setq modified nil))
+ ((< end edit-end)
+ (setq end (car (vlf-delete-region
+ (point-min) vlf-start-pos
+ edit-end end
+ (min (or (byte-to-position
+ (- end vlf-start-pos))
+ (point-min))
+ (point-max))
+ nil))))
+ ((< edit-end end)
+ (vlf-with-undo-disabled
+ (setq shift-end (cdr (vlf-insert-file-contents
+ vlf-end-pos end nil t
+ (point-max)))))))
+ (setq vlf-end-pos (+ end shift-end))
+ (cond ((= start edit-end)
+ (or (eq buffer-undo-list t)
+ (setq buffer-undo-list nil))
+ (vlf-with-undo-disabled
+ (delete-region (point-min) (point)))
+ (setq modified nil))
+ ((< vlf-start-pos start)
+ (let ((del-info (vlf-delete-region
+ (point-min) vlf-start-pos
+ vlf-end-pos start
+ (min (or
+ (byte-to-position
+ (- start vlf-start-pos))
+ (point))
+ (point-max)) t)))
+ (setq start (car del-info))
+ (vlf-shift-undo-list (- (point-min)
+ (cdr del-info)))))
+ ((< start vlf-start-pos)
+ (let ((edit-end-pos (point-max)))
+ (vlf-with-undo-disabled
+ (setq shift-start (car
+ (vlf-insert-file-contents
+ start vlf-start-pos t nil
+ edit-end-pos)))
+ (goto-char (point-min))
+ (insert (delete-and-extract-region
+ edit-end-pos (point-max))))
+ (vlf-shift-undo-list (- (point-max)
+ edit-end-pos)))))
+ (setq start (- start shift-start))
+ (goto-char (or (byte-to-position (- pos start))
+ (byte-to-position (- pos vlf-start-pos))
+ (point-max)))
+ (setq vlf-start-pos start))
+ (set-buffer-modified-p modified)
+ (set-visited-file-modtime)
+ (when hexl
+ (hexl-mode)
+ (setq restore-hexl nil))
+ (run-hooks 'vlf-after-chunk-update)
+ (cons shift-start shift-end))))))
+ (if restore-hexl (hexl-mode))
+ shifts))
(defun vlf-move-to-chunk-2 (start end)
"Unconditionally move to chunk enclosed by START END bytes.
- [elpa] externals/vlf 72fec35 162/310: Update README and bump version., (continued)
- [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
- [elpa] externals/vlf 557d751 236/310: Be more precise on restoring hexl-mode after chunk update has been,
Stefan Monnier <=
- [elpa] externals/vlf ece554a 231/310: Wording., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 069b2f5 240/310: Replace operations with respective vlf-tune wrappers., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf fb05030 241/310: Add basic tune strategies., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf e18a05b 247/310: Add linear search for tuning and prefer smaller batches., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 48a014f 250/310: Fix write measuring and endless loop in nearby approximation., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf ee7409b 254/310: Tune batch size in more cases., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 5651ee3 252/310: Rename vlf-tune-optimal to vlf-tune-batch., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 06b4f85 262/310: Respect disabled tune settings and move custom options., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 199209f 263/310: Fix vlf-tune-optimal-load with no optional arguments supplied., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 023ee70 267/310: Declare hexl functions to please byte compiler., Stefan Monnier, 2020/11/28