mirror of
https://github.com/m00natic/vlfi.git
synced 2025-04-18 16:50:19 +01:00
Fix occur indexing not to skip last chunk.
This commit is contained in:
parent
fd9c258fc8
commit
fbe081417c
43
vlfi.el
43
vlfi.el
@ -438,7 +438,7 @@ Return number of bytes moved back for this to happen."
|
|||||||
(or (byte-to-position
|
(or (byte-to-position
|
||||||
(- match-end-pos
|
(- match-end-pos
|
||||||
vlfi-start-pos))
|
vlfi-start-pos))
|
||||||
(point-max))
|
(point-min))
|
||||||
(point-min)))
|
(point-min)))
|
||||||
(progress-reporter-update reporter
|
(progress-reporter-update reporter
|
||||||
vlfi-end-pos)))))
|
vlfi-end-pos)))))
|
||||||
@ -583,9 +583,8 @@ EVENT may hold details of the invocation."
|
|||||||
(let ((chunk-start (get-char-property pos 'chunk-start))
|
(let ((chunk-start (get-char-property pos 'chunk-start))
|
||||||
(chunk-end (get-char-property pos 'chunk-end))
|
(chunk-end (get-char-property pos 'chunk-end))
|
||||||
(buffer (get-char-property pos 'buffer))
|
(buffer (get-char-property pos 'buffer))
|
||||||
(match-pos (or (get-char-property pos 'match-pos)
|
(match-pos (+ (get-char-property pos 'line-pos)
|
||||||
(+ (get-char-property pos 'line-pos)
|
pos-relative)))
|
||||||
pos-relative))))
|
|
||||||
(or (buffer-live-p buffer)
|
(or (buffer-live-p buffer)
|
||||||
(let ((occur-buffer (current-buffer)))
|
(let ((occur-buffer (current-buffer)))
|
||||||
(setq buffer (vlfi file))
|
(setq buffer (vlfi file))
|
||||||
@ -632,12 +631,13 @@ Prematurely ending indexing will still show what's found so far."
|
|||||||
(line-regexp (concat "\\(?5:[\n\C-m]\\)\\|\\(?10:"
|
(line-regexp (concat "\\(?5:[\n\C-m]\\)\\|\\(?10:"
|
||||||
regexp "\\)"))
|
regexp "\\)"))
|
||||||
(batch-step (/ vlfi-batch-size 8))
|
(batch-step (/ vlfi-batch-size 8))
|
||||||
|
(end-of-file nil)
|
||||||
(reporter (make-progress-reporter
|
(reporter (make-progress-reporter
|
||||||
(concat "Building index for " regexp "...")
|
(concat "Building index for " regexp "...")
|
||||||
vlfi-start-pos vlfi-file-size)))
|
vlfi-start-pos vlfi-file-size)))
|
||||||
(unwind-protect
|
(unwind-protect
|
||||||
(progn
|
(progn
|
||||||
(while (/= vlfi-end-pos vlfi-file-size)
|
(while (not end-of-file)
|
||||||
(if (re-search-forward line-regexp nil t)
|
(if (re-search-forward line-regexp nil t)
|
||||||
(progn
|
(progn
|
||||||
(setq match-end-pos (+ vlfi-start-pos
|
(setq match-end-pos (+ vlfi-start-pos
|
||||||
@ -675,29 +675,31 @@ Prematurely ending indexing will still show what's found so far."
|
|||||||
line))))
|
line))))
|
||||||
(setq last-match-line line
|
(setq last-match-line line
|
||||||
total-matches (1+ total-matches))
|
total-matches (1+ total-matches))
|
||||||
(let ((line-start (+ (line-beginning-position)
|
(let ((line-start (1+
|
||||||
1))
|
(line-beginning-position)))
|
||||||
(match-pos (match-beginning 10)))
|
(match-pos (match-beginning 10)))
|
||||||
(add-text-properties ; mark match
|
(add-text-properties ; mark match
|
||||||
(+ line-start match-pos (- last-line-pos))
|
(+ line-start match-pos (- last-line-pos))
|
||||||
(+ line-start (match-end 10)
|
(+ line-start (match-end 10)
|
||||||
(- last-line-pos))
|
(- last-line-pos))
|
||||||
(list 'face 'match 'match-pos match-pos
|
(list 'face 'match
|
||||||
'help-echo
|
'help-echo
|
||||||
(format "Move to match %d"
|
(format "Move to match %d"
|
||||||
total-matches))))))))
|
total-matches))))))))
|
||||||
(let ((batch-move (- vlfi-end-pos batch-step)))
|
(setq end-of-file (= vlfi-end-pos vlfi-file-size))
|
||||||
(vlfi-move-to-batch (if (< batch-move match-end-pos)
|
(unless end-of-file
|
||||||
match-end-pos
|
(let ((batch-move (- vlfi-end-pos batch-step)))
|
||||||
batch-move) t))
|
(vlfi-move-to-batch (if (< batch-move match-end-pos)
|
||||||
(goto-char (if (< vlfi-start-pos match-end-pos)
|
match-end-pos
|
||||||
(or (byte-to-position (- match-end-pos
|
batch-move) t))
|
||||||
vlfi-start-pos))
|
(goto-char (if (< vlfi-start-pos match-end-pos)
|
||||||
(point-min))
|
(or (byte-to-position (- match-end-pos
|
||||||
(point-min)))
|
vlfi-start-pos))
|
||||||
(setq last-match-line 0
|
(point-min))
|
||||||
last-line-pos (point-min))
|
(point-min)))
|
||||||
(progress-reporter-update reporter vlfi-end-pos)))
|
(setq last-match-line 0
|
||||||
|
last-line-pos (line-beginning-position))
|
||||||
|
(progress-reporter-update reporter vlfi-end-pos))))
|
||||||
(progress-reporter-done reporter))
|
(progress-reporter-done reporter))
|
||||||
(if (zerop total-matches)
|
(if (zerop total-matches)
|
||||||
(progn (with-current-buffer occur-buffer
|
(progn (with-current-buffer occur-buffer
|
||||||
@ -738,6 +740,7 @@ or \\[vlfi-discard-edit] to discard changes.")))
|
|||||||
(defun vlfi-discard-edit ()
|
(defun vlfi-discard-edit ()
|
||||||
"Discard edit and refresh chunk from file."
|
"Discard edit and refresh chunk from file."
|
||||||
(interactive)
|
(interactive)
|
||||||
|
(set-buffer-modified-p nil)
|
||||||
(vlfi-move-to-chunk vlfi-start-pos vlfi-end-pos)
|
(vlfi-move-to-chunk vlfi-start-pos vlfi-end-pos)
|
||||||
(vlfi-mode)
|
(vlfi-mode)
|
||||||
(message "Switched to VLFI mode."))
|
(message "Switched to VLFI mode."))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user