[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/vlf 8ed9192 117/310: Review fixes:
From: |
Stefan Monnier |
Subject: |
[elpa] externals/vlf 8ed9192 117/310: Review fixes: |
Date: |
Sat, 28 Nov 2020 00:32:58 -0500 (EST) |
branch: externals/vlf
commit 8ed919209aa08c809e3e773f6d94f3a50fe216fa
Author: Andrey Kotlarski <m00naticus@gmail.com>
Commit: Andrey Kotlarski <m00naticus@gmail.com>
Review fixes:
- move put statements to top level
- add write-file-functions hook locally
- vlfi-if-file-too-large becomes around advice
- minor style changes
---
vlfi.el | 33 +++++++++++++++------------------
1 file changed, 15 insertions(+), 18 deletions(-)
diff --git a/vlfi.el b/vlfi.el
index 7b27468..a114f81 100644
--- a/vlfi.el
+++ b/vlfi.el
@@ -70,23 +70,22 @@
map)
"Keymap for `vlfi-mode'.")
+(put 'vlfi-batch-size 'permanent-local t)
+(put 'vlfi-start-pos 'permanent-local t)
+(put 'vlfi-end-pos 'permanent-local t)
+(put 'vlfi-file-size 'permanent-local t)
(define-derived-mode vlfi-mode special-mode "VLFI"
"Mode to browse large files in."
(setq buffer-read-only t)
(set-buffer-modified-p nil)
(buffer-disable-undo)
- (make-local-variable 'write-file-functions)
- (add-hook 'write-file-functions 'vlfi-write)
+ (add-hook 'write-file-functions 'vlfi-write nil t)
(make-local-variable 'revert-buffer-function)
(setq revert-buffer-function 'vlfi-revert)
(make-local-variable 'vlfi-batch-size)
- (put 'vlfi-batch-size 'permanent-local t)
(make-local-variable 'vlfi-start-pos)
- (put 'vlfi-start-pos 'permanent-local t)
(make-local-variable 'vlfi-end-pos)
- (put 'vlfi-end-pos 'permanent-local t)
- (make-local-variable 'vlfi-file-size)
- (put 'vlfi-file-size 'permanent-local t))
+ (make-local-variable 'vlfi-file-size))
;;;###autoload
(defun vlfi (file)
@@ -117,9 +116,12 @@ buffer. You can customize number of bytes displayed by
customizing
'(define-key dired-mode-map "V" 'dired-vlfi))
;;;###autoload
-(defun vlfi-if-file-too-large (size op-type &optional filename)
+(defadvice abort-if-file-too-large (around vlfi-if-file-too-large
+ (size op-type
+ &optional filename)
+ compile activate)
"If file SIZE larger than `large-file-warning-threshold', \
-allow user to view file with `vlfi', open it normally or abort.
+allow user to view file with `vlfi', open it normally, or abort.
OP-TYPE specifies the file operation being performed over FILENAME."
(and large-file-warning-threshold size
(> size large-file-warning-threshold)
@@ -144,15 +146,12 @@ OP-TYPE specifies the file operation being performed over
FILENAME."
((memq char '(?a ?A))
(error "Aborted"))))))
-;; hijack `abort-if-file-too-large'
-;;;###autoload
-(fset 'abort-if-file-too-large 'vlfi-if-file-too-large)
;; scroll auto batching
(defadvice scroll-up (around vlfi-scroll-up
activate compile)
"Slide to next batch if at end of buffer in `vlfi-mode'."
- (if (and (eq major-mode 'vlfi-mode)
+ (if (and (derived-mode-p 'vlfi-mode)
(eobp))
(progn (vlfi-next-batch 1)
(goto-char (point-min)))
@@ -161,7 +160,7 @@ OP-TYPE specifies the file operation being performed over
FILENAME."
(defadvice scroll-down (around vlfi-scroll-down
activate compile)
"Slide to previous batch if at beginning of buffer in `vlfi-mode'."
- (if (and (eq major-mode 'vlfi-mode)
+ (if (and (derived-mode-p 'vlfi-mode)
(bobp))
(progn (vlfi-prev-batch 1)
(goto-char (point-max)))
@@ -181,8 +180,6 @@ OP-TYPE specifies the file operation being performed over
FILENAME."
Normally, the value is doubled;
with the prefix argument DECREASE it is halved."
(interactive "P")
- (or (assq 'vlfi-batch-size (buffer-local-variables))
- (error "%s is not local in this buffer" 'vlfi-batch-size))
(setq vlfi-batch-size (if decrease
(/ vlfi-batch-size 2)
(* vlfi-batch-size 2)))
@@ -298,8 +295,8 @@ When prefix argument is negative
(if do-prepend
vlfi-start-pos
vlfi-end-pos))
- (setq vlfi-start-pos start)
- (setq pos (+ pos (vlfi-adjust-chunk)))
+ (setq vlfi-start-pos start
+ pos (+ pos (vlfi-adjust-chunk)))
(goto-char (or (byte-to-position (- (position-bytes (point-max))
pos))
(point-max))))
- [elpa] externals/vlf a5fec57 090/310: Mostly documentation and commentary added., (continued)
- [elpa] externals/vlf a5fec57 090/310: Mostly documentation and commentary added., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf fbc3a37 094/310: Add tip for ability to change major mode and more section hierarchy., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf fd9c258 096/310: Use permanent buffer local write hook and update README., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf fbe0814 097/310: Fix occur indexing not to skip last chunk., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 28255a2 098/310: Correctly print MB (for older emacsen)., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf ca13bea 101/310: Try utf-8 and if not successful, auto detect when adjusting chunk for, Stefan Monnier, 2020/11/28
- [elpa] externals/vlf ae775f8 107/310: Extend vlfi-goto-line to count lines from the end with negative, Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 36d2ed4 109/310: Update README., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 3c2fb6b 111/310: Merge branch 'master' into chunk-opt2, Stefan Monnier, 2020/11/28
- [elpa] externals/vlf a0b8d5f 115/310: Merge pull request #3 from danlamanna/master, Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 8ed9192 117/310: Review fixes:,
Stefan Monnier <=
- [elpa] externals/vlf 298d8f5 118/310: Keep track of current batch encoded size and allow fluctuation when, Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 563d9ca 119/310: Fix vlfi-revert to revert on user confirmation., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 34dfbd2 121/310: Use set-visited-file-name and abstract getting current file size and, Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 6a1919d 001/310: Initial commit - original state of GNU ELPA vlf.el., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 2d0709b 003/310: Improvements to the existing functionality:, Stefan Monnier, 2020/11/28
- [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