diff options
| author | Eli Zaretskii | 1997-02-20 16:11:48 +0000 |
|---|---|---|
| committer | Eli Zaretskii | 1997-02-20 16:11:48 +0000 |
| commit | acffd065e3d99c26172070b4b745d55a7e828c72 (patch) | |
| tree | 08f5a5fa705b68b63a7dbd825ddf24cdf63a5a61 /lisp | |
| parent | 5679531d6c48cec2cfb8fe5317fe0ebea2841662 (diff) | |
| download | emacs-acffd065e3d99c26172070b4b745d55a7e828c72.tar.gz emacs-acffd065e3d99c26172070b4b745d55a7e828c72.zip | |
(grep-process-setup): New function, sets up the
exit message function in a way that works when async processes
aren't supported.
(grep): Use `grep-process-setup'.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/progmodes/compile.el | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el index 77608903b22..ab93cd447ec 100644 --- a/lisp/progmodes/compile.el +++ b/lisp/progmodes/compile.el | |||
| @@ -355,6 +355,19 @@ to a function that generates a unique name." | |||
| 355 | ;; The system null device. (Should reference NULL_DEVICE from C.) | 355 | ;; The system null device. (Should reference NULL_DEVICE from C.) |
| 356 | (defvar grep-null-device "/dev/null" "The system null device.") | 356 | (defvar grep-null-device "/dev/null" "The system null device.") |
| 357 | 357 | ||
| 358 | (defun grep-process-setup () | ||
| 359 | "Set up `compilation-exit-message-function' for `grep'." | ||
| 360 | (set (make-local-variable 'compilation-exit-message-function) | ||
| 361 | (lambda (status code msg) | ||
| 362 | (if (eq status 'exit) | ||
| 363 | (cond ((zerop code) | ||
| 364 | '("finished (matches found)\n" . "matched")) | ||
| 365 | ((= code 1) | ||
| 366 | '("finished with no matches found\n" . "no match")) | ||
| 367 | (t | ||
| 368 | (cons msg code))) | ||
| 369 | (cons msg code))))) | ||
| 370 | |||
| 358 | ;;;###autoload | 371 | ;;;###autoload |
| 359 | (defun grep (command-args) | 372 | (defun grep (command-args) |
| 360 | "Run grep, with user-specified args, and collect output in a buffer. | 373 | "Run grep, with user-specified args, and collect output in a buffer. |
| @@ -366,22 +379,13 @@ easily repeat a grep command." | |||
| 366 | (interactive | 379 | (interactive |
| 367 | (list (read-from-minibuffer "Run grep (like this): " | 380 | (list (read-from-minibuffer "Run grep (like this): " |
| 368 | grep-command nil nil 'grep-history))) | 381 | grep-command nil nil 'grep-history))) |
| 369 | (let ((buf (compile-internal (concat command-args " " grep-null-device) | 382 | ;; Setting process-setup-function makes exit-message-function work |
| 370 | "No more grep hits" "grep" | 383 | ;; even when async processes aren't supported. |
| 371 | ;; Give it a simpler regexp to match. | 384 | (let* ((compilation-process-setup-function 'grep-process-setup) |
| 372 | nil grep-regexp-alist))) | 385 | (buf (compile-internal (concat command-args " " grep-null-device) |
| 373 | (save-excursion | 386 | "No more grep hits" "grep" |
| 374 | (set-buffer buf) | 387 | ;; Give it a simpler regexp to match. |
| 375 | (set (make-local-variable 'compilation-exit-message-function) | 388 | nil grep-regexp-alist))))) |
| 376 | (lambda (status code msg) | ||
| 377 | (if (eq status 'exit) | ||
| 378 | (cond ((zerop code) | ||
| 379 | '("finished (matches found)\n" . "matched")) | ||
| 380 | ((= code 1) | ||
| 381 | '("finished with no matches found\n" . "no match")) | ||
| 382 | (t | ||
| 383 | (cons msg code))) | ||
| 384 | (cons msg code))))))) | ||
| 385 | 389 | ||
| 386 | (defun compile-internal (command error-message | 390 | (defun compile-internal (command error-message |
| 387 | &optional name-of-mode parser regexp-alist | 391 | &optional name-of-mode parser regexp-alist |