emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] scratch/flymake-refactor dc39d65 4/7: flymake-ui.el provid


From: João Távora
Subject: [Emacs-diffs] scratch/flymake-refactor dc39d65 4/7: flymake-ui.el provides new flymake-report as a re-entry point for backends.
Date: Wed, 23 Aug 2017 19:52:58 -0400 (EDT)

branch: scratch/flymake-refactor
commit dc39d65adff932cec0a06049a0c4e7b00304d190
Author: João Távora <address@hidden>
Commit: João Távora <address@hidden>

    flymake-ui.el provides new flymake-report as a re-entry point for backends.
    
    * lisp/progmodes/flymake-proc.el (flymake-post-syntax-check):
    Simplify.  Call flymake-report.
    
    * lisp/progmodes/flymake-ui.el (flymake-report): New function.
    (flymake-backends): Tweak docstring.
---
 lisp/progmodes/flymake-proc.el | 37 ++++++++++++-------------------------
 lisp/progmodes/flymake-ui.el   | 24 +++++++++++++++++++++---
 2 files changed, 33 insertions(+), 28 deletions(-)

diff --git a/lisp/progmodes/flymake-proc.el b/lisp/progmodes/flymake-proc.el
index 56b1078..8d630dd 100644
--- a/lisp/progmodes/flymake-proc.el
+++ b/lisp/progmodes/flymake-proc.el
@@ -442,31 +442,18 @@ It's flymake process filter."
              (setq flymake-is-running nil))))))))
 
 (defun flymake-post-syntax-check (exit-status command)
-  (save-restriction
-    (widen)
-    (setq flymake-err-info flymake-new-err-info)
-    (setq flymake-new-err-info nil)
-    (setq flymake-err-info
-          (flymake-fix-line-numbers
-           flymake-err-info 1 (count-lines (point-min) (point-max))))
-    (flymake-delete-own-overlays)
-    (flymake-highlight-err-lines flymake-err-info)
-    (let (err-count warn-count)
-      (setq err-count (flymake-get-err-count flymake-err-info "e"))
-      (setq warn-count  (flymake-get-err-count flymake-err-info "w"))
-      (flymake-log 2 "%s: %d error(s), %d warning(s) in %.2f second(s)"
-                   (buffer-name) err-count warn-count
-                   (- (float-time) flymake-check-start-time))
-      (setq flymake-check-start-time nil)
-
-      (if (and (equal 0 err-count) (equal 0 warn-count))
-          (if (equal 0 exit-status)
-              (flymake-report-status "" "") ; PASSED
-            (if (not flymake-check-was-interrupted)
-                (flymake-report-fatal-status "CFGERR"
-                                             (format "Configuration error has 
occurred while running %s" command))
-              (flymake-report-status nil ""))) ; "STOPPED"
-        (flymake-report-status (format "%d/%d" err-count warn-count) "")))))
+  (let ((err-count (flymake-get-err-count flymake-new-err-info "e"))
+        (warn-count (flymake-get-err-count flymake-new-err-info "w")))
+    (if (equal 0 exit-status)
+        (flymake-report flymake-new-err-info)
+      (if flymake-check-was-interrupted
+          (flymake-report-status nil "") ;; STOPPED
+        (if (and (zerop err-count) (zerop warn-count))
+            (flymake-report-fatal-status "CFGERR"
+                                   (format "Configuration error has occurred 
while running %s" command))
+          (flymake-report flymake-new-err-info))))
+    (setq flymake-new-err-info nil)))
+
 
 (defun flymake-parse-output-and-residual (output)
   "Split OUTPUT into lines, merge in residual if necessary."
diff --git a/lisp/progmodes/flymake-ui.el b/lisp/progmodes/flymake-ui.el
index a0864b5..8c7b8a2 100644
--- a/lisp/progmodes/flymake-ui.el
+++ b/lisp/progmodes/flymake-ui.el
@@ -114,9 +114,10 @@ Value is an alist of conses (PREDICATE . CHECKER). Both 
PREDICATE
 and CHECKER are functions called without arguments and within the
 the buffer in which `flymake-mode' was enabled. PREDICATE is
 expected to (quickly) return t or nil if the buffer can be
-syntax-checked by CHECKER, in which case it can then perform
-more morose operations, possibly asynchronously."  :group
-'flymake :type 'alist)
+syntax-checked by CHECKER, in which case it can then perform more
+morose operations, possibly asynchronously. After it's done,
+CHECKER must invoke `flymake-report' to display the results of
+the syntax check." :group 'flymake :type 'alist)
 
 (defvar-local flymake-timer nil
   "Timer for starting syntax check.")
@@ -469,6 +470,23 @@ line number outside the file being compiled."
       (setq count (1- count))))
   err-info-list)
 
+(defun flymake-report (diagnostics)
+  (save-restriction
+    (widen)
+    (setq flymake-err-info
+          (flymake-fix-line-numbers
+           diagnostics 1 (count-lines (point-min) (point-max))))
+    (flymake-delete-own-overlays)
+    (flymake-highlight-err-lines flymake-err-info)
+    (let ((err-count (flymake-get-err-count flymake-err-info "e"))
+          (warn-count (flymake-get-err-count flymake-err-info "w")))
+      (flymake-log 2 "%s: %d error(s), %d warning(s) in %.2f second(s)"
+                   (buffer-name) err-count warn-count
+                   (- (float-time) flymake-check-start-time))
+      (if (and (equal 0 err-count) (equal 0 warn-count))
+          (flymake-report-status "" "")
+        (flymake-report-status (format "%d/%d" err-count warn-count) "")))))
+
 (defvar-local flymake--backend nil
   "The currently active backend selected by `flymake-mode'")
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]