mirror of
				https://github.com/m00natic/vlfi.git
				synced 2025-10-30 22:53:37 +00:00 
			
		
		
		
	Add command to unconditionally open fresh VLF buffer to visit occur
match.
This commit is contained in:
		
							
								
								
									
										26
									
								
								vlf.el
									
									
									
									
									
								
							
							
						
						
									
										26
									
								
								vlf.el
									
									
									
									
									
								
							| @@ -645,6 +645,7 @@ Search is performed chunk by chunk in `vlf-batch-size' memory." | |||||||
|     (define-key map "n" 'vlf-occur-next-match) |     (define-key map "n" 'vlf-occur-next-match) | ||||||
|     (define-key map "p" 'vlf-occur-prev-match) |     (define-key map "p" 'vlf-occur-prev-match) | ||||||
|     (define-key map "\C-m" 'vlf-occur-visit) |     (define-key map "\C-m" 'vlf-occur-visit) | ||||||
|  |     (define-key map "\M-\r" 'vlf-occur-visit-new-buffer) | ||||||
|     (define-key map [mouse-1] 'vlf-occur-visit) |     (define-key map [mouse-1] 'vlf-occur-visit) | ||||||
|     (define-key map "o" 'vlf-occur-show) |     (define-key map "o" 'vlf-occur-show) | ||||||
|     map) |     map) | ||||||
| @@ -684,10 +685,16 @@ EVENT may hold details of the invocation." | |||||||
|     (vlf-occur-visit event) |     (vlf-occur-visit event) | ||||||
|     (pop-to-buffer occur-buffer))) |     (pop-to-buffer occur-buffer))) | ||||||
|  |  | ||||||
|  | (defun vlf-occur-visit-new-buffer () | ||||||
|  |   "Visit `vlf-occur' link in new vlf buffer." | ||||||
|  |   (interactive) | ||||||
|  |   (let ((current-prefix-arg t)) | ||||||
|  |     (vlf-occur-visit))) | ||||||
|  |  | ||||||
| (defun vlf-occur-visit (&optional event) | (defun vlf-occur-visit (&optional event) | ||||||
|   "Visit current `vlf-occur' link in a vlf buffer. |   "Visit current `vlf-occur' link in a vlf buffer. | ||||||
| If original VLF buffer has been killed, | With prefix argument or if original VLF buffer has been killed, | ||||||
| open new VLF session each time. | open new VLF session. | ||||||
| EVENT may hold details of the invocation." | EVENT may hold details of the invocation." | ||||||
|   (interactive (list last-nonmenu-event)) |   (interactive (list last-nonmenu-event)) | ||||||
|   (when event |   (when event | ||||||
| @@ -699,20 +706,23 @@ EVENT may hold details of the invocation." | |||||||
|     (if file |     (if file | ||||||
|         (let ((chunk-start (get-char-property pos 'chunk-start)) |         (let ((chunk-start (get-char-property pos 'chunk-start)) | ||||||
|               (chunk-end (get-char-property pos 'chunk-end)) |               (chunk-end (get-char-property pos 'chunk-end)) | ||||||
|               (buffer (get-char-property pos 'buffer)) |               (vlf-buffer (get-char-property pos 'buffer)) | ||||||
|  |               (occur-buffer (current-buffer)) | ||||||
|               (match-pos (+ (get-char-property pos 'line-pos) |               (match-pos (+ (get-char-property pos 'line-pos) | ||||||
|                             pos-relative))) |                             pos-relative))) | ||||||
|           (or (buffer-live-p buffer) |           (cond (current-prefix-arg | ||||||
|               (let ((occur-buffer (current-buffer))) |                  (setq vlf-buffer (vlf file)) | ||||||
|  |                  (switch-to-buffer occur-buffer)) | ||||||
|  |                 ((not (buffer-live-p vlf-buffer)) | ||||||
|                  (or (catch 'found |                  (or (catch 'found | ||||||
|                        (dolist (buf (buffer-list)) |                        (dolist (buf (buffer-list)) | ||||||
|                          (set-buffer buf) |                          (set-buffer buf) | ||||||
|                          (and vlf-mode (equal file buffer-file-name) |                          (and vlf-mode (equal file buffer-file-name) | ||||||
|                              (setq buffer buf) |                               (setq vlf-buffer buf) | ||||||
|                               (throw 'found t)))) |                               (throw 'found t)))) | ||||||
|                     (setq buffer (vlf file))) |                      (setq vlf-buffer (vlf file))) | ||||||
|                  (switch-to-buffer occur-buffer))) |                  (switch-to-buffer occur-buffer))) | ||||||
|           (pop-to-buffer buffer) |           (pop-to-buffer vlf-buffer) | ||||||
|           (vlf-move-to-chunk chunk-start chunk-end) |           (vlf-move-to-chunk chunk-start chunk-end) | ||||||
|           (goto-char match-pos))))) |           (goto-char match-pos))))) | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user