branch: externals/vlf
commit e4d886a3e305bd755740542c8ada139b5db0d823
Author: Andrey Kotlarski <[email protected]>
Commit: Andrey Kotlarski <[email protected]>
Add check if VLFI buffer has been modified before occur jumping to new
chunk.
---
vlfi.el | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/vlfi.el b/vlfi.el
index 88a494f..b07111d 100644
--- a/vlfi.el
+++ b/vlfi.el
@@ -585,13 +585,21 @@ EVENT may hold details of the invocation."
(match-pos (or (get-char-property pos 'match-pos)
(+ (get-char-property pos 'line-pos)
pos-relative))))
- (unless (buffer-live-p buffer)
- (let ((occur-buffer (current-buffer)))
- (setq buffer (vlfi file))
- (switch-to-buffer occur-buffer)))
+ (or (buffer-live-p buffer)
+ (let ((occur-buffer (current-buffer)))
+ (setq buffer (vlfi file))
+ (switch-to-buffer occur-buffer)))
(pop-to-buffer buffer)
- (vlfi-move-to-chunk chunk-start chunk-end)
- (goto-char match-pos)))))
+ (if (buffer-modified-p)
+ (cond ((and (= vlfi-start-pos chunk-start)
+ (= vlfi-end-pos chunk-end))
+ (goto-char match-pos))
+ ((y-or-n-p "VLFI buffer has been modified. \
+Really jump to new chunk? ")
+ (vlfi-move-to-chunk chunk-start chunk-end)
+ (goto-char match-pos)))
+ (vlfi-move-to-chunk chunk-start chunk-end)
+ (goto-char match-pos))))))
(defun vlfi-occur (regexp)
"Make whole file occur style index for REGEXP.