Mercurial > emacs
changeset 17054:84414e5f194d
(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'.
author | Eli Zaretskii <eliz@gnu.org> |
---|---|
date | Thu, 20 Feb 1997 16:11:48 +0000 |
parents | df904355f033 |
children | f0f8005780cc |
files | lisp/progmodes/compile.el |
diffstat | 1 files changed, 20 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/progmodes/compile.el Thu Feb 20 07:26:24 1997 +0000 +++ b/lisp/progmodes/compile.el Thu Feb 20 16:11:48 1997 +0000 @@ -355,6 +355,19 @@ ;; The system null device. (Should reference NULL_DEVICE from C.) (defvar grep-null-device "/dev/null" "The system null device.") +(defun grep-process-setup () + "Set up `compilation-exit-message-function' for `grep'." + (set (make-local-variable 'compilation-exit-message-function) + (lambda (status code msg) + (if (eq status 'exit) + (cond ((zerop code) + '("finished (matches found)\n" . "matched")) + ((= code 1) + '("finished with no matches found\n" . "no match")) + (t + (cons msg code))) + (cons msg code))))) + ;;;###autoload (defun grep (command-args) "Run grep, with user-specified args, and collect output in a buffer. @@ -366,22 +379,13 @@ (interactive (list (read-from-minibuffer "Run grep (like this): " grep-command nil nil 'grep-history))) - (let ((buf (compile-internal (concat command-args " " grep-null-device) - "No more grep hits" "grep" - ;; Give it a simpler regexp to match. - nil grep-regexp-alist))) - (save-excursion - (set-buffer buf) - (set (make-local-variable 'compilation-exit-message-function) - (lambda (status code msg) - (if (eq status 'exit) - (cond ((zerop code) - '("finished (matches found)\n" . "matched")) - ((= code 1) - '("finished with no matches found\n" . "no match")) - (t - (cons msg code))) - (cons msg code))))))) + ;; Setting process-setup-function makes exit-message-function work + ;; even when async processes aren't supported. + (let* ((compilation-process-setup-function 'grep-process-setup) + (buf (compile-internal (concat command-args " " grep-null-device) + "No more grep hits" "grep" + ;; Give it a simpler regexp to match. + nil grep-regexp-alist))))) (defun compile-internal (command error-message &optional name-of-mode parser regexp-alist