1
0
mirror of https://github.com/m00natic/vlfi.git synced 2024-10-05 18:30:51 +01:00

Fixes to hexl-mode activation.

This commit is contained in:
Andrey Kotlarski 2014-10-07 01:37:19 +03:00
parent 7b9befe81a
commit ac8d4008bd
3 changed files with 23 additions and 21 deletions

View File

@ -124,7 +124,7 @@ EVENT may hold details of the invocation."
pos-relative)))
(cond (current-prefix-arg
(setq vlf-buffer (vlf file t))
(or not-hexl (vlf-tune-hexlify))
(or not-hexl (hexl-mode))
(switch-to-buffer occur-buffer))
((not (buffer-live-p vlf-buffer))
(unless (catch 'found
@ -137,7 +137,7 @@ EVENT may hold details of the invocation."
(setq vlf-buffer buf)
(throw 'found t))))
(setq vlf-buffer (vlf file t))
(or not-hexl (vlf-tune-hexlify)))
(or not-hexl (hexl-mode)))
(switch-to-buffer occur-buffer)
(setq vlf-occur-vlf-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)
(end-pos vlf-end-pos)
(pos (point))
(batch-size vlf-batch-size)
(is-hexl (derived-mode-p 'hexl-mode)))
(batch-size vlf-batch-size))
(vlf-tune-batch (if (derived-mode-p 'hexl-mode)
'(:hexl :raw)
'(:insert :encode)) t)
@ -211,7 +210,6 @@ Prematurely ending indexing will still show what's found so far."
(goto-char (point-min))
(unwind-protect (vlf-build-occur regexp (current-buffer))
(vlf-move-to-chunk start-pos end-pos)
(if is-hexl (vlf-tune-hexlify))
(goto-char pos)
(setq vlf-batch-size batch-size)))))
(run-hook-with-args 'vlf-after-batch-functions 'occur))

View File

@ -135,7 +135,6 @@ Return t if search has been at least partially successful."
vlf-end-pos)))))
(progress-reporter-done reporter))
(set-buffer-modified-p nil)
(if is-hexl (vlf-tune-hexlify))
(if font-lock (font-lock-mode 1))
(let ((result
(if backward
@ -202,10 +201,13 @@ Search is performed chunk by chunk in `vlf-batch-size' memory."
(if regexp-history
(car regexp-history)))
(or current-prefix-arg 1))))
(let ((batch-size vlf-batch-size))
(or (vlf-re-search regexp count nil (min 1024 (/ vlf-batch-size 8))
nil nil t)
(setq vlf-batch-size batch-size))))
(let ((batch-size vlf-batch-size)
success)
(unwind-protect
(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)
"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
(car regexp-history)))
(or current-prefix-arg 1))))
(let ((batch-size vlf-batch-size))
(or (vlf-re-search regexp count t (min 1024 (/ vlf-batch-size 8))
nil nil t)
(setq vlf-batch-size batch-size))))
(let ((batch-size vlf-batch-size)
success)
(unwind-protect
(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)
"Go to line N. If N is negative, count from the end of file."

View File

@ -55,6 +55,7 @@ If changing size of chunk, shift remaining file content."
(progn (vlf-tune-write nil nil vlf-start-pos t
(vlf-tune-encode-length (point-min)
(point-max)))
(if hexl (vlf-tune-hexlify))
(setq vlf-file-size (vlf-get-file-size
buffer-file-truename)
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
region-length)))
(if (zerop size-change)
(vlf-tune-write nil nil vlf-start-pos t
(- vlf-end-pos vlf-start-pos))
(progn (vlf-tune-write nil nil vlf-start-pos t
(- vlf-end-pos vlf-start-pos))
(if hexl (vlf-tune-hexlify)))
(let ((pos (point))
(font-lock font-lock-mode)
(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\
till end. Use temporary copy of the whole file (slower but safer)? ")
(not vlf-save-in-place)))
(let ((file-tmp (make-temp-file
(file-name-nondirectory
buffer-file-name))))
(let ((file-tmp (make-temp-file "vlf")))
(setq time (float-time))
(copy-file buffer-file-name file-tmp t t t t)
(if (< 0 size-change)
@ -101,8 +101,7 @@ If changing size of chunk, shift remaining file content."
vlf-end-pos))
(vlf-update-buffer-name)
(goto-char pos)
(message "Save took %f seconds" (- (float-time) time))))))
(if hexl (vlf-tune-hexlify)))
(message "Save took %f seconds" (- (float-time) time)))))))
(run-hook-with-args 'vlf-after-batch-functions 'write))
t)