aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1995-10-05 22:25:38 +0000
committerRichard M. Stallman1995-10-05 22:25:38 +0000
commit4fe11426dfc69b2e71512dcf0cd5088380e50d74 (patch)
tree72c322f9939e4a815974d218aeaac971481e671e
parent84c5c82383ac5076a999e297e101a97d8194b191 (diff)
downloademacs-4fe11426dfc69b2e71512dcf0cd5088380e50d74.tar.gz
emacs-4fe11426dfc69b2e71512dcf0cd5088380e50d74.zip
(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 @@
53(defvar view-exit-position nil) 53(defvar view-exit-position nil)
54(make-variable-buffer-local 'view-exit-position) 54(make-variable-buffer-local 'view-exit-position)
55 55
56(defvar view-overlay nil
57 "Overlay used to display where a search operation found its match.")
58(make-variable-buffer-local 'view-overlay)
59
56(or (assq 'view-mode minor-mode-alist) 60(or (assq 'view-mode minor-mode-alist)
57 (setq minor-mode-alist 61 (setq minor-mode-alist
58 (cons '(view-mode " View") minor-mode-alist))) 62 (cons '(view-mode " View") minor-mode-alist)))
@@ -260,6 +264,7 @@ If you viewed an existing buffer, that buffer returns to its previous mode.
260If you viewed a file that was not present in Emacs, its buffer is killed." 264If you viewed a file that was not present in Emacs, its buffer is killed."
261 (interactive) 265 (interactive)
262 (setq view-mode nil) 266 (setq view-mode nil)
267 (delete-overlay view-overlay)
263 (force-mode-line-update) 268 (force-mode-line-update)
264 (cond (view-mode-auto-exit 269 (cond (view-mode-auto-exit
265 (setq buffer-read-only view-old-buffer-read-only) 270 (setq buffer-read-only view-old-buffer-read-only)
@@ -371,17 +376,16 @@ Arg is number of lines to scroll."
371Displays line found at center of window. REGEXP is remembered for 376Displays line found at center of window. REGEXP is remembered for
372searching with \\[View-search-last-regexp-forward] and \\[View-search-last-regexp-backward]. Sets mark at starting position and pushes mark ring." 377searching with \\[View-search-last-regexp-forward] and \\[View-search-last-regexp-backward]. Sets mark at starting position and pushes mark ring."
373 (interactive "p\nsSearch forward (regexp): ") 378 (interactive "p\nsSearch forward (regexp): ")
374 (if (> (length regexp) 0) 379;;;(view-last-command 'View-search-last-regexp-forward n)
375 (progn 380 (view-search n (if (equal regexp "") view-last-regexp regexp))))
376 ;(view-last-command 'View-search-last-regexp-forward n)
377 (view-search n regexp))))
378 381
379(defun View-search-regexp-backward (n regexp) 382(defun View-search-regexp-backward (n regexp)
380 "Search backward from window start for Nth instance of REGEXP. 383 "Search backward from window start for Nth instance of REGEXP.
381Displays line found at center of window. REGEXP is remembered for 384Displays line found at center of window. REGEXP is remembered for
382searching with \\[View-search-last-regexp-forward] and \\[View-search-last-regexp-backward]. Sets mark at starting position and pushes mark ring." 385searching with \\[View-search-last-regexp-forward] and \\[View-search-last-regexp-backward]. Sets mark at starting position and pushes mark ring."
383 (interactive "p\nsSearch backward (regexp): ") 386 (interactive "p\nsSearch backward (regexp): ")
384 (View-search-regexp-forward (- n) regexp)) 387 (View-search-regexp-forward (- n)
388 (if (equal regexp "") view-last-regexp regexp)))
385 389
386(defun View-search-last-regexp-forward (n) 390(defun View-search-last-regexp-forward (n)
387 "Search forward from window end for Nth instance of last regexp. 391 "Search forward from window end for Nth instance of last regexp.
@@ -417,6 +421,11 @@ invocations return to earlier marks."
417 (progn 421 (progn
418 (push-mark) 422 (push-mark)
419 (goto-char where) 423 (goto-char where)
424 (if view-overlay
425 (move-overlay view-overlay (match-beginning 0) (match-end 0))
426 (setq view-overlay
427 (make-overlay (match-beginning 0) (match-end 0))))
428 (overlay-put view-overlay 'face 'highlight)
420 (beginning-of-line) 429 (beginning-of-line)
421 (recenter (/ (view-window-size) 2))) 430 (recenter (/ (view-window-size) 2)))
422 (message "Can't find occurrence %d of %s" times regexp) 431 (message "Can't find occurrence %d of %s" times regexp)