@@ -96,52 +96,28 @@ Value is a list of (last-regexp last-pos idx cnt).")
96
96
(push ov meow--match-overlays)))))
97
97
98
98
(defun meow--highlight-regexp-in-buffer (regexp )
99
- " Highlight all regexp in this buffer.
100
-
101
- There is a cache mechanism, if the REGEXP is not changed,
102
- we simply inc/dec idx and redraw the overlays. Only count for the first time."
99
+ " Highlight all regexp in this buffer."
103
100
(when (and (meow-normal-mode-p)
104
101
(region-active-p ))
105
102
(meow--remove-expand-highlights)
106
103
(let* ((cnt 0 )
107
104
(idx 0 )
108
105
(pos (region-end ))
109
- (last-regexp (car meow--search-indicator-state))
110
- (last-pos (cadr meow--search-indicator-state))
111
- (last-idx (caddr meow--search-indicator-state))
112
- (last-cnt (cadddr meow--search-indicator-state))
113
106
(hl-start (max (point-min ) (- (point ) 3000 )))
114
107
(hl-end (min (point-max ) (+ (point ) 3000 ))))
115
108
(setq meow--expand-nav-function nil )
116
109
(setq meow--visual-command this-command)
117
- (cond
118
- ((equal last-regexp regexp)
119
- (setq cnt last-cnt
120
- idx (cond ((> pos last-pos) (1+ last-idx))
121
- ((< pos last-pos) (1- last-idx))
122
- (t last-idx)))
110
+ (save-mark-and-excursion
123
111
(meow--remove-search-indicator)
124
- (save-mark-and-excursion
125
- (goto-char hl-start)
126
- (while (re-search-forward regexp hl-end t )
127
- (meow--highlight-match))
128
- (meow--show-indicator pos idx cnt)
129
- (setq meow--search-indicator-state (list regexp pos idx cnt))))
130
-
131
- ; ; For initializing search highlight, we need to count
132
- (t
133
- (save-mark-and-excursion
134
- (meow--remove-search-indicator)
135
- (let ((case-fold-search nil ))
136
- (goto-char (point-min ))
137
- (while (re-search-forward regexp (point-max ) t )
138
- (cl-incf cnt)
139
- (when (<= (match-beginning 0 ) pos (match-end 0 ))
140
- (setq idx cnt))
141
- (when (<= hl-start (point ) hl-end)
142
- (meow--highlight-match)))
143
- (meow--show-indicator pos idx cnt)
144
- (setq meow--search-indicator-state (list regexp pos idx cnt)))))))))
112
+ (let ((case-fold-search nil ))
113
+ (goto-char (point-min ))
114
+ (while (re-search-forward regexp (point-max ) t )
115
+ (cl-incf cnt)
116
+ (when (<= (match-beginning 0 ) pos (match-end 0 ))
117
+ (setq idx cnt))
118
+ (when (<= hl-start (point ) hl-end)
119
+ (meow--highlight-match)))
120
+ (meow--show-indicator pos idx cnt))))))
145
121
146
122
(defun meow--format-full-width-number (n )
147
123
(alist-get n meow-full-width-number-position-chars))
0 commit comments