mirror of
				https://github.com/m00natic/vlfi.git
				synced 2025-10-30 22:53:37 +00:00 
			
		
		
		
	Merge branch 'master' into chunk-opt2
This commit is contained in:
		
							
								
								
									
										14
									
								
								vlfi.el
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								vlfi.el
									
									
									
									
									
								
							| @@ -200,9 +200,9 @@ with the prefix argument DECREASE it is halved." | |||||||
|   "Update the current buffer name." |   "Update the current buffer name." | ||||||
|   (rename-buffer (vlfi-format-buffer-name) t)) |   (rename-buffer (vlfi-format-buffer-name) t)) | ||||||
|  |  | ||||||
| (defmacro vlfi-get-file-size (file) | (defun vlfi-get-file-size (file) | ||||||
|   "Get size in bytes of FILE." |   "Get size in bytes of FILE." | ||||||
|   `(nth 7 (file-attributes ,file))) |   (nth 7 (file-attributes file))) | ||||||
|  |  | ||||||
| (defun vlfi-insert-file (&optional from-end) | (defun vlfi-insert-file (&optional from-end) | ||||||
|   "Insert first chunk of current file contents in current buffer. |   "Insert first chunk of current file contents in current buffer. | ||||||
| @@ -428,6 +428,7 @@ Return cons \(success-status . number-of-bytes-moved-back\)." | |||||||
| (defun vlfi-re-search (regexp count backward batch-step) | (defun vlfi-re-search (regexp count backward batch-step) | ||||||
|   "Search for REGEXP COUNT number of times forward or BACKWARD. |   "Search for REGEXP COUNT number of times forward or BACKWARD. | ||||||
| BATCH-STEP is amount of overlap between successive chunks." | BATCH-STEP is amount of overlap between successive chunks." | ||||||
|  |   (assert (< 0 count)) | ||||||
|   (let* ((match-chunk-start vlfi-start-pos) |   (let* ((match-chunk-start vlfi-start-pos) | ||||||
|          (match-chunk-end vlfi-end-pos) |          (match-chunk-end vlfi-end-pos) | ||||||
|          (match-start-pos (+ vlfi-start-pos (position-bytes (point)))) |          (match-start-pos (+ vlfi-start-pos (position-bytes (point)))) | ||||||
| @@ -561,18 +562,23 @@ Search is performed chunk by chunk in `vlfi-batch-size' memory." | |||||||
|   (vlfi-re-search regexp count t (/ vlfi-batch-size 8))) |   (vlfi-re-search regexp count t (/ vlfi-batch-size 8))) | ||||||
|  |  | ||||||
| (defun vlfi-goto-line (n) | (defun vlfi-goto-line (n) | ||||||
|   "Go to line N." |   "Go to line N.  If N is negative, count from the end of file." | ||||||
|   (interactive "nGo to line: ") |   (interactive "nGo to line: ") | ||||||
|   (let ((start-pos vlfi-start-pos) |   (let ((start-pos vlfi-start-pos) | ||||||
|         (end-pos vlfi-end-pos) |         (end-pos vlfi-end-pos) | ||||||
|         (pos (point)) |         (pos (point)) | ||||||
|         (success nil)) |         (success nil)) | ||||||
|     (unwind-protect |     (unwind-protect | ||||||
|  |         (if (< 0 n) | ||||||
|             (progn (vlfi-beginning-of-file) |             (progn (vlfi-beginning-of-file) | ||||||
|                    (goto-char (point-min)) |                    (goto-char (point-min)) | ||||||
|                    (setq success (vlfi-re-search "[\n\C-m]" (1- n) |                    (setq success (vlfi-re-search "[\n\C-m]" (1- n) | ||||||
|                                                  nil 0))) |                                                  nil 0))) | ||||||
|       (unless success |           (vlfi-end-of-file) | ||||||
|  |           (goto-char (point-max)) | ||||||
|  |           (setq success (vlfi-re-search "[\n\C-m]" (- n) t 0))) | ||||||
|  |       (if success | ||||||
|  |           (message "Onto line %s" n) | ||||||
|         (vlfi-move-to-chunk start-pos end-pos) |         (vlfi-move-to-chunk start-pos end-pos) | ||||||
|         (goto-char pos))))) |         (goto-char pos))))) | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user