[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
feature/native-comp 868d3ff 2/2: * Report warnings and errors from nativ
From: |
Andrea Corallo |
Subject: |
feature/native-comp 868d3ff 2/2: * Report warnings and errors from native asynchronous compilation (bug#44168) |
Date: |
Sun, 25 Oct 2020 11:20:52 -0400 (EDT) |
branch: feature/native-comp
commit 868d3ff9b87ce85014870c9688b899e640866b48
Author: Andrea Corallo <akrl@sdf.org>
Commit: Andrea Corallo <akrl@sdf.org>
* Report warnings and errors from native asynchronous compilation
(bug#44168)
* lisp/emacs-lisp/comp.el (comp-last-scanned-async-output): New
buffer local variable.
(comp-accept-and-process-async-output): New function.
(comp-run-async-workers): Use
`comp-accept-and-process-async-output'.
---
lisp/emacs-lisp/comp.el | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el
index a13b974..1808e72 100644
--- a/lisp/emacs-lisp/comp.el
+++ b/lisp/emacs-lisp/comp.el
@@ -128,6 +128,11 @@ before compilation. Usable to modify the compiler
environment."
:type 'list
:group 'comp)
+(defcustom comp-async-report-warnings-errors t
+ "Report warnings and errors from native asynchronous compilation."
+ :type 'boolean
+ :group 'comp)
+
(defcustom comp-native-driver-options nil
"Options passed verbatim to the native compiler's backend driver.
Note that not all options are meaningful; typically only the options
@@ -2768,6 +2773,21 @@ processes from `comp-async-compilations'"
2))))
comp-async-jobs-number))
+(defvar comp-last-scanned-async-output nil)
+(make-variable-buffer-local 'comp-last-scanned-async-output)
+(defun comp-accept-and-process-async-output (process)
+ "Accept PROCESS output and check for diagnostic messages."
+ (if comp-async-report-warnings-errors
+ (with-current-buffer (process-buffer process)
+ (save-excursion
+ (accept-process-output process)
+ (goto-char (or comp-last-scanned-async-output (point-min)))
+ (while (re-search-forward "^.*+?\\(?:Error\\|Warning\\): .*$"
+ nil t)
+ (display-warning 'comp (match-string 0)))
+ (setq comp-last-scanned-async-output (point-max))))
+ (accept-process-output process)))
+
(defun comp-run-async-workers ()
"Start compiling files from `comp-files-queue' asynchronously.
When compilation is finished, run `comp-async-all-done-hook' and
@@ -2822,7 +2842,7 @@ display a message."
(run-hook-with-args
'comp-async-cu-done-hook
source-file)
- (accept-process-output process)
+ (comp-accept-and-process-async-output process)
(ignore-errors (delete-file temp-file))
(when (and load1
(zerop (process-exit-status
process)))