mirror of
				https://github.com/m00natic/vlfi.git
				synced 2025-10-31 15:11:47 +00:00 
			
		
		
		
	Enlarge default batch size but keep is small on initial load of remote
files and on demand.
This commit is contained in:
		| @@ -27,7 +27,7 @@ | ||||
|  | ||||
| ;;; Code: | ||||
|  | ||||
| (defcustom vlf-batch-size 1024 | ||||
| (defcustom vlf-batch-size 1000000 | ||||
|   "Defines how large each batch of file data initially is (in bytes)." | ||||
|   :group 'vlf :type 'integer) | ||||
| (put 'vlf-batch-size 'permanent-local t) | ||||
|   | ||||
| @@ -34,7 +34,6 @@ | ||||
|   "If non nil, specifies that ediff is done over VLF buffers.") | ||||
| (make-variable-buffer-local 'vlf-ediff-session) | ||||
|  | ||||
| ;;;###autoload | ||||
| (defun vlf-ediff-buffers (buffer-A buffer-B) | ||||
|   "Run batch by batch ediff over VLF buffers BUFFER-A and BUFFER-B. | ||||
| Batch size is determined by the size in BUFFER-A. | ||||
| @@ -93,10 +92,10 @@ respectively of difference list, runs ediff over the adjacent chunks." | ||||
|                                       dir-B))) | ||||
|                                    (ediff-get-default-file-name f 1))) | ||||
|            (read-number "Batch size (in bytes): " vlf-batch-size)))) | ||||
|   (let ((buffer-A (vlf file-A))) | ||||
|   (let ((buffer-A (vlf file-A t))) | ||||
|     (set-buffer buffer-A) | ||||
|     (vlf-set-batch-size batch-size) | ||||
|     (let ((buffer-B (vlf file-B))) | ||||
|     (let ((buffer-B (vlf file-B t))) | ||||
|       (vlf-ediff-buffers buffer-A buffer-B)))) | ||||
|  | ||||
| (defadvice ediff-next-difference (around vlf-ediff-next-difference | ||||
|   | ||||
| @@ -29,7 +29,7 @@ | ||||
| (defgroup vlf nil "View Large Files in Emacs." | ||||
|   :prefix "vlf-" :group 'files) | ||||
|  | ||||
| (defcustom vlf-batch-size 1024 | ||||
| (defcustom vlf-batch-size 1000000 | ||||
|   "Defines how large each batch of file data initially is (in bytes)." | ||||
|   :group 'vlf :type 'integer) | ||||
|  | ||||
|   | ||||
| @@ -123,7 +123,7 @@ EVENT may hold details of the invocation." | ||||
|               (match-pos (+ (get-text-property pos 'line-pos) | ||||
|                             pos-relative))) | ||||
|           (cond (current-prefix-arg | ||||
|                  (setq vlf-buffer (vlf file)) | ||||
|                  (setq vlf-buffer (vlf file t)) | ||||
|                  (or not-hexl (hexl-mode)) | ||||
|                  (switch-to-buffer occur-buffer)) | ||||
|                 ((not (buffer-live-p vlf-buffer)) | ||||
| @@ -136,7 +136,7 @@ EVENT may hold details of the invocation." | ||||
|                                       not-hexl) | ||||
|                                   (setq vlf-buffer buf) | ||||
|                                   (throw 'found t)))) | ||||
|                    (setq vlf-buffer (vlf file)) | ||||
|                    (setq vlf-buffer (vlf file t)) | ||||
|                    (or not-hexl (hexl-mode))) | ||||
|                  (switch-to-buffer occur-buffer) | ||||
|                  (setq vlf-occur-vlf-buffer vlf-buffer))) | ||||
|   | ||||
							
								
								
									
										15
									
								
								vlf.el
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								vlf.el
									
									
									
									
									
								
							| @@ -145,17 +145,22 @@ values are: `write', `ediff', `occur', `search', `goto-line'." | ||||
|   (setq vlf-mode t)) | ||||
|  | ||||
| ;;;###autoload | ||||
| (defun vlf (file) | ||||
|   "View Large FILE in batches. | ||||
| (defun vlf (file &optional minimal) | ||||
|   "View Large FILE in batches.  When MINIMAL load just a few bytes. | ||||
| You can customize number of bytes displayed by customizing | ||||
| `vlf-batch-size'. | ||||
| Return newly created buffer." | ||||
|   (interactive "fFile to open: ") | ||||
|   (interactive (list (read-file-name "File to open: ") nil)) | ||||
|   (let ((vlf-buffer (generate-new-buffer "*vlf*"))) | ||||
|     (set-buffer vlf-buffer) | ||||
|     (set-visited-file-name file) | ||||
|     (set-buffer-modified-p nil) | ||||
|     (if (or minimal (file-remote-p file)) | ||||
|         (set (make-local-variable 'vlf-batch-size) 1024)) | ||||
|     (vlf-mode 1) | ||||
|     (when minimal                 ;restore batch size to default value | ||||
|       (kill-local-variable 'vlf-batch-size) | ||||
|       (make-local-variable 'vlf-batch-size)) | ||||
|     (switch-to-buffer vlf-buffer) | ||||
|     vlf-buffer)) | ||||
|  | ||||
| @@ -263,8 +268,8 @@ with the prefix argument DECREASE it is halved." | ||||
|   (vlf-verify-size) | ||||
|   (vlf-move-to-batch vlf-file-size)) | ||||
|  | ||||
| (defun vlf-revert (&optional _ignore-auto noconfirm) | ||||
|   "Revert current chunk.  Ignore _IGNORE-AUTO. | ||||
| (defun vlf-revert (&optional _auto noconfirm) | ||||
|   "Revert current chunk.  Ignore _AUTO. | ||||
| Ask for confirmation if NOCONFIRM is nil." | ||||
|   (interactive) | ||||
|   (when (or noconfirm | ||||
|   | ||||
		Reference in New Issue
	
	Block a user