mirror of
https://github.com/m00natic/vlfi.git
synced 2025-02-24 05:48:06 +00:00
Add direct jumps to first and last chunks.
This commit is contained in:
parent
375c96f89b
commit
30e495901b
48
vlfi.el
48
vlfi.el
@ -63,6 +63,12 @@
|
|||||||
(vlfi-change-batch-size t)))
|
(vlfi-change-batch-size t)))
|
||||||
(define-key map "\C-c\C-s" 'vlfi-re-search-forward)
|
(define-key map "\C-c\C-s" 'vlfi-re-search-forward)
|
||||||
(define-key map "\C-c\C-r" 'vlfi-re-search-backward)
|
(define-key map "\C-c\C-r" 'vlfi-re-search-backward)
|
||||||
|
(define-key map "\C-c>" (lambda () "Jump to end of file content."
|
||||||
|
(interactive)
|
||||||
|
(vlfi-insert-file buffer-file-name t)))
|
||||||
|
(define-key map "\C-c<" (lambda () "Jump to beginning of file content."
|
||||||
|
(interactive)
|
||||||
|
(vlfi-insert-file buffer-file-name)))
|
||||||
map)
|
map)
|
||||||
"Keymap for `vlfi-mode'.")
|
"Keymap for `vlfi-mode'.")
|
||||||
|
|
||||||
@ -156,29 +162,33 @@ When prefix argument is negative
|
|||||||
(set-buffer-modified-p nil)
|
(set-buffer-modified-p nil)
|
||||||
(vlfi-update-buffer-name))
|
(vlfi-update-buffer-name))
|
||||||
|
|
||||||
|
(defun vlfi-insert-file (file &optional from-end)
|
||||||
|
"Insert first chunk of FILE contents in current buffer.
|
||||||
|
With FROM-END prefix, start from the back."
|
||||||
|
(if from-end
|
||||||
|
(setq vlfi-start-pos (max 0 (- vlfi-file-size vlfi-batch-size))
|
||||||
|
vlfi-end-pos vlfi-file-size)
|
||||||
|
(setq vlfi-start-pos 0
|
||||||
|
vlfi-end-pos (min vlfi-batch-size vlfi-file-size)))
|
||||||
|
(let ((inhibit-read-only t))
|
||||||
|
(erase-buffer)
|
||||||
|
(insert-file-contents buffer-file-name nil
|
||||||
|
vlfi-start-pos vlfi-end-pos))
|
||||||
|
(set-buffer-modified-p nil)
|
||||||
|
(vlfi-update-buffer-name))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun vlfi (from-end file)
|
(defun vlfi (file &optional from-end)
|
||||||
"View a Large File in Emacs.
|
"View Large FILE. With FROM-END prefix, view from the back.
|
||||||
With FROM-END prefix, view from the back.
|
Batches of the file data from FILE will be displayed in a read-only
|
||||||
FILE is the file to open.
|
buffer. You can customize number of bytes displayed by customizing
|
||||||
Batches of the file data from FILE will be displayed in a
|
`vlfi-batch-size'."
|
||||||
read-only buffer.
|
(interactive "fFile to open: \nP")
|
||||||
You can customize the number of bytes to
|
|
||||||
display by customizing `vlfi-batch-size'."
|
|
||||||
(interactive "P\nfFile to open: ")
|
|
||||||
(with-current-buffer (generate-new-buffer "*vlfi*")
|
(with-current-buffer (generate-new-buffer "*vlfi*")
|
||||||
(buffer-disable-undo)
|
(buffer-disable-undo)
|
||||||
(setq buffer-file-name file
|
(setq buffer-file-name file
|
||||||
vlfi-file-size (nth 7 (file-attributes file)))
|
vlfi-file-size (nth 7 (file-attributes file)))
|
||||||
(if from-end
|
(vlfi-insert-file file from-end)
|
||||||
(setq vlfi-start-pos (max 0
|
|
||||||
(- vlfi-file-size vlfi-batch-size))
|
|
||||||
vlfi-end-pos vlfi-file-size)
|
|
||||||
(setq vlfi-start-pos 0
|
|
||||||
vlfi-end-pos (min vlfi-batch-size vlfi-file-size)))
|
|
||||||
(vlfi-update-buffer-name)
|
|
||||||
(insert-file-contents buffer-file-name nil
|
|
||||||
vlfi-start-pos vlfi-end-pos)
|
|
||||||
(vlfi-mode)
|
(vlfi-mode)
|
||||||
(switch-to-buffer (current-buffer))))
|
(switch-to-buffer (current-buffer))))
|
||||||
|
|
||||||
@ -187,7 +197,7 @@ You can customize the number of bytes to
|
|||||||
"In Dired, visit the file on this line in VLFI mode.
|
"In Dired, visit the file on this line in VLFI mode.
|
||||||
With FROM-END prefix, view from the back."
|
With FROM-END prefix, view from the back."
|
||||||
(interactive "P")
|
(interactive "P")
|
||||||
(vlfi from-end (dired-get-file-for-visit)))
|
(vlfi (dired-get-file-for-visit) from-end))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(eval-after-load "dired"
|
(eval-after-load "dired"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user