mirror of
https://github.com/m00natic/vlfi.git
synced 2025-01-18 12:05:31 +00:00
Fixes to hexl-mode activation.
This commit is contained in:
parent
7b9befe81a
commit
ac8d4008bd
@ -124,7 +124,7 @@ EVENT may hold details of the invocation."
|
|||||||
pos-relative)))
|
pos-relative)))
|
||||||
(cond (current-prefix-arg
|
(cond (current-prefix-arg
|
||||||
(setq vlf-buffer (vlf file t))
|
(setq vlf-buffer (vlf file t))
|
||||||
(or not-hexl (vlf-tune-hexlify))
|
(or not-hexl (hexl-mode))
|
||||||
(switch-to-buffer occur-buffer))
|
(switch-to-buffer occur-buffer))
|
||||||
((not (buffer-live-p vlf-buffer))
|
((not (buffer-live-p vlf-buffer))
|
||||||
(unless (catch 'found
|
(unless (catch 'found
|
||||||
@ -137,7 +137,7 @@ EVENT may hold details of the invocation."
|
|||||||
(setq vlf-buffer buf)
|
(setq vlf-buffer buf)
|
||||||
(throw 'found t))))
|
(throw 'found t))))
|
||||||
(setq vlf-buffer (vlf file t))
|
(setq vlf-buffer (vlf file t))
|
||||||
(or not-hexl (vlf-tune-hexlify)))
|
(or not-hexl (hexl-mode)))
|
||||||
(switch-to-buffer occur-buffer)
|
(switch-to-buffer occur-buffer)
|
||||||
(setq vlf-occur-vlf-buffer vlf-buffer)))
|
(setq vlf-occur-vlf-buffer vlf-buffer)))
|
||||||
(pop-to-buffer vlf-buffer)
|
(pop-to-buffer vlf-buffer)
|
||||||
@ -201,8 +201,7 @@ Prematurely ending indexing will still show what's found so far."
|
|||||||
(let ((start-pos vlf-start-pos)
|
(let ((start-pos vlf-start-pos)
|
||||||
(end-pos vlf-end-pos)
|
(end-pos vlf-end-pos)
|
||||||
(pos (point))
|
(pos (point))
|
||||||
(batch-size vlf-batch-size)
|
(batch-size vlf-batch-size))
|
||||||
(is-hexl (derived-mode-p 'hexl-mode)))
|
|
||||||
(vlf-tune-batch (if (derived-mode-p 'hexl-mode)
|
(vlf-tune-batch (if (derived-mode-p 'hexl-mode)
|
||||||
'(:hexl :raw)
|
'(:hexl :raw)
|
||||||
'(:insert :encode)) t)
|
'(:insert :encode)) t)
|
||||||
@ -211,7 +210,6 @@ Prematurely ending indexing will still show what's found so far."
|
|||||||
(goto-char (point-min))
|
(goto-char (point-min))
|
||||||
(unwind-protect (vlf-build-occur regexp (current-buffer))
|
(unwind-protect (vlf-build-occur regexp (current-buffer))
|
||||||
(vlf-move-to-chunk start-pos end-pos)
|
(vlf-move-to-chunk start-pos end-pos)
|
||||||
(if is-hexl (vlf-tune-hexlify))
|
|
||||||
(goto-char pos)
|
(goto-char pos)
|
||||||
(setq vlf-batch-size batch-size)))))
|
(setq vlf-batch-size batch-size)))))
|
||||||
(run-hook-with-args 'vlf-after-batch-functions 'occur))
|
(run-hook-with-args 'vlf-after-batch-functions 'occur))
|
||||||
|
@ -135,7 +135,6 @@ Return t if search has been at least partially successful."
|
|||||||
vlf-end-pos)))))
|
vlf-end-pos)))))
|
||||||
(progress-reporter-done reporter))
|
(progress-reporter-done reporter))
|
||||||
(set-buffer-modified-p nil)
|
(set-buffer-modified-p nil)
|
||||||
(if is-hexl (vlf-tune-hexlify))
|
|
||||||
(if font-lock (font-lock-mode 1))
|
(if font-lock (font-lock-mode 1))
|
||||||
(let ((result
|
(let ((result
|
||||||
(if backward
|
(if backward
|
||||||
@ -202,10 +201,13 @@ Search is performed chunk by chunk in `vlf-batch-size' memory."
|
|||||||
(if regexp-history
|
(if regexp-history
|
||||||
(car regexp-history)))
|
(car regexp-history)))
|
||||||
(or current-prefix-arg 1))))
|
(or current-prefix-arg 1))))
|
||||||
(let ((batch-size vlf-batch-size))
|
(let ((batch-size vlf-batch-size)
|
||||||
(or (vlf-re-search regexp count nil (min 1024 (/ vlf-batch-size 8))
|
success)
|
||||||
nil nil t)
|
(unwind-protect
|
||||||
(setq vlf-batch-size batch-size))))
|
(setq success (vlf-re-search regexp count nil
|
||||||
|
(min 1024 (/ vlf-batch-size 8))
|
||||||
|
nil nil t))
|
||||||
|
(or success (setq vlf-batch-size batch-size)))))
|
||||||
|
|
||||||
(defun vlf-re-search-backward (regexp count)
|
(defun vlf-re-search-backward (regexp count)
|
||||||
"Search backward for REGEXP prefix COUNT number of times.
|
"Search backward for REGEXP prefix COUNT number of times.
|
||||||
@ -215,10 +217,13 @@ Search is performed chunk by chunk in `vlf-batch-size' memory."
|
|||||||
(if regexp-history
|
(if regexp-history
|
||||||
(car regexp-history)))
|
(car regexp-history)))
|
||||||
(or current-prefix-arg 1))))
|
(or current-prefix-arg 1))))
|
||||||
(let ((batch-size vlf-batch-size))
|
(let ((batch-size vlf-batch-size)
|
||||||
(or (vlf-re-search regexp count t (min 1024 (/ vlf-batch-size 8))
|
success)
|
||||||
nil nil t)
|
(unwind-protect
|
||||||
(setq vlf-batch-size batch-size))))
|
(setq success (vlf-re-search regexp count t
|
||||||
|
(min 1024 (/ vlf-batch-size 8))
|
||||||
|
nil nil t))
|
||||||
|
(or success (setq vlf-batch-size batch-size)))))
|
||||||
|
|
||||||
(defun vlf-goto-line (n)
|
(defun vlf-goto-line (n)
|
||||||
"Go to line N. If N is negative, count from the end of file."
|
"Go to line N. If N is negative, count from the end of file."
|
||||||
|
13
vlf-write.el
13
vlf-write.el
@ -55,6 +55,7 @@ If changing size of chunk, shift remaining file content."
|
|||||||
(progn (vlf-tune-write nil nil vlf-start-pos t
|
(progn (vlf-tune-write nil nil vlf-start-pos t
|
||||||
(vlf-tune-encode-length (point-min)
|
(vlf-tune-encode-length (point-min)
|
||||||
(point-max)))
|
(point-max)))
|
||||||
|
(if hexl (vlf-tune-hexlify))
|
||||||
(setq vlf-file-size (vlf-get-file-size
|
(setq vlf-file-size (vlf-get-file-size
|
||||||
buffer-file-truename)
|
buffer-file-truename)
|
||||||
vlf-end-pos vlf-file-size)
|
vlf-end-pos vlf-file-size)
|
||||||
@ -64,8 +65,9 @@ If changing size of chunk, shift remaining file content."
|
|||||||
(size-change (- vlf-end-pos vlf-start-pos
|
(size-change (- vlf-end-pos vlf-start-pos
|
||||||
region-length)))
|
region-length)))
|
||||||
(if (zerop size-change)
|
(if (zerop size-change)
|
||||||
(vlf-tune-write nil nil vlf-start-pos t
|
(progn (vlf-tune-write nil nil vlf-start-pos t
|
||||||
(- vlf-end-pos vlf-start-pos))
|
(- vlf-end-pos vlf-start-pos))
|
||||||
|
(if hexl (vlf-tune-hexlify)))
|
||||||
(let ((pos (point))
|
(let ((pos (point))
|
||||||
(font-lock font-lock-mode)
|
(font-lock font-lock-mode)
|
||||||
(batch-size vlf-batch-size)
|
(batch-size vlf-batch-size)
|
||||||
@ -76,9 +78,7 @@ If changing size of chunk, shift remaining file content."
|
|||||||
(y-or-n-p "File content needs be adjusted\
|
(y-or-n-p "File content needs be adjusted\
|
||||||
till end. Use temporary copy of the whole file (slower but safer)? ")
|
till end. Use temporary copy of the whole file (slower but safer)? ")
|
||||||
(not vlf-save-in-place)))
|
(not vlf-save-in-place)))
|
||||||
(let ((file-tmp (make-temp-file
|
(let ((file-tmp (make-temp-file "vlf")))
|
||||||
(file-name-nondirectory
|
|
||||||
buffer-file-name))))
|
|
||||||
(setq time (float-time))
|
(setq time (float-time))
|
||||||
(copy-file buffer-file-name file-tmp t t t t)
|
(copy-file buffer-file-name file-tmp t t t t)
|
||||||
(if (< 0 size-change)
|
(if (< 0 size-change)
|
||||||
@ -101,8 +101,7 @@ If changing size of chunk, shift remaining file content."
|
|||||||
vlf-end-pos))
|
vlf-end-pos))
|
||||||
(vlf-update-buffer-name)
|
(vlf-update-buffer-name)
|
||||||
(goto-char pos)
|
(goto-char pos)
|
||||||
(message "Save took %f seconds" (- (float-time) time))))))
|
(message "Save took %f seconds" (- (float-time) time)))))))
|
||||||
(if hexl (vlf-tune-hexlify)))
|
|
||||||
(run-hook-with-args 'vlf-after-batch-functions 'write))
|
(run-hook-with-args 'vlf-after-batch-functions 'write))
|
||||||
t)
|
t)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user