# HG changeset patch # User Eli Zaretskii # Date 855503831 0 # Node ID 100ef50c2c01b21a52f896ef437d758c12d3a3bb # Parent 8c94c682773a2e49f06a0211dfbe07f59e8924f4 * (diff-process-setup): New function, sets up the compilation-exit-message-function so that it works with both asynchronous and synchronous sub-processes. (diff): Bind compilation-exit-message-function. Run compilation-finish-function when compile-internal returns if async processes aren't supported. diff -r 8c94c682773a -r 100ef50c2c01 lisp/diff.el --- a/lisp/diff.el Sat Feb 08 20:17:04 1997 +0000 +++ b/lisp/diff.el Sun Feb 09 15:57:11 1997 +0000 @@ -160,6 +160,21 @@ (message "Parsing differences...done")) (setq compilation-error-list (nreverse compilation-error-list))) +(defun diff-process-setup () + "Set up \`compilation-exit-message-function' for \`diff'." + ;; Avoid frightening people with "abnormally terminated" + ;; if diff finds differences. + (set (make-local-variable 'compilation-exit-message-function) + (lambda (status code msg) + (cond ((not (eq status 'exit)) + (cons msg code)) + ((zerop code) + '("finished (no differences)\n" . "no differences")) + ((= code 1) + '("finished\n" . "differences found")) + (t + (cons msg code)))))) + ;;;###autoload (defun diff (old new &optional switches) "Find and display the differences between OLD and NEW files. @@ -198,7 +213,8 @@ (new-alt (file-local-copy new)) buf) (save-excursion - (let ((command + (let ((compilation-process-setup-function 'diff-process-setup) + (command (mapconcat 'identity (append (list diff-command) ;; Use explicitly specified switches @@ -221,18 +237,6 @@ "No more differences" "Diff" 'diff-parse-differences)) (set-buffer buf) - ;; Avoid frightening people with "abnormally terminated" - ;; if diff finds differences. - (set (make-local-variable 'compilation-exit-message-function) - (lambda (status code msg) - (cond ((not (eq status 'exit)) - (cons msg code)) - ((zerop code) - '("finished (no differences)\n" . "no differences")) - ((= code 1) - '("finished\n" . "differences found")) - (t - (cons msg code))))) (set (make-local-variable 'diff-old-file) old) (set (make-local-variable 'diff-new-file) new) (set (make-local-variable 'diff-old-temp-file) old-alt) @@ -243,6 +247,10 @@ (delete-file diff-old-temp-file)) (if diff-new-temp-file (delete-file diff-new-temp-file))))) + ;; When async processes aren't available, the compilation finish + ;; function doesn't get chance to run. Invoke it by hand. + (or (fboundp 'start-process) + (funcall compilation-finish-function nil nil)) buf)))) ;;;###autoload