1
0
mirror of https://github.com/m00natic/vlfi.git synced 2025-01-31 02:00:47 +00:00

Add adjust command for cases where chunk starts with part of multibyte symbol.

This commit is contained in:
Andrey Kotlarski 2013-04-14 18:54:51 +03:00
parent 74febeb183
commit 473536e050

14
vlfi.el
View File

@ -67,6 +67,7 @@
(define-key map "e" 'vlfi-edit-mode) (define-key map "e" 'vlfi-edit-mode)
(define-key map "j" 'vlfi-jump-to-chunk) (define-key map "j" 'vlfi-jump-to-chunk)
(define-key map "l" 'vlfi-goto-line) (define-key map "l" 'vlfi-goto-line)
(define-key map "a" 'vlfi-adjust-chunk)
map) map)
"Keymap for `vlfi-mode'.") "Keymap for `vlfi-mode'.")
@ -460,6 +461,19 @@ Search is performed chunk by chunk in `vlfi-batch-size' memory."
(vlfi-move-to-chunk start-pos end-pos) (vlfi-move-to-chunk start-pos end-pos)
(goto-char pos))))) (goto-char pos)))))
(defun vlfi-adjust-chunk (bytes)
"Adjust chunk beginning by BYTES."
(interactive "p")
(or (zerop vlfi-start-pos)
(let ((pos (+ (point) bytes)))
(setq vlfi-start-pos (- vlfi-start-pos bytes))
(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)
(goto-char pos))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; editing ;;; editing