mirror of
https://github.com/m00natic/vlfi.git
synced 2025-02-07 13:40:49 +00:00
Explicitly offer vlf-prefix-map so user can easily define another prefix
for vlf-mode-map. Remove vlf-refresh and refine vlf-revert.
This commit is contained in:
parent
c68c34ea90
commit
a0cafa71ea
47
vlf.el
47
vlf.el
@ -74,11 +74,10 @@ Possible values are: nil to never use it;
|
|||||||
(put 'vlf-file-size 'permanent-local t)
|
(put 'vlf-file-size 'permanent-local t)
|
||||||
|
|
||||||
(defvar vlf-mode-map
|
(defvar vlf-mode-map
|
||||||
(let ((map-prefix (make-sparse-keymap))
|
(let ((map (make-sparse-keymap)))
|
||||||
(map (make-sparse-keymap)))
|
(define-key map "n" 'vlf-next-batch)
|
||||||
(define-key map [next] 'vlf-next-batch)
|
(define-key map "p" 'vlf-prev-batch)
|
||||||
(define-key map [prior] 'vlf-prev-batch)
|
(define-key map " " 'vlf-next-batch-from-point)
|
||||||
(define-key map "n" 'vlf-next-batch-from-point)
|
|
||||||
(define-key map "+" 'vlf-change-batch-size)
|
(define-key map "+" 'vlf-change-batch-size)
|
||||||
(define-key map "-"
|
(define-key map "-"
|
||||||
(lambda () "Decrease vlf batch size by factor of 2."
|
(lambda () "Decrease vlf batch size by factor of 2."
|
||||||
@ -91,16 +90,21 @@ Possible values are: nil to never use it;
|
|||||||
(define-key map "]" 'vlf-end-of-file)
|
(define-key map "]" 'vlf-end-of-file)
|
||||||
(define-key map "j" 'vlf-jump-to-chunk)
|
(define-key map "j" 'vlf-jump-to-chunk)
|
||||||
(define-key map "l" 'vlf-goto-line)
|
(define-key map "l" 'vlf-goto-line)
|
||||||
(define-key map "g" 'vlf-refresh)
|
(define-key map "g" 'vlf-revert)
|
||||||
(define-key map-prefix "\C-c\C-v" map)
|
map)
|
||||||
map-prefix)
|
|
||||||
"Keymap for `vlf-mode'.")
|
"Keymap for `vlf-mode'.")
|
||||||
|
|
||||||
|
(defvar vlf-prefix-map
|
||||||
|
(let ((map (make-sparse-keymap)))
|
||||||
|
(define-key map "\C-c\C-v" vlf-mode-map)
|
||||||
|
map)
|
||||||
|
"Prefixed keymap for `vlf-mode'.")
|
||||||
|
|
||||||
(define-minor-mode vlf-mode
|
(define-minor-mode vlf-mode
|
||||||
"Mode to browse large files in."
|
"Mode to browse large files in."
|
||||||
:lighter " VLF"
|
:lighter " VLF"
|
||||||
:group 'vlf
|
:group 'vlf
|
||||||
:keymap vlf-mode-map
|
:keymap vlf-prefix-map
|
||||||
(if vlf-mode
|
(if vlf-mode
|
||||||
(progn
|
(progn
|
||||||
(set (make-local-variable 'require-final-newline) nil)
|
(set (make-local-variable 'require-final-newline) nil)
|
||||||
@ -275,10 +279,12 @@ With FROM-END prefix, start from the back."
|
|||||||
(defun vlf-revert (&optional _ignore-auto noconfirm)
|
(defun vlf-revert (&optional _ignore-auto noconfirm)
|
||||||
"Revert current chunk. Ignore _IGNORE-AUTO.
|
"Revert current chunk. Ignore _IGNORE-AUTO.
|
||||||
Ask for confirmation if NOCONFIRM is nil."
|
Ask for confirmation if NOCONFIRM is nil."
|
||||||
(if (or noconfirm
|
(interactive)
|
||||||
(yes-or-no-p (format "Revert buffer from file %s? "
|
(when (or noconfirm
|
||||||
buffer-file-name)))
|
(yes-or-no-p (format "Revert buffer from file %s? "
|
||||||
(vlf-move-to-chunk-2 vlf-start-pos vlf-end-pos)))
|
buffer-file-name)))
|
||||||
|
(set-buffer-modified-p nil)
|
||||||
|
(vlf-move-to-chunk-2 vlf-start-pos vlf-end-pos)))
|
||||||
|
|
||||||
(defun vlf-jump-to-chunk (n)
|
(defun vlf-jump-to-chunk (n)
|
||||||
"Go to to chunk N."
|
"Go to to chunk N."
|
||||||
@ -311,8 +317,7 @@ When prefix argument is negative
|
|||||||
append next APPEND number of batches to the existing buffer."
|
append next APPEND number of batches to the existing buffer."
|
||||||
(interactive "p")
|
(interactive "p")
|
||||||
(vlf-verify-size)
|
(vlf-verify-size)
|
||||||
(let* ((end (min (+ vlf-end-pos (* vlf-batch-size
|
(let* ((end (min (+ vlf-end-pos (* vlf-batch-size (abs append)))
|
||||||
(abs append)))
|
|
||||||
vlf-file-size))
|
vlf-file-size))
|
||||||
(start (if (< append 0)
|
(start (if (< append 0)
|
||||||
vlf-start-pos
|
vlf-start-pos
|
||||||
@ -328,8 +333,7 @@ When prefix argument is negative
|
|||||||
(interactive "p")
|
(interactive "p")
|
||||||
(if (zerop vlf-start-pos)
|
(if (zerop vlf-start-pos)
|
||||||
(error "Already at BOF"))
|
(error "Already at BOF"))
|
||||||
(let* ((start (max 0 (- vlf-start-pos (* vlf-batch-size
|
(let* ((start (max 0 (- vlf-start-pos (* vlf-batch-size (abs prepend)))))
|
||||||
(abs prepend)))))
|
|
||||||
(end (if (< prepend 0)
|
(end (if (< prepend 0)
|
||||||
vlf-end-pos
|
vlf-end-pos
|
||||||
(+ start vlf-batch-size))))
|
(+ start vlf-batch-size))))
|
||||||
@ -901,15 +905,6 @@ in file: %s" total-matches line regexp file)
|
|||||||
(vlf-occur-mode))
|
(vlf-occur-mode))
|
||||||
(display-buffer occur-buffer)))))
|
(display-buffer occur-buffer)))))
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
||||||
;;; editing
|
|
||||||
|
|
||||||
(defun vlf-refresh ()
|
|
||||||
"Discard edit and refresh chunk from file."
|
|
||||||
(interactive)
|
|
||||||
(set-buffer-modified-p nil)
|
|
||||||
(vlf-move-to-chunk-2 vlf-start-pos vlf-end-pos))
|
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;;; saving
|
;;; saving
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user