mirror of
https://github.com/m00natic/vlfi.git
synced 2025-03-26 12:38:06 +00:00
Fix follow functionality and explicitly set variable as buffer local.
This commit is contained in:
parent
95e625938e
commit
66db665d82
@ -29,6 +29,7 @@
|
||||
|
||||
(defvar vlf-follow-timer nil
|
||||
"Contains timer if vlf buffer is set to continuously recenter.")
|
||||
(make-variable-buffer-local 'vlf-follow-timer)
|
||||
(put 'vlf-follow-timer 'permanent-local t)
|
||||
|
||||
(defun vlf-recenter (vlf-buffer)
|
||||
@ -57,8 +58,9 @@
|
||||
|
||||
(defun vlf-stop-follow ()
|
||||
"Stop continuous recenter."
|
||||
(cancel-timer vlf-follow-timer)
|
||||
(setq vlf-follow-timer nil))
|
||||
(when vlf-follow-timer
|
||||
(cancel-timer vlf-follow-timer)
|
||||
(setq vlf-follow-timer nil)))
|
||||
|
||||
(defun vlf-start-follow (interval)
|
||||
"Continuously recenter chunk around point every INTERVAL seconds."
|
||||
|
@ -126,7 +126,7 @@ Prematurely ending indexing will still show what's found so far."
|
||||
(with-temp-buffer
|
||||
(setq buffer-file-name file)
|
||||
(set-buffer-modified-p nil)
|
||||
(set (make-local-variable 'vlf-batch-size) batch-size)
|
||||
(setq-local vlf-batch-size batch-size)
|
||||
(vlf-mode 1)
|
||||
(goto-char (point-min))
|
||||
(vlf-with-undo-disabled
|
||||
|
20
vlf.el
20
vlf.el
@ -51,12 +51,15 @@
|
||||
;;; Keep track of file position.
|
||||
(defvar vlf-start-pos 0
|
||||
"Absolute position of the visible chunk start.")
|
||||
(make-variable-buffer-local 'vlf-start-pos)
|
||||
(put 'vlf-start-pos 'permanent-local t)
|
||||
|
||||
(defvar vlf-end-pos 0 "Absolute position of the visible chunk end.")
|
||||
(make-variable-buffer-local 'vlf-end-pos)
|
||||
(put 'vlf-end-pos 'permanent-local t)
|
||||
|
||||
(defvar vlf-file-size 0 "Total size of presented file.")
|
||||
(make-variable-buffer-local 'vlf-file-size)
|
||||
(put 'vlf-file-size 'permanent-local t)
|
||||
|
||||
(autoload 'vlf-write "vlf-write" "Write current chunk to file.")
|
||||
@ -69,6 +72,8 @@
|
||||
"Make whole file occur style index for REGEXP.")
|
||||
(autoload 'vlf-toggle-follow "vlf-follow"
|
||||
"Toggle continuous chunk recenter around current point.")
|
||||
(autoload 'vlf-stop-follow "vlf-follow"
|
||||
"Stop continuous recenter.")
|
||||
|
||||
(defvar vlf-mode-map
|
||||
(let ((map (make-sparse-keymap)))
|
||||
@ -112,22 +117,19 @@
|
||||
:keymap vlf-prefix-map
|
||||
(if vlf-mode
|
||||
(progn
|
||||
(set (make-local-variable 'require-final-newline) nil)
|
||||
(setq-local require-final-newline nil)
|
||||
(add-hook 'write-file-functions 'vlf-write nil t)
|
||||
(set (make-local-variable 'revert-buffer-function)
|
||||
'vlf-revert)
|
||||
(setq-local revert-buffer-function 'vlf-revert)
|
||||
(make-local-variable 'vlf-batch-size)
|
||||
(set (make-local-variable 'vlf-file-size)
|
||||
(vlf-get-file-size buffer-file-truename))
|
||||
(set (make-local-variable 'vlf-start-pos) 0)
|
||||
(set (make-local-variable 'vlf-end-pos) 0)
|
||||
(set (make-local-variable 'vlf-follow-timer) nil)
|
||||
(setq vlf-file-size (vlf-get-file-size buffer-file-truename)
|
||||
vlf-start-pos 0
|
||||
vlf-end-pos 0)
|
||||
(let* ((pos (position-bytes (point)))
|
||||
(start (* (/ pos vlf-batch-size) vlf-batch-size)))
|
||||
(goto-char (byte-to-position (- pos start)))
|
||||
(vlf-move-to-batch start)))
|
||||
(kill-local-variable 'revert-buffer-function)
|
||||
(vlf-stop-following)
|
||||
(vlf-stop-follow)
|
||||
(when (or (not large-file-warning-threshold)
|
||||
(< vlf-file-size large-file-warning-threshold)
|
||||
(y-or-n-p (format "Load whole file (%s)? "
|
||||
|
Loading…
x
Reference in New Issue
Block a user