From f1ade8106c3d6b05a650743598c1830560b09f20 Mon Sep 17 00:00:00 2001 From: Andrey Kotlarski Date: Sun, 14 Apr 2013 02:18:06 +0300 Subject: [PATCH] Add go to line command. --- vlfi.el | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/vlfi.el b/vlfi.el index 347788f..6bf37ca 100644 --- a/vlfi.el +++ b/vlfi.el @@ -66,6 +66,7 @@ (define-key map "]" 'vlfi-end-of-file) (define-key map "e" 'vlfi-edit-mode) (define-key map "j" 'vlfi-jump-to-chunk) + (define-key map "l" 'vlfi-goto-line) map) "Keymap for `vlfi-mode'.") @@ -425,6 +426,22 @@ Search is performed chunk by chunk in `vlfi-batch-size' memory." (or current-prefix-arg 1))) (vlfi-re-search regexp count t)) +(defun vlfi-goto-line (n) + "Go to line N." + (interactive "nGo to line: ") + (let ((start-pos vlfi-start-pos) + (end-pos vlfi-end-pos) + (pos (point)) + (success nil)) + (unwind-protect + (progn (vlfi-beginning-of-file) + (goto-char (point-min)) + (setq success (vlfi-re-search-forward "[\n\C-m]" + (1- n)))) + (unless success + (vlfi-move-to-chunk start-pos end-pos) + (goto-char pos))))) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; editing