[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/vlf 681d3d9 084/310: Add vlfi-occur-mode.
From: |
Stefan Monnier |
Subject: |
[elpa] externals/vlf 681d3d9 084/310: Add vlfi-occur-mode. |
Date: |
Sat, 28 Nov 2020 00:32:52 -0500 (EST) |
branch: externals/vlf
commit 681d3d94fcd2bcb0c6c5d074425147413e53ceac
Author: Andrey Kotlarski <m00naticus@gmail.com>
Commit: Andrey Kotlarski <m00naticus@gmail.com>
Add vlfi-occur-mode.
---
vlfi.el | 46 +++++++++++++++++++++++++++++++++++++---------
1 file changed, 37 insertions(+), 9 deletions(-)
diff --git a/vlfi.el b/vlfi.el
index 67c5c68..4fa0b4b 100644
--- a/vlfi.el
+++ b/vlfi.el
@@ -476,7 +476,7 @@ successful. Return nil if nothing found."
(- match-pos-start
vlfi-start-pos))
match-end)))
- (overlay-put overlay 'face 'region)
+ (overlay-put overlay 'face 'match)
(unless success
(goto-char match-end)
(message "Moved to the %d match which is last"
@@ -522,6 +522,34 @@ Search is performed chunk by chunk in `vlfi-batch-size'
memory."
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; occur
+(defvar vlfi-occur-mode-map
+ (let ((map (make-sparse-keymap)))
+ (define-key map "n" 'vlfi-occur-next-match)
+ (define-key map "p" 'vlfi-occur-prev-match)
+ map)
+ "Keymap for command `vlfi-occur-mode'.")
+
+(define-derived-mode vlfi-occur-mode special-mode "VLFI[occur]"
+ "Major mode for showing occur matches of VLFI opened files.")
+
+(defun vlfi-occur-next-match ()
+ "Move cursor to next match."
+ (interactive)
+ (if (eq (get-char-property (point) 'face) 'match)
+ (goto-char (next-single-property-change (point) 'face)))
+ (goto-char (or (text-property-any (point) (point-max) 'face 'match)
+ (text-property-any (point-min) (point)
+ 'face 'match))))
+
+(defun vlfi-occur-prev-match ()
+ "Move cursor to previous match."
+ (interactive)
+ (if (eq (get-char-property (point) 'face) 'match)
+ (goto-char (previous-single-property-change (point) 'face)))
+ (while (not (eq (get-char-property (point) 'face) 'match))
+ (goto-char (or (previous-single-property-change (point) 'face)
+ (point-max)))))
+
(defun vlfi-occur (regexp)
"Make occur style index for REGEXP."
(interactive (list (read-regexp "List lines matching regexp"
@@ -530,12 +558,11 @@ Search is performed chunk by chunk in `vlfi-batch-size'
memory."
(let ((start-pos vlfi-start-pos)
(end-pos vlfi-end-pos)
(pos (point)))
- (unwind-protect
- (progn (vlfi-beginning-of-file)
- (goto-char (point-min))
- (vlfi-build-occur regexp))
- (vlfi-move-to-chunk start-pos end-pos)
- (goto-char pos))))
+ (vlfi-beginning-of-file)
+ (goto-char (point-min))
+ (vlfi-build-occur regexp)
+ (vlfi-move-to-chunk start-pos end-pos)
+ (goto-char pos)))
(defun vlfi-build-occur (regexp)
"Build occur style index for REGEXP."
@@ -586,7 +613,7 @@ Search is performed chunk by chunk in `vlfi-batch-size'
memory."
(- last-line-pos))
(+ line-start (match-end 10)
(- last-line-pos))
- (list 'face 'region)))
+ (list 'face 'match)))
(forward-line)
(setq last-line-result line)))))
(let ((batch-move (- vlfi-end-pos batch-step)))
@@ -606,7 +633,8 @@ Search is performed chunk by chunk in `vlfi-batch-size'
memory."
(insert (propertize
(format "%d matches for \"%s\" in file \
\(from %d lines\): %s\n" match-count regexp line file)
- 'face 'underline))))
+ 'face 'underline)))
+ (vlfi-occur-mode))
(display-buffer occur-buffer))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- [elpa] externals/vlf 82fd5b9 203/310: Refine diff adjustment and in case of equality after it - make another, (continued)
- [elpa] externals/vlf 82fd5b9 203/310: Refine diff adjustment and in case of equality after it - make another, Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 0199c24 218/310: Lower tramp verbosity level when dealing with multiple batches., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf ee19f81 228/310: Load hexl advices after load and move vlf group definition., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 2c231df 226/310: Disable hexl-save-buffer and hexl revert when vlf-mode is active., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf a1ca1e3 232/310: Don't launch vlf when file size is less than vlf-batch-size., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf facdb9f 249/310: Fix binary tune base case and add approximation after access to, Stefan Monnier, 2020/11/28
- [elpa] externals/vlf d67825c 244/310: Move back to using average speed when measuring and tuning. Be more, Stefan Monnier, 2020/11/28
- [elpa] externals/vlf e3be8d5 079/310: Don't adjust chunk with more that 3 bytes and inhibit spurious update, Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 1589cf9 081/310: Make custom revert function local only for vlfi buffers., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf b34bd2e 082/310: Don't use temporary buffer when adjusting expanded file content., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 681d3d9 084/310: Add vlfi-occur-mode.,
Stefan Monnier <=
- [elpa] externals/vlf 641ff4b 085/310: First feature complete version of vlfi-occur., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 1dcd122 086/310: Use overlays for number indicators., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf f14ef6c 087/310: Usability improvements to vlfi-occur., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 54927af 088/310: Update README and bump version., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf b8cc344 091/310: Add more detailed usage details., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf eaf85e5 093/310: Add key-binding to vlfi-mode-map in vlfi-edit-mode-map., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf e4d886a 092/310: Add check if VLFI buffer has been modified before occur jumping to new, Stefan Monnier, 2020/11/28
- [elpa] externals/vlf a63ea7a 095/310: Grammar fixes., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 57eb4c2 099/310: Initial attempt at optimizing chunk access., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf d2bd47c 100/310: More attempts to optimize decoding., Stefan Monnier, 2020/11/28