diff options
| author | Richard M. Stallman | 1997-01-13 08:45:17 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1997-01-13 08:45:17 +0000 |
| commit | a41284da64e27af4becf2c03069428af8c6c721e (patch) | |
| tree | 917b835c45a3ccca2a10e20eece6e8db6c15c4f5 | |
| parent | de712da3be4b586a962c50b78decfa1fa279478b (diff) | |
| download | emacs-a41284da64e27af4becf2c03069428af8c6c721e.tar.gz emacs-a41284da64e27af4becf2c03069428af8c6c721e.zip | |
(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.
| -rw-r--r-- | lisp/replace.el | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/lisp/replace.el b/lisp/replace.el index 95b791aec39..086fea67455 100644 --- a/lisp/replace.el +++ b/lisp/replace.el | |||
| @@ -241,11 +241,14 @@ Applies to lines after point." | |||
| 241 | (setq occur-mode-map (make-sparse-keymap)) | 241 | (setq occur-mode-map (make-sparse-keymap)) |
| 242 | (define-key occur-mode-map [mouse-2] 'occur-mode-mouse-goto) | 242 | (define-key occur-mode-map [mouse-2] 'occur-mode-mouse-goto) |
| 243 | (define-key occur-mode-map "\C-c\C-c" 'occur-mode-goto-occurrence) | 243 | (define-key occur-mode-map "\C-c\C-c" 'occur-mode-goto-occurrence) |
| 244 | (define-key occur-mode-map "\C-m" 'occur-mode-goto-occurrence)) | 244 | (define-key occur-mode-map "\C-m" 'occur-mode-goto-occurrence) |
| 245 | (define-key occur-mode-map "g" 'revert-buffer)) | ||
| 245 | 246 | ||
| 246 | (defvar occur-buffer nil) | 247 | (defvar occur-buffer nil) |
| 247 | (defvar occur-nlines nil) | 248 | (defvar occur-nlines nil) |
| 248 | (defvar occur-pos-list nil) | 249 | (defvar occur-pos-list nil) |
| 250 | (defvar occur-command-arguments nil | ||
| 251 | "Arguments that were given to `occur' when it made this buffer.") | ||
| 249 | 252 | ||
| 250 | (defun occur-mode () | 253 | (defun occur-mode () |
| 251 | "Major mode for output from \\[occur]. | 254 | "Major mode for output from \\[occur]. |
| @@ -258,11 +261,21 @@ Alternatively, click \\[occur-mode-mouse-goto] on an item to go to it. | |||
| 258 | (use-local-map occur-mode-map) | 261 | (use-local-map occur-mode-map) |
| 259 | (setq major-mode 'occur-mode) | 262 | (setq major-mode 'occur-mode) |
| 260 | (setq mode-name "Occur") | 263 | (setq mode-name "Occur") |
| 264 | (make-local-variable 'revert-buffer-function) | ||
| 265 | (setq revert-buffer-function 'occur-revert-function) | ||
| 261 | (make-local-variable 'occur-buffer) | 266 | (make-local-variable 'occur-buffer) |
| 262 | (make-local-variable 'occur-nlines) | 267 | (make-local-variable 'occur-nlines) |
| 263 | (make-local-variable 'occur-pos-list) | 268 | (make-local-variable 'occur-pos-list) |
| 269 | (make-local-variable 'occur-command-arguments) | ||
| 264 | (run-hooks 'occur-mode-hook)) | 270 | (run-hooks 'occur-mode-hook)) |
| 265 | 271 | ||
| 272 | ;; Handle revert-buffer for *Occur* buffers. | ||
| 273 | (defun occur-revert-function (ignore1 ignore2) | ||
| 274 | (let ((args occur-command-arguments )) | ||
| 275 | (save-excursion | ||
| 276 | (set-buffer occur-buffer) | ||
| 277 | (apply 'occur args)))) | ||
| 278 | |||
| 266 | (defun occur-mode-mouse-goto (event) | 279 | (defun occur-mode-mouse-goto (event) |
| 267 | "In Occur mode, go to the occurrence whose line you click on." | 280 | "In Occur mode, go to the occurrence whose line you click on." |
| 268 | (interactive "e") | 281 | (interactive "e") |
| @@ -380,7 +393,9 @@ It serves as a menu to find any of the occurrences in this buffer. | |||
| 380 | (occur-mode) | 393 | (occur-mode) |
| 381 | (setq occur-buffer buffer) | 394 | (setq occur-buffer buffer) |
| 382 | (setq occur-nlines nlines) | 395 | (setq occur-nlines nlines) |
| 383 | (setq occur-pos-list ())) | 396 | (setq occur-pos-list ()) |
| 397 | (setq occur-command-arguments | ||
| 398 | (list regexp nlines))) | ||
| 384 | (if (eq buffer standard-output) | 399 | (if (eq buffer standard-output) |
| 385 | (goto-char (point-max))) | 400 | (goto-char (point-max))) |
| 386 | (save-excursion | 401 | (save-excursion |