changeset 13122:05bae277596e

(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.
author Richard M. Stallman <rms@gnu.org>
date Thu, 05 Oct 1995 22:25:38 +0000
parents 4efe8fac6854
children e712a11f25a0
files lisp/view.el
diffstat 1 files changed, 14 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/view.el	Thu Oct 05 16:35:45 1995 +0000
+++ b/lisp/view.el	Thu Oct 05 22:25:38 1995 +0000
@@ -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 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 @@
 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 @@
 	(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)