From acffd065e3d99c26172070b4b745d55a7e828c72 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Thu, 20 Feb 1997 16:11:48 +0000 Subject: [PATCH] (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'. --- lisp/progmodes/compile.el | 36 ++++++++++++++++++++---------------- 1 file 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." ;; 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 @@ easily repeat a grep command." (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 -- 2.39.2