[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/vlf f3132c0 044/310: Keep current position when moving
From: |
Stefan Monnier |
Subject: |
[elpa] externals/vlf f3132c0 044/310: Keep current position when moving around chunks. |
Date: |
Sat, 28 Nov 2020 00:32:43 -0500 (EST) |
branch: externals/vlf
commit f3132c0970496bbb1665f3b436ba0b1731c6db53
Author: Andrey Kotlarski <m00naticus@gmail.com>
Commit: Andrey Kotlarski <m00naticus@gmail.com>
Keep current position when moving around chunks.
---
vlfi.el | 39 ++++++++++++++++++++++++---------------
1 file changed, 24 insertions(+), 15 deletions(-)
diff --git a/vlfi.el b/vlfi.el
index 410a568..ff1bd59 100644
--- a/vlfi.el
+++ b/vlfi.el
@@ -1,5 +1,4 @@
-;;; vlfi.el --- View Large Files Improved
-;;; -*- lexical-bind: t -*-
+;;; vlfi.el --- View Large Files Improved -*- lexical-binding: t -*-
;; Copyright (C) 2006, 2012, 2013 Free Software Foundation, Inc.
@@ -63,12 +62,8 @@
(vlfi-change-batch-size t)))
(define-key map "s" 'vlfi-re-search-forward)
(define-key map "r" 'vlfi-re-search-backward)
- (define-key map "]" (lambda () "Jump to end of file content."
- (interactive)
- (vlfi-insert-file buffer-file-name t)))
- (define-key map "[" (lambda () "Jump to beginning of file content."
- (interactive)
- (vlfi-insert-file buffer-file-name)))
+ (define-key map "[" 'vlfi-beginning-of-file)
+ (define-key map "]" 'vlfi-end-of-file)
(define-key map "e" 'vlfi-edit-mode)
map)
"Keymap for `vlfi-mode'.")
@@ -180,10 +175,12 @@ Adjust according to file start/end and show
`vlfi-batch-size' bytes."
(nth 7 (file-attributes buffer-file-name))
vlfi-end-pos (min vlfi-end-pos vlfi-file-size)
vlfi-start-pos (max 0 (- vlfi-end-pos vlfi-batch-size))))
- (let ((inhibit-read-only t))
+ (let ((inhibit-read-only t)
+ (pos (point)))
(erase-buffer)
(insert-file-contents buffer-file-name nil
- vlfi-start-pos vlfi-end-pos))
+ vlfi-start-pos vlfi-end-pos)
+ (goto-char pos))
(set-buffer-modified-p nil)
(vlfi-update-buffer-name))
@@ -194,15 +191,17 @@ Adjust according to file start/end and show
`vlfi-batch-size' bytes."
(file-attributes buffer-file-name))))
(setq vlfi-start-pos (max 0 start)
vlfi-end-pos (min end vlfi-file-size))
- (let ((inhibit-read-only t))
+ (let ((inhibit-read-only t)
+ (pos (point)))
(erase-buffer)
(insert-file-contents buffer-file-name nil
- vlfi-start-pos vlfi-end-pos))
+ vlfi-start-pos vlfi-end-pos)
+ (goto-char pos))
(set-buffer-modified-p nil)
(vlfi-update-buffer-name))
-(defun vlfi-insert-file (file &optional from-end)
- "Insert first chunk of FILE contents in current buffer.
+(defun vlfi-insert-file (&optional from-end)
+ "Insert first chunk of current 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))
@@ -211,6 +210,16 @@ With FROM-END prefix, start from the back."
vlfi-end-pos (min vlfi-batch-size vlfi-file-size)))
(vlfi-move-to-chunk vlfi-start-pos vlfi-end-pos))
+(defun vlfi-beginning-of-file ()
+ "Jump to beginning of file content."
+ (interactive)
+ (vlfi-insert-file))
+
+(defun vlfi-end-of-file ()
+ "Jump to end of file content."
+ (interactive)
+ (vlfi-insert-file t))
+
;;;###autoload
(defun vlfi (file &optional from-end)
"View Large FILE. With FROM-END prefix, view from the back.
@@ -221,7 +230,7 @@ buffer. You can customize number of bytes displayed by
customizing
(with-current-buffer (generate-new-buffer "*vlfi*")
(setq buffer-file-name file
vlfi-file-size (nth 7 (file-attributes file)))
- (vlfi-insert-file file from-end)
+ (vlfi-insert-file from-end)
(vlfi-mode)
(switch-to-buffer (current-buffer))))
- [elpa] externals/vlf 59d5d2c 008/310: Add lexical-bind declaration., (continued)
- [elpa] externals/vlf 59d5d2c 008/310: Add lexical-bind declaration., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 782b7e4 009/310: Make filename argument of `vlf-if-file-too-large' optional so it at, Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 375c96f 018/310: Add backward whole file search., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 30e4959 019/310: Add direct jumps to first and last chunks., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 42693f6 026/310: Update README., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf ac382e9 032/310: Add temporary highlight of match., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 9abee04 038/310: Merge branch 'master' into edit, Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 0ff2f3e 040/310: Merge branch 'master' into edit, Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 1948f3e 041/310: Make VLFI edit mode actually working., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 5405a30 045/310: Intercept buffer saving with vlfi-write., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf f3132c0 044/310: Keep current position when moving around chunks.,
Stefan Monnier <=
- [elpa] externals/vlf 8787186 055/310: Show paging according to batch size instead of percentage., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 8f6299c 056/310: Simplify detection of buffer size change., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf f23262e 057/310: Add shift back of file contents when edited chunk shrinks in size., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 2f201c5 061/310: Add jump to chunk command., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf d5f2a36 060/310: Rearrange code in sections., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 705f9ce 064/310: Add issue section to the README., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 9fad430 066/310: Fix positioning after save., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf e545769 128/310: Fix adjusting of end chunk bytes., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf ae2237d 135/310: Minor adjustments:, Stefan Monnier, 2020/11/28
- [elpa] externals/vlf cb47e19 139/310: Use temporary buffer for occur in case of modifications., Stefan Monnier, 2020/11/28