summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard M. Stallman <rms@gnu.org>1995-10-05 22:25:38 +0000
committerRichard M. Stallman <rms@gnu.org>1995-10-05 22:25:38 +0000
commitd8525aec13284504b5d5345acbe29079fe35af95 (patch)
tree2e5cfacf350c6c438a78626bde59c84d2c97d3c2
parent2dc67529f013717ae1d084907835358b1203fee5 (diff)
downloademacs-d8525aec13284504b5d5345acbe29079fe35af95.tar.gz
(View-search-regexp-forward, View-search-regexp-backward):
If arg is empty, use view-last-regexp. (view-overlay): New variable, local in all buffers. (view-search): Highlight the match using view-overlay. (view-exit): Delete view-overlay.
-rw-r--r--lisp/view.el19
1 files changed, 14 insertions, 5 deletions
diff --git a/lisp/view.el b/lisp/view.el
index 06f30a5bff6..cf1cc51f2ec 100644
--- a/lisp/view.el
+++ b/lisp/view.el
@@ -53,6 +53,10 @@
(defvar view-exit-position nil)
(make-variable-buffer-local 'view-exit-position)
+(defvar view-overlay nil
+ "Overlay used to display where a search operation found its match.")
+(make-variable-buffer-local 'view-overlay)
+
(or (assq 'view-mode minor-mode-alist)
(setq minor-mode-alist
(cons '(view-mode " View") minor-mode-alist)))
@@ -260,6 +264,7 @@ If you viewed an existing buffer, that buffer returns to its previous mode.
If you viewed a file that was not present in Emacs, its buffer is killed."
(interactive)
(setq view-mode nil)
+ (delete-overlay view-overlay)
(force-mode-line-update)
(cond (view-mode-auto-exit
(setq buffer-read-only view-old-buffer-read-only)
@@ -371,17 +376,16 @@ Arg is number of lines to scroll."
Displays line found at center of window. REGEXP is remembered for
searching with \\[View-search-last-regexp-forward] and \\[View-search-last-regexp-backward]. Sets mark at starting position and pushes mark ring."
(interactive "p\nsSearch forward (regexp): ")
- (if (> (length regexp) 0)
- (progn
- ;(view-last-command 'View-search-last-regexp-forward n)
- (view-search n regexp))))
+;;;(view-last-command 'View-search-last-regexp-forward n)
+ (view-search n (if (equal regexp "") view-last-regexp regexp))))
(defun View-search-regexp-backward (n regexp)
"Search backward from window start for Nth instance of REGEXP.
Displays line found at center of window. REGEXP is remembered for
searching with \\[View-search-last-regexp-forward] and \\[View-search-last-regexp-backward]. Sets mark at starting position and pushes mark ring."
(interactive "p\nsSearch backward (regexp): ")
- (View-search-regexp-forward (- n) regexp))
+ (View-search-regexp-forward (- n)
+ (if (equal regexp "") view-last-regexp regexp)))
(defun View-search-last-regexp-forward (n)
"Search forward from window end for Nth instance of last regexp.
@@ -417,6 +421,11 @@ invocations return to earlier marks."
(progn
(push-mark)
(goto-char where)
+ (if view-overlay
+ (move-overlay view-overlay (match-beginning 0) (match-end 0))
+ (setq view-overlay
+ (make-overlay (match-beginning 0) (match-end 0))))
+ (overlay-put view-overlay 'face 'highlight)
(beginning-of-line)
(recenter (/ (view-window-size) 2)))
(message "Can't find occurrence %d of %s" times regexp)