Skip to content

Commit

Permalink
Encode smaller region to detect cut point overall offset in vlf-occur
Browse files Browse the repository at this point in the history
when moving to next batch and be more precise with hexl-mode active.
  • Loading branch information
m00natic committed Dec 27, 2014
1 parent bc398d6 commit b300137
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
8 changes: 8 additions & 0 deletions vlf-base.el
Expand Up @@ -375,6 +375,14 @@ which deletion was performed."
(delete-region cut-point (point-max))))
(cons dist (1+ cut-point))))

(defun vlf-byte-position (point)
"Determine global byte position of POINT."
(let ((pmax (point-max)))
(if (< (/ pmax 2) point)
(- vlf-end-pos (vlf-tune-encode-length (min (1+ point) pmax)
pmax))
(+ vlf-start-pos (vlf-tune-encode-length (point-min) point)))))

(defun vlf-shift-undo-list (n)
"Shift undo list element regions by N."
(or (null buffer-undo-list) (eq buffer-undo-list t)
Expand Down
16 changes: 7 additions & 9 deletions vlf-occur.el
Expand Up @@ -309,15 +309,16 @@ Prematurely ending indexing will still show what's found so far."
match-end-point)))))
(- vlf-end-pos (* (- 10 (forward-line 10))
hexl-bits)))
(let* ((batch-step (min 1024 (/ vlf-batch-size
(let* ((pmax (point-max))
(batch-step (min 1024 (/ vlf-batch-size
10)))
(batch-point
(max match-end-point
(or
(byte-to-position
(- vlf-batch-size batch-step))
(progn
(goto-char (point-max))
(goto-char pmax)
(let ((last (line-beginning-position)))
(if (= last (point-min))
(1- (point))
Expand All @@ -334,15 +335,12 @@ Prematurely ending indexing will still show what's found so far."
(goto-char match-end-point)
(forward-line)
(setq first-line-incomplete
(let ((pmax (point-max)))
(if (= (point) pmax)
(- pmax match-end-point))))
(+ vlf-start-pos
(vlf-tune-encode-length (point-min)
batch-point))))))
(if (= (point) pmax)
(- pmax match-end-point)))
(vlf-byte-position batch-point)))))
(vlf-tune-batch tune-types)
(setq vlf-end-pos start) ;not to adjust start
(vlf-move-to-chunk-2 start (+ start vlf-batch-size)))
(vlf-move-to-chunk start (+ start vlf-batch-size)))
(setq match-start-point (point-min)
match-end-point match-start-point)
(goto-char match-end-point)
Expand Down

0 comments on commit b300137

Please sign in to comment.