changeset 16864:59ed508195a4

(occur-mode-map): Bind g to revert-buffer. (occur-mode): Locally bind revert-buffer-function. (occur-command-arguments): New variable. (occur-revert-function): New function. (occur): Set occur-command-arguments.
author Richard M. Stallman <rms@gnu.org>
date Mon, 13 Jan 1997 08:45:17 +0000
parents 591b7a95d7a5
children 0e79ed2e445b
files lisp/replace.el
diffstat 1 files changed, 17 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/replace.el	Mon Jan 13 03:33:26 1997 +0000
+++ b/lisp/replace.el	Mon Jan 13 08:45:17 1997 +0000
@@ -241,11 +241,14 @@
   (setq occur-mode-map (make-sparse-keymap))
   (define-key occur-mode-map [mouse-2] 'occur-mode-mouse-goto)
   (define-key occur-mode-map "\C-c\C-c" 'occur-mode-goto-occurrence)
-  (define-key occur-mode-map "\C-m" 'occur-mode-goto-occurrence))
+  (define-key occur-mode-map "\C-m" 'occur-mode-goto-occurrence)
+  (define-key occur-mode-map "g" 'revert-buffer))
 
 (defvar occur-buffer nil)
 (defvar occur-nlines nil)
 (defvar occur-pos-list nil)
+(defvar occur-command-arguments nil
+  "Arguments that were given to `occur' when it made this buffer.")
 
 (defun occur-mode ()
   "Major mode for output from \\[occur].
@@ -258,11 +261,21 @@
   (use-local-map occur-mode-map)
   (setq major-mode 'occur-mode)
   (setq mode-name "Occur")
+  (make-local-variable 'revert-buffer-function)
+  (setq revert-buffer-function 'occur-revert-function)
   (make-local-variable 'occur-buffer)
   (make-local-variable 'occur-nlines)
   (make-local-variable 'occur-pos-list)
+  (make-local-variable 'occur-command-arguments)
   (run-hooks 'occur-mode-hook))
 
+;; Handle revert-buffer for *Occur* buffers.
+(defun occur-revert-function (ignore1 ignore2)
+  (let ((args occur-command-arguments ))
+    (save-excursion
+      (set-buffer occur-buffer)
+      (apply 'occur args))))
+
 (defun occur-mode-mouse-goto (event)
   "In Occur mode, go to the occurrence whose line you click on."
   (interactive "e")
@@ -380,7 +393,9 @@
 	    (occur-mode)
 	    (setq occur-buffer buffer)
 	    (setq occur-nlines nlines)
-	    (setq occur-pos-list ()))
+	    (setq occur-pos-list ())
+	    (setq occur-command-arguments
+		  (list regexp nlines)))
 	  (if (eq buffer standard-output)
 	      (goto-char (point-max)))
 	  (save-excursion