mirror of
https://github.com/m00natic/vlfi.git
synced 2025-01-18 20:10:47 +00:00
Be more precise on restoring hexl-mode after chunk update has been
canceled.
This commit is contained in:
parent
694d1de495
commit
557d751f78
34
vlf-base.el
34
vlf-base.el
@ -136,21 +136,18 @@ bytes added to the end."
|
||||
(length (encode-coding-region
|
||||
(point-min) (point-max)
|
||||
buffer-file-coding-system t))))
|
||||
vlf-end-pos)))
|
||||
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)
|
||||
(let ((shifts (vlf-move-to-chunk-2 start end)))
|
||||
(if restore-hexl (hexl-mode))
|
||||
shifts)))
|
||||
(vlf-move-to-chunk-2 start end)))
|
||||
((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 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? "))
|
||||
@ -170,8 +167,9 @@ bytes added to the end."
|
||||
(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
|
||||
(point-min) vlf-start-pos
|
||||
edit-end end
|
||||
(min (or (byte-to-position
|
||||
(- end vlf-start-pos))
|
||||
(point-min))
|
||||
(point-max))
|
||||
@ -192,7 +190,8 @@ bytes added to the end."
|
||||
(let ((del-info (vlf-delete-region
|
||||
(point-min) vlf-start-pos
|
||||
vlf-end-pos start
|
||||
(min (or (byte-to-position
|
||||
(min (or
|
||||
(byte-to-position
|
||||
(- start vlf-start-pos))
|
||||
(point))
|
||||
(point-max)) t)))
|
||||
@ -202,7 +201,8 @@ bytes added to the end."
|
||||
((< start vlf-start-pos)
|
||||
(let ((edit-end-pos (point-max)))
|
||||
(vlf-with-undo-disabled
|
||||
(setq shift-start (car (vlf-insert-file-contents
|
||||
(setq shift-start (car
|
||||
(vlf-insert-file-contents
|
||||
start vlf-start-pos t nil
|
||||
edit-end-pos)))
|
||||
(goto-char (point-min))
|
||||
@ -217,11 +217,13 @@ bytes added to the end."
|
||||
(setq vlf-start-pos start))
|
||||
(set-buffer-modified-p modified)
|
||||
(set-visited-file-modtime)
|
||||
(if hexl (hexl-mode))
|
||||
(when hexl
|
||||
(hexl-mode)
|
||||
(setq restore-hexl nil))
|
||||
(run-hooks 'vlf-after-chunk-update)
|
||||
(cons shift-start shift-end)))
|
||||
(restore-hexl (hexl-mode)
|
||||
nil))))
|
||||
(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.
|
||||
|
Loading…
x
Reference in New Issue
Block a user