mirror of
https://github.com/m00natic/vlfi.git
synced 2025-01-31 10:10:48 +00:00
Fixes for GNU Emacs 23.
This commit is contained in:
parent
e3be8d5d98
commit
83eb8a586b
35
vlfi.el
35
vlfi.el
@ -242,7 +242,7 @@ When prefix argument is supplied and positive
|
|||||||
When prefix argument is negative
|
When prefix argument is negative
|
||||||
append next APPEND number of batches to the existing buffer."
|
append next APPEND number of batches to the existing buffer."
|
||||||
(interactive "p")
|
(interactive "p")
|
||||||
(or (verify-visited-file-modtime)
|
(or (verify-visited-file-modtime (current-buffer))
|
||||||
(setq vlfi-file-size (vlfi-get-file-size buffer-file-name)))
|
(setq vlfi-file-size (vlfi-get-file-size buffer-file-name)))
|
||||||
(let ((end (min (+ vlfi-end-pos (* vlfi-batch-size
|
(let ((end (min (+ vlfi-end-pos (* vlfi-batch-size
|
||||||
(abs append)))
|
(abs append)))
|
||||||
@ -274,7 +274,7 @@ When prefix argument is negative
|
|||||||
(interactive "p")
|
(interactive "p")
|
||||||
(if (zerop vlfi-start-pos)
|
(if (zerop vlfi-start-pos)
|
||||||
(error "Already at BOF"))
|
(error "Already at BOF"))
|
||||||
(or (verify-visited-file-modtime)
|
(or (verify-visited-file-modtime (current-buffer))
|
||||||
(setq vlfi-file-size (vlfi-get-file-size buffer-file-name)))
|
(setq vlfi-file-size (vlfi-get-file-size buffer-file-name)))
|
||||||
(let ((inhibit-read-only t)
|
(let ((inhibit-read-only t)
|
||||||
(start (max 0 (- vlfi-start-pos (* vlfi-batch-size
|
(start (max 0 (- vlfi-start-pos (* vlfi-batch-size
|
||||||
@ -304,7 +304,7 @@ When prefix argument is negative
|
|||||||
"Move to batch determined by START.
|
"Move to batch determined by START.
|
||||||
Adjust according to file start/end and show `vlfi-batch-size' bytes.
|
Adjust according to file start/end and show `vlfi-batch-size' bytes.
|
||||||
When given MINIMAL flag, skip non important operations."
|
When given MINIMAL flag, skip non important operations."
|
||||||
(or (verify-visited-file-modtime)
|
(or (verify-visited-file-modtime (current-buffer))
|
||||||
(setq vlfi-file-size (vlfi-get-file-size buffer-file-name)))
|
(setq vlfi-file-size (vlfi-get-file-size buffer-file-name)))
|
||||||
(setq vlfi-start-pos (max 0 start)
|
(setq vlfi-start-pos (max 0 start)
|
||||||
vlfi-end-pos (min (+ vlfi-start-pos vlfi-batch-size)
|
vlfi-end-pos (min (+ vlfi-start-pos vlfi-batch-size)
|
||||||
@ -325,7 +325,7 @@ When given MINIMAL flag, skip non important operations."
|
|||||||
(defun vlfi-move-to-chunk (start end &optional minimal)
|
(defun vlfi-move-to-chunk (start end &optional minimal)
|
||||||
"Move to chunk determined by START END.
|
"Move to chunk determined by START END.
|
||||||
When given MINIMAL flag, skip non important operations."
|
When given MINIMAL flag, skip non important operations."
|
||||||
(or (verify-visited-file-modtime)
|
(or (verify-visited-file-modtime (current-buffer))
|
||||||
(setq vlfi-file-size (vlfi-get-file-size buffer-file-name)))
|
(setq vlfi-file-size (vlfi-get-file-size buffer-file-name)))
|
||||||
(setq vlfi-start-pos (max 0 start)
|
(setq vlfi-start-pos (max 0 start)
|
||||||
vlfi-end-pos (min end vlfi-file-size))
|
vlfi-end-pos (min end vlfi-file-size))
|
||||||
@ -370,7 +370,7 @@ Return number of bytes moved back for this to happen."
|
|||||||
(match-end-pos match-start-pos)
|
(match-end-pos match-start-pos)
|
||||||
(to-find count)
|
(to-find count)
|
||||||
(search-reporter (make-progress-reporter
|
(search-reporter (make-progress-reporter
|
||||||
(concat "Searching for " regexp)
|
(concat "Searching for " regexp "...")
|
||||||
(if backward
|
(if backward
|
||||||
(- vlfi-file-size vlfi-end-pos)
|
(- vlfi-file-size vlfi-end-pos)
|
||||||
vlfi-start-pos)
|
vlfi-start-pos)
|
||||||
@ -406,8 +406,9 @@ Return number of bytes moved back for this to happen."
|
|||||||
vlfi-start-pos))
|
vlfi-start-pos))
|
||||||
(point-max))
|
(point-max))
|
||||||
(point-max)))
|
(point-max)))
|
||||||
(progress-reporter-update search-reporter
|
(progress-reporter-update
|
||||||
vlfi-start-pos))))
|
search-reporter (- vlfi-file-size
|
||||||
|
vlfi-start-pos)))))
|
||||||
(while (not (zerop to-find))
|
(while (not (zerop to-find))
|
||||||
(cond ((re-search-forward regexp nil t)
|
(cond ((re-search-forward regexp nil t)
|
||||||
(setq to-find (1- to-find)
|
(setq to-find (1- to-find)
|
||||||
@ -483,8 +484,7 @@ successful. Return nil if nothing found."
|
|||||||
Search is performed chunk by chunk in `vlfi-batch-size' memory."
|
Search is performed chunk by chunk in `vlfi-batch-size' memory."
|
||||||
(interactive (list (read-regexp "Search whole file"
|
(interactive (list (read-regexp "Search whole file"
|
||||||
(if regexp-history
|
(if regexp-history
|
||||||
(car regexp-history))
|
(car regexp-history)))
|
||||||
'regexp-history)
|
|
||||||
(or current-prefix-arg 1)))
|
(or current-prefix-arg 1)))
|
||||||
(vlfi-re-search regexp count nil))
|
(vlfi-re-search regexp count nil))
|
||||||
|
|
||||||
@ -493,8 +493,7 @@ Search is performed chunk by chunk in `vlfi-batch-size' memory."
|
|||||||
Search is performed chunk by chunk in `vlfi-batch-size' memory."
|
Search is performed chunk by chunk in `vlfi-batch-size' memory."
|
||||||
(interactive (list (read-regexp "Search whole file backward"
|
(interactive (list (read-regexp "Search whole file backward"
|
||||||
(if regexp-history
|
(if regexp-history
|
||||||
(car regexp-history))
|
(car regexp-history)))
|
||||||
'regexp-history)
|
|
||||||
(or current-prefix-arg 1)))
|
(or current-prefix-arg 1)))
|
||||||
(vlfi-re-search regexp count t))
|
(vlfi-re-search regexp count t))
|
||||||
|
|
||||||
@ -548,7 +547,7 @@ or \\[vlfi-discard-edit] to discard changes.")))
|
|||||||
If changing size of chunk shift remaining file content."
|
If changing size of chunk shift remaining file content."
|
||||||
(interactive)
|
(interactive)
|
||||||
(when (and (buffer-modified-p)
|
(when (and (buffer-modified-p)
|
||||||
(or (verify-visited-file-modtime)
|
(or (verify-visited-file-modtime (current-buffer))
|
||||||
(y-or-n-p "File has changed since visited or saved. \
|
(y-or-n-p "File has changed since visited or saved. \
|
||||||
Save anyway? ")))
|
Save anyway? ")))
|
||||||
(let ((pos (point))
|
(let ((pos (point))
|
||||||
@ -572,7 +571,7 @@ Save anyway? ")))
|
|||||||
(buffer-disable-undo)
|
(buffer-disable-undo)
|
||||||
(let ((read-start-pos vlfi-end-pos)
|
(let ((read-start-pos vlfi-end-pos)
|
||||||
(coding-system-for-write 'no-conversion)
|
(coding-system-for-write 'no-conversion)
|
||||||
(reporter (make-progress-reporter "Adjusting file content"
|
(reporter (make-progress-reporter "Adjusting file content..."
|
||||||
vlfi-end-pos
|
vlfi-end-pos
|
||||||
vlfi-file-size)))
|
vlfi-file-size)))
|
||||||
(while (vlfi-shift-batch read-start-pos (- read-start-pos
|
(while (vlfi-shift-batch read-start-pos (- read-start-pos
|
||||||
@ -590,7 +589,7 @@ Save anyway? ")))
|
|||||||
"Read `vlfi-batch-size' bytes from READ-POS and write them \
|
"Read `vlfi-batch-size' bytes from READ-POS and write them \
|
||||||
back at WRITE-POS. Return nil if EOF is reached, t otherwise."
|
back at WRITE-POS. Return nil if EOF is reached, t otherwise."
|
||||||
(erase-buffer)
|
(erase-buffer)
|
||||||
(or (verify-visited-file-modtime)
|
(or (verify-visited-file-modtime (current-buffer))
|
||||||
(setq vlfi-file-size (vlfi-get-file-size buffer-file-name)))
|
(setq vlfi-file-size (vlfi-get-file-size buffer-file-name)))
|
||||||
(let ((read-end (+ read-pos vlfi-batch-size)))
|
(let ((read-end (+ read-pos vlfi-batch-size)))
|
||||||
(insert-file-contents-literally buffer-file-name nil
|
(insert-file-contents-literally buffer-file-name nil
|
||||||
@ -618,9 +617,9 @@ Done by saving content up front and then writing previous batch."
|
|||||||
(read-pos vlfi-end-pos)
|
(read-pos vlfi-end-pos)
|
||||||
(write-pos vlfi-start-pos)
|
(write-pos vlfi-start-pos)
|
||||||
swap-buffer
|
swap-buffer
|
||||||
(reporter (make-progress-reporter "Adjusting file content"
|
(reporter (make-progress-reporter
|
||||||
vlfi-start-pos
|
"Adjusting file content..."
|
||||||
vlfi-file-size)))
|
vlfi-start-pos vlfi-file-size)))
|
||||||
(while (vlfi-shift-batches size read-buffer read-pos
|
(while (vlfi-shift-batches size read-buffer read-pos
|
||||||
write-buffer write-pos)
|
write-buffer write-pos)
|
||||||
(setq swap-buffer read-buffer
|
(setq swap-buffer read-buffer
|
||||||
@ -630,6 +629,8 @@ Done by saving content up front and then writing previous batch."
|
|||||||
read-pos (+ read-pos size))
|
read-pos (+ read-pos size))
|
||||||
(progress-reporter-update reporter write-pos))
|
(progress-reporter-update reporter write-pos))
|
||||||
(progress-reporter-done reporter))
|
(progress-reporter-done reporter))
|
||||||
|
(set-buffer temp-buffer)
|
||||||
|
(set-buffer-modified-p nil)
|
||||||
(kill-buffer temp-buffer)
|
(kill-buffer temp-buffer)
|
||||||
(set-buffer vlfi-buffer)))
|
(set-buffer vlfi-buffer)))
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user