aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/progmodes/flymake-proc.el68
1 files changed, 44 insertions, 24 deletions
diff --git a/lisp/progmodes/flymake-proc.el b/lisp/progmodes/flymake-proc.el
index 1028d9ae40c..37b7e49dea4 100644
--- a/lisp/progmodes/flymake-proc.el
+++ b/lisp/progmodes/flymake-proc.el
@@ -1,4 +1,4 @@
1;;; flymake-proc.el --- Flymake for external syntax checker processes -*- lexical-binding: t; -*- 1;;; flymake-proc.el --- Flymake backend for external tools -*- lexical-binding: t; -*-
2 2
3;; Copyright (C) 2003-2017 Free Software Foundation, Inc. 3;; Copyright (C) 2003-2017 Free Software Foundation, Inc.
4 4
@@ -26,9 +26,13 @@
26;; 26;;
27;; Flymake is a minor Emacs mode performing on-the-fly syntax checks. 27;; Flymake is a minor Emacs mode performing on-the-fly syntax checks.
28;; 28;;
29;; This file contains the most original implementation of flymake's 29;; This file contains a significant part of the original flymake's
30;; main source of on-the-fly diagnostic info, the external syntax 30;; implementation, a buffer-checking mechanism that parses the output
31;; checker backend. 31;; of an external syntax check tool with regular expressions.
32;;
33;; That work has been adapted into a flymake "backend" function,
34;; `flymake-proc-legacy-flymake' suitable for adding to the
35;; `flymake-diagnostic-functions' variable.
32;; 36;;
33;;; Bugs/todo: 37;;; Bugs/todo:
34 38
@@ -412,7 +416,7 @@ Create parent directories as needed."
412 :warning) 416 :warning)
413 (t 417 (t
414 :error))))))) 418 :error)))))))
415 (condition-case err 419 (condition-case-unless-debug err
416 (cl-loop 420 (cl-loop
417 with (regexp file-idx line-idx col-idx message-idx) = pattern 421 with (regexp file-idx line-idx col-idx message-idx) = pattern
418 while (search-forward-regexp regexp nil t) 422 while (search-forward-regexp regexp nil t)
@@ -497,11 +501,13 @@ Create parent directories as needed."
497 (diagnostics (process-get 501 (diagnostics (process-get
498 proc 502 proc
499 'flymake-proc--collected-diagnostics)) 503 'flymake-proc--collected-diagnostics))
500 (interrupted (process-get proc 'flymake-proc--interrupted))) 504 (interrupted (process-get proc 'flymake-proc--interrupted))
505 (panic nil)
506 (output-buffer (process-get proc 'flymake-proc--output-buffer)))
501 (flymake-log 2 "process %d exited with code %d" 507 (flymake-log 2 "process %d exited with code %d"
502 (process-id proc) exit-status) 508 (process-id proc) exit-status)
503 (unwind-protect 509 (condition-case-unless-debug err
504 (when (buffer-live-p source-buffer) 510 (progn
505 (flymake-log 3 "cleaning up using %s" cleanup-f) 511 (flymake-log 3 "cleaning up using %s" cleanup-f)
506 (with-current-buffer source-buffer 512 (with-current-buffer source-buffer
507 (funcall cleanup-f) 513 (funcall cleanup-f)
@@ -509,19 +515,24 @@ Create parent directories as needed."
509 (funcall flymake-proc--report-fn diagnostics)) 515 (funcall flymake-proc--report-fn diagnostics))
510 (interrupted 516 (interrupted
511 (flymake-proc--panic :stopped interrupted)) 517 (flymake-proc--panic :stopped interrupted))
518 (diagnostics
519 ;; non-zero exit but some diagnostics is quite
520 ;; normal...
521 (funcall flymake-proc--report-fn diagnostics))
512 ((null diagnostics) 522 ((null diagnostics)
513 ;; non-zero exit but no errors is strange 523 ;; ...but no diagnostics is strange, so panic.
524 (setq panic t)
514 (flymake-proc--panic 525 (flymake-proc--panic
515 :configuration-error 526 :configuration-error
516 (format "Command %s errored, but no diagnostics" 527 (format "Command %s errored, but no diagnostics"
517 command))) 528 command))))))
518 (diagnostics
519 (funcall flymake-proc--report-fn diagnostics)))))
520 (delete-process proc) 529 (delete-process proc)
521 (setq flymake-proc--processes 530 (setq flymake-proc--processes
522 (delq proc flymake-proc--processes)) 531 (delq proc flymake-proc--processes))
523 (unless (> flymake-log-level 2) 532 (if panic
524 (kill-buffer (process-get proc 'flymake-proc--output-buffer))))))) 533 (flymake-log 1 "Output buffer %s kept alive for debugging"
534 output-buffer)
535 (kill-buffer output-buffer))))))
525 536
526(defun flymake-proc--panic (problem explanation) 537(defun flymake-proc--panic (problem explanation)
527 "Tell flymake UI about a fatal PROBLEM with this backend. 538 "Tell flymake UI about a fatal PROBLEM with this backend.
@@ -679,7 +690,7 @@ expression. A match indicates `:warning' type, otherwise
679 (flymake-log 2 "deleted file %s" file-name))) 690 (flymake-log 2 "deleted file %s" file-name)))
680 691
681(defun flymake-proc--safe-delete-directory (dir-name) 692(defun flymake-proc--safe-delete-directory (dir-name)
682 (condition-case nil 693 (condition-case-unless-debug nil
683 (progn 694 (progn
684 (delete-directory dir-name) 695 (delete-directory dir-name)
685 (flymake-log 2 "deleted dir %s" dir-name)) 696 (flymake-log 2 "deleted dir %s" dir-name))
@@ -687,13 +698,21 @@ expression. A match indicates `:warning' type, otherwise
687 (flymake-log 1 "Failed to delete dir %s, error ignored" dir-name)))) 698 (flymake-log 1 "Failed to delete dir %s, error ignored" dir-name))))
688 699
689 700
690(defun flymake-proc-start-syntax-check (report-fn &optional interactive) 701(defun flymake-proc-legacy-flymake (report-fn &optional interactive)
691 "Start syntax checking for current buffer." 702 "Flymake backend based on the original flymake implementation.
703This function is suitable for inclusion in
704`flymake-dianostic-types-alist'. For backward compatibility, it
705can also be executed interactively independently of
706`flymake-mode'."
692 ;; Interactively, behave as if flymake had invoked us through its 707 ;; Interactively, behave as if flymake had invoked us through its
693 ;; `flymake-diagnostic-functions' with a suitable ID so flymake can 708 ;; `flymake-diagnostic-functions' with a suitable ID so flymake can
694 ;; clean up consistently 709 ;; clean up consistently
695 (interactive (list (flymake-make-report-fn 'flymake-proc-start-syntax-check) 710 (interactive (list
696 t)) 711 (lambda (diags &rest args)
712 (apply (flymake-make-report-fn 'flymake-proc-legacy-flymake)
713 diags
714 (append args '(:force t))))
715 t))
697 (cond 716 (cond
698 ((process-live-p flymake-proc--process) 717 ((process-live-p flymake-proc--process)
699 (when interactive 718 (when interactive
@@ -728,9 +747,13 @@ expression. A match indicates `:warning' type, otherwise
728 dir) 747 dir)
729 t))))))) 748 t)))))))
730 749
750(define-obsolete-function-alias 'flymake-start-syntax-check
751 'flymake-proc-legacy-flymake "26.1"
752 "Flymake backend based on the original flymake implementation.")
753
731(defun flymake-proc--start-syntax-check-process (cmd args dir) 754(defun flymake-proc--start-syntax-check-process (cmd args dir)
732 "Start syntax check process." 755 "Start syntax check process."
733 (condition-case err 756 (condition-case-unless-debug err
734 (let* ((process 757 (let* ((process
735 (let ((default-directory (or dir default-directory))) 758 (let ((default-directory (or dir default-directory)))
736 (when dir 759 (when dir
@@ -1070,7 +1093,7 @@ Use CREATE-TEMP-F for creating temp copy."
1070 1093
1071;;;; Hook onto flymake-ui 1094;;;; Hook onto flymake-ui
1072(add-to-list 'flymake-diagnostic-functions 1095(add-to-list 'flymake-diagnostic-functions
1073 'flymake-proc-start-syntax-check) 1096 'flymake-proc-legacy-flymake)
1074 1097
1075 1098
1076;;;; 1099;;;;
@@ -1254,9 +1277,6 @@ Return its components if so, nil otherwise.")
1254 (define-obsolete-function-alias 'flymake-safe-delete-directory 1277 (define-obsolete-function-alias 'flymake-safe-delete-directory
1255 'flymake-proc--safe-delete-directory "26.1" 1278 'flymake-proc--safe-delete-directory "26.1"
1256 nil) 1279 nil)
1257 (define-obsolete-function-alias 'flymake-start-syntax-check
1258 'flymake-proc-start-syntax-check "26.1"
1259 "Start syntax checking for current buffer.")
1260 (define-obsolete-function-alias 'flymake-stop-all-syntax-checks 1280 (define-obsolete-function-alias 'flymake-stop-all-syntax-checks
1261 'flymake-proc-stop-all-syntax-checks "26.1" 1281 'flymake-proc-stop-all-syntax-checks "26.1"
1262 "Kill all syntax check processes.") 1282 "Kill all syntax check processes.")