[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] emacs-26 5ec7d73 19/39: Flymake's flymake-proc.el backend
From: |
João Távora |
Subject: |
[Emacs-diffs] emacs-26 5ec7d73 19/39: Flymake's flymake-proc.el backend slightly easier to debug |
Date: |
Tue, 3 Oct 2017 10:04:50 -0400 (EDT) |
branch: emacs-26
commit 5ec7d738655db209ef7375e340d3d2b0ae5fc3da
Author: João Távora <address@hidden>
Commit: João Távora <address@hidden>
Flymake's flymake-proc.el backend slightly easier to debug
Misc cleanup in flymake-proc.el
Improve description of what this file contains.
Better name for the backend function. Fix the case where it is run
interactively.
Keep the output buffer alive iff the external process panics.
* lisp/progmodes/flymake-proc.el
(flymake-proc-legacy-flymake): Rename from
flymake-proc-start-syntax-check. Allow running interactively.
(flymake-start-syntax-check): Obsolete alias for
flymake-proc-legacy-flymake.
(flymake-proc-start-syntax-check): Delete.
(flymake-diagnostic-functions): Include flymake-proc-legacy-flymake
(flymake-proc--process-sentinel): Keep output buffer alive.
Clarify with comments.
(flymake-proc--diagnostics-for-pattern)
(flymake-proc--process-sentinel)
(flymake-proc--safe-delete-directory)
(flymake-proc--start-syntax-check-process): Use condition-case-unless-debug.
---
lisp/progmodes/flymake-proc.el | 68 +++++++++++++++++++++++++++---------------
1 file changed, 44 insertions(+), 24 deletions(-)
diff --git a/lisp/progmodes/flymake-proc.el b/lisp/progmodes/flymake-proc.el
index 1028d9a..37b7e49 100644
--- a/lisp/progmodes/flymake-proc.el
+++ b/lisp/progmodes/flymake-proc.el
@@ -1,4 +1,4 @@
-;;; flymake-proc.el --- Flymake for external syntax checker processes -*-
lexical-binding: t; -*-
+;;; flymake-proc.el --- Flymake backend for external tools -*-
lexical-binding: t; -*-
;; Copyright (C) 2003-2017 Free Software Foundation, Inc.
@@ -26,9 +26,13 @@
;;
;; Flymake is a minor Emacs mode performing on-the-fly syntax checks.
;;
-;; This file contains the most original implementation of flymake's
-;; main source of on-the-fly diagnostic info, the external syntax
-;; checker backend.
+;; This file contains a significant part of the original flymake's
+;; implementation, a buffer-checking mechanism that parses the output
+;; of an external syntax check tool with regular expressions.
+;;
+;; That work has been adapted into a flymake "backend" function,
+;; `flymake-proc-legacy-flymake' suitable for adding to the
+;; `flymake-diagnostic-functions' variable.
;;
;;; Bugs/todo:
@@ -412,7 +416,7 @@ Create parent directories as needed."
:warning)
(t
:error)))))))
- (condition-case err
+ (condition-case-unless-debug err
(cl-loop
with (regexp file-idx line-idx col-idx message-idx) = pattern
while (search-forward-regexp regexp nil t)
@@ -497,11 +501,13 @@ Create parent directories as needed."
(diagnostics (process-get
proc
'flymake-proc--collected-diagnostics))
- (interrupted (process-get proc 'flymake-proc--interrupted)))
+ (interrupted (process-get proc 'flymake-proc--interrupted))
+ (panic nil)
+ (output-buffer (process-get proc 'flymake-proc--output-buffer)))
(flymake-log 2 "process %d exited with code %d"
(process-id proc) exit-status)
- (unwind-protect
- (when (buffer-live-p source-buffer)
+ (condition-case-unless-debug err
+ (progn
(flymake-log 3 "cleaning up using %s" cleanup-f)
(with-current-buffer source-buffer
(funcall cleanup-f)
@@ -509,19 +515,24 @@ Create parent directories as needed."
(funcall flymake-proc--report-fn diagnostics))
(interrupted
(flymake-proc--panic :stopped interrupted))
+ (diagnostics
+ ;; non-zero exit but some diagnostics is quite
+ ;; normal...
+ (funcall flymake-proc--report-fn diagnostics))
((null diagnostics)
- ;; non-zero exit but no errors is strange
+ ;; ...but no diagnostics is strange, so panic.
+ (setq panic t)
(flymake-proc--panic
:configuration-error
(format "Command %s errored, but no diagnostics"
- command)))
- (diagnostics
- (funcall flymake-proc--report-fn diagnostics)))))
+ command))))))
(delete-process proc)
(setq flymake-proc--processes
(delq proc flymake-proc--processes))
- (unless (> flymake-log-level 2)
- (kill-buffer (process-get proc 'flymake-proc--output-buffer)))))))
+ (if panic
+ (flymake-log 1 "Output buffer %s kept alive for debugging"
+ output-buffer)
+ (kill-buffer output-buffer))))))
(defun flymake-proc--panic (problem explanation)
"Tell flymake UI about a fatal PROBLEM with this backend.
@@ -679,7 +690,7 @@ expression. A match indicates `:warning' type, otherwise
(flymake-log 2 "deleted file %s" file-name)))
(defun flymake-proc--safe-delete-directory (dir-name)
- (condition-case nil
+ (condition-case-unless-debug nil
(progn
(delete-directory dir-name)
(flymake-log 2 "deleted dir %s" dir-name))
@@ -687,13 +698,21 @@ expression. A match indicates `:warning' type, otherwise
(flymake-log 1 "Failed to delete dir %s, error ignored" dir-name))))
-(defun flymake-proc-start-syntax-check (report-fn &optional interactive)
- "Start syntax checking for current buffer."
+(defun flymake-proc-legacy-flymake (report-fn &optional interactive)
+ "Flymake backend based on the original flymake implementation.
+This function is suitable for inclusion in
+`flymake-dianostic-types-alist'. For backward compatibility, it
+can also be executed interactively independently of
+`flymake-mode'."
;; Interactively, behave as if flymake had invoked us through its
;; `flymake-diagnostic-functions' with a suitable ID so flymake can
;; clean up consistently
- (interactive (list (flymake-make-report-fn 'flymake-proc-start-syntax-check)
- t))
+ (interactive (list
+ (lambda (diags &rest args)
+ (apply (flymake-make-report-fn 'flymake-proc-legacy-flymake)
+ diags
+ (append args '(:force t))))
+ t))
(cond
((process-live-p flymake-proc--process)
(when interactive
@@ -728,9 +747,13 @@ expression. A match indicates `:warning' type, otherwise
dir)
t)))))))
+(define-obsolete-function-alias 'flymake-start-syntax-check
+ 'flymake-proc-legacy-flymake "26.1"
+ "Flymake backend based on the original flymake implementation.")
+
(defun flymake-proc--start-syntax-check-process (cmd args dir)
"Start syntax check process."
- (condition-case err
+ (condition-case-unless-debug err
(let* ((process
(let ((default-directory (or dir default-directory)))
(when dir
@@ -1070,7 +1093,7 @@ Use CREATE-TEMP-F for creating temp copy."
;;;; Hook onto flymake-ui
(add-to-list 'flymake-diagnostic-functions
- 'flymake-proc-start-syntax-check)
+ 'flymake-proc-legacy-flymake)
;;;;
@@ -1254,9 +1277,6 @@ Return its components if so, nil otherwise.")
(define-obsolete-function-alias 'flymake-safe-delete-directory
'flymake-proc--safe-delete-directory "26.1"
nil)
- (define-obsolete-function-alias 'flymake-start-syntax-check
- 'flymake-proc-start-syntax-check "26.1"
- "Start syntax checking for current buffer.")
(define-obsolete-function-alias 'flymake-stop-all-syntax-checks
'flymake-proc-stop-all-syntax-checks "26.1"
"Kill all syntax check processes.")
- [Emacs-diffs] emacs-26 0d26e45 11/39: Add a new Flymake test for multiple errors and warnings, (continued)
- [Emacs-diffs] emacs-26 0d26e45 11/39: Add a new Flymake test for multiple errors and warnings, João Távora, 2017/10/03
- [Emacs-diffs] emacs-26 54beebb 14/39: Flymake highlights GCC info/notes as detected by flymake-proc.el, João Távora, 2017/10/03
- [Emacs-diffs] emacs-26 f1601be 02/39: Flymake provides flymake-report re-entry point for backends, João Távora, 2017/10/03
- [Emacs-diffs] emacs-26 ae64bf1 08/39: New Flymake variable flymake-diagnostic-types-alist and much cleanup, João Távora, 2017/10/03
- [Emacs-diffs] emacs-26 6954270 03/39: Completely rewrite Flymake's subprocess output processing, João Távora, 2017/10/03
- [Emacs-diffs] emacs-26 f930963 18/39: Simplify Flymake logging and erroring, João Távora, 2017/10/03
- [Emacs-diffs] emacs-26 734aa88 09/39: Flymake's flymake-proc.el parses column numbers from gcc/javac errors, João Távora, 2017/10/03
- [Emacs-diffs] emacs-26 9f8ad13 07/39: Refactor Flymake tests in preparation for more tests, João Távora, 2017/10/03
- [Emacs-diffs] emacs-26 491cc4a 13/39: Flymake checks file names before considering diagnostics, João Távora, 2017/10/03
- [Emacs-diffs] emacs-26 7787988 10/39: Flymake warning face easier to distinguish, João Távora, 2017/10/03
- [Emacs-diffs] emacs-26 5ec7d73 19/39: Flymake's flymake-proc.el backend slightly easier to debug,
João Távora <=
- [Emacs-diffs] emacs-26 9a629a7 23/39: Add interactive flymake-start function, João Távora, 2017/10/03
- [Emacs-diffs] emacs-26 b0bb181 15/39: Protect Flymake's eager checks against commands like fill-paragraph, João Távora, 2017/10/03
- [Emacs-diffs] emacs-26 b2f8b8b 16/39: More Flymake cleanup before advancing to backend redesign, João Távora, 2017/10/03
- [Emacs-diffs] emacs-26 22a7372 31/39: Flymake uses proper idle timers, João Távora, 2017/10/03
- [Emacs-diffs] emacs-26 87993cd 28/39: Explicitly add a(n empty) keymap for Flymake, João Távora, 2017/10/03
- [Emacs-diffs] emacs-26 bb8b663 04/39: Move symbols in flymake-proc.el to separate namespace, João Távora, 2017/10/03
- [Emacs-diffs] emacs-26 483f1e8 22/39: A couple of Flymake backends for emacs-lisp-mode, João Távora, 2017/10/03
- [Emacs-diffs] emacs-26 5235eaf 25/39: Treat Flymake errors as just another type of diagnostic, João Távora, 2017/10/03
- [Emacs-diffs] emacs-26 8118f0f 24/39: Fix three Flymake bugs when checking C header files, João Távora, 2017/10/03
- [Emacs-diffs] emacs-26 e0df7b9 21/39: Fancy Flymake mode-line construct displays status, João Távora, 2017/10/03