Commit 8785daf3 authored by Eli Zaretskii's avatar Eli Zaretskii
Browse files

* (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.
parent 7ada1a07
...@@ -160,6 +160,21 @@ is nil, REGEXP matches only half a section.") ...@@ -160,6 +160,21 @@ is nil, REGEXP matches only half a section.")
(message "Parsing differences...done")) (message "Parsing differences...done"))
(setq compilation-error-list (nreverse compilation-error-list))) (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 ;;;###autoload
(defun diff (old new &optional switches) (defun diff (old new &optional switches)
"Find and display the differences between OLD and NEW files. "Find and display the differences between OLD and NEW files.
...@@ -198,7 +213,8 @@ With prefix arg, prompt for diff switches." ...@@ -198,7 +213,8 @@ With prefix arg, prompt for diff switches."
(new-alt (file-local-copy new)) (new-alt (file-local-copy new))
buf) buf)
(save-excursion (save-excursion
(let ((command (let ((compilation-process-setup-function 'diff-process-setup)
(command
(mapconcat 'identity (mapconcat 'identity
(append (list diff-command) (append (list diff-command)
;; Use explicitly specified switches ;; Use explicitly specified switches
...@@ -221,18 +237,6 @@ With prefix arg, prompt for diff switches." ...@@ -221,18 +237,6 @@ With prefix arg, prompt for diff switches."
"No more differences" "Diff" "No more differences" "Diff"
'diff-parse-differences)) 'diff-parse-differences))
(set-buffer buf) (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-old-file) old)
(set (make-local-variable 'diff-new-file) new) (set (make-local-variable 'diff-new-file) new)
(set (make-local-variable 'diff-old-temp-file) old-alt) (set (make-local-variable 'diff-old-temp-file) old-alt)
...@@ -243,6 +247,10 @@ With prefix arg, prompt for diff switches." ...@@ -243,6 +247,10 @@ With prefix arg, prompt for diff switches."
(delete-file diff-old-temp-file)) (delete-file diff-old-temp-file))
(if diff-new-temp-file (if diff-new-temp-file
(delete-file 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)))) buf))))
;;;###autoload ;;;###autoload
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment