aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuanma Barranquero <[email protected]>2002-09-24 08:35:43 +0000
committerJuanma Barranquero <[email protected]>2002-09-24 08:35:43 +0000
commit123d55481b2a42dde751c2d3b74d05e001ef602b (patch)
tree09fdf5421c136801d5e38a752229f6e6eb8cade6
parentd5ec6a2da4b2138be6bf183b797eed40291dc89e (diff)
(occur-find-match): New function.
(occur-next, occur-prev): Use it.
-rw-r--r--lisp/ChangeLog5
-rw-r--r--lisp/replace.el34
2 files changed, 18 insertions, 21 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 9f58dcccdd..6595454120 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
+2002-09-24 Juanma Barranquero <[email protected]>
+
+ * replace.el (occur-find-match): New function.
+ (occur-next, occur-prev): Use it.
+
2002-09-23 Kenichi Handa <[email protected]>
* international/quail.el (quail-completion): Be sure to scroll
diff --git a/lisp/replace.el b/lisp/replace.el
index f24a5fde9d..c2c39cbd21 100644
--- a/lisp/replace.el
+++ b/lisp/replace.el
@@ -544,36 +544,28 @@ Alternatively, click \\[occur-mode-mouse-goto] on an item to go to it.
(select-window window)
(goto-char pos))))
-(defun occur-next (&optional n)
- "Move to the Nth (default 1) next match in an Occur mode buffer."
- (interactive "p")
+(defun occur-find-match (n search message)
(if (not n) (setq n 1))
(let ((r))
(while (> n 0)
- (if (get-text-property (point) 'occur-point)
- (forward-char 1))
- (setq r (next-single-property-change (point) 'occur-point))
+ (setq r (funcall search (point) 'occur-match))
+ (and r
+ (get-text-property r 'occur-match)
+ (setq r (funcall search r 'occur-match)))
(if r
- (goto-char r)
- (error "No more matches"))
+ (goto-char r)
+ (error message))
(setq n (1- n)))))
+(defun occur-next (&optional n)
+ "Move to the Nth (default 1) next match in an Occur mode buffer."
+ (interactive "p")
+ (occur-find-match n #'next-single-property-change "No more matches"))
+
(defun occur-prev (&optional n)
"Move to the Nth (default 1) previous match in an Occur mode buffer."
(interactive "p")
- (if (not n) (setq n 1))
- (let ((r))
- (while (> n 0)
-
- (setq r (get-text-property (point) 'occur-point))
- (if r (forward-char -1))
-
- (setq r (previous-single-property-change (point) 'occur-point))
- (if r
- (goto-char (- r 1))
- (error "No earlier matches"))
-
- (setq n (1- n)))))
+ (occur-find-match n #'previous-single-property-change "No earlier matches"))
(defcustom list-matching-lines-default-context-lines 0
"*Default number of context lines included around `list-matching-lines' matches.