[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] scratch/flymake-refactor 3dfe11c 28/52: Simplify flymake l
From: |
João Távora |
Subject: |
[Emacs-diffs] scratch/flymake-refactor 3dfe11c 28/52: Simplify flymake logging and erroring. |
Date: |
Sun, 1 Oct 2017 12:40:47 -0400 (EDT) |
branch: scratch/flymake-refactor
commit 3dfe11c78babb0b045ab56015d4b908842eff305
Author: João Távora <address@hidden>
Commit: João Távora <address@hidden>
Simplify flymake logging and erroring.
Use display-warning and a dedicated *Flymake log* buffer.
To ease readability, flymake log messages are now prefixed with a
common prefix and the buffer that originated them.
Some situations of over-zealous logging are fixed.
* lisp/progmodes/flymake-proc.el
(flymake-proc--diagnostics-for-pattern): Improve log message.
(flymake-proc--panic): Always flymake-log an error
(flymake-proc--safe-delete-file)
(flymake-proc--safe-delete-directory):
Downgrade warning
(flymake-proc-start-syntax-check): Simplify slightly.
(flymake-proc--start-syntax-check-process): Simplify.
(flymake-proc--init-find-buildfile-dir)
(flymake-proc--init-create-temp-source-and-master-buffer-copy):
No need to warn twice.
* lisp/progmodes/flymake-ui.el (flymake-log): Use display-warning.
(flymake-log-level): Deprecate.
(flymake-error): New helper.
(flymake-ler-make-ler, flymake--handle-report, flymake-mode):
Use flymake-error.
(flymake--handle-report, flymake-mode-on)
(flymake-mode-off, flymake-find-file-hook): Simplify log message.
(flymake-after-save-hook): Simplify logging.
---
lisp/progmodes/flymake-proc.el | 29 ++++++++++++-------------
lisp/progmodes/flymake-ui.el | 48 ++++++++++++++++++++++++++++--------------
2 files changed, 45 insertions(+), 32 deletions(-)
diff --git a/lisp/progmodes/flymake-proc.el b/lisp/progmodes/flymake-proc.el
index 8992b1d..0050a44 100644
--- a/lisp/progmodes/flymake-proc.el
+++ b/lisp/progmodes/flymake-proc.el
@@ -440,7 +440,7 @@ Create parent directories as needed."
(guess-type flymake-proc-diagnostic-type-pred message)
message)))
else
- do (flymake-log 2 "No buffer found for diagnosed file %s" fname))
+ do (flymake-log 2 "Reference to file %s is out of scope" fname))
(error
(flymake-log 1 "Error parsing process output for pattern %s: %s"
pattern err)
@@ -531,7 +531,7 @@ May only be called in a dynamic environment where
flymake-proc--report-fn)
(funcall flymake-proc--report-fn :panic
:explanation (format "%s: %s" problem explanation))
- (error "Trouble telling flymake-ui about problem %s(%s)"
+ (flymake-error "Trouble telling flymake-ui about problem %s(%s)"
problem explanation)))
(defun flymake-proc-reformat-err-line-patterns-from-compile-el (original-list)
@@ -675,13 +675,13 @@ expression. A match indicates `:warning' type, otherwise
(defun flymake-proc--safe-delete-file (file-name)
(when (and file-name (file-exists-p file-name))
(delete-file file-name)
- (flymake-log 1 "deleted file %s" file-name)))
+ (flymake-log 2 "deleted file %s" file-name)))
(defun flymake-proc--safe-delete-directory (dir-name)
(condition-case-unless-debug nil
(progn
(delete-directory dir-name)
- (flymake-log 1 "deleted dir %s" dir-name))
+ (flymake-log 2 "deleted dir %s" dir-name))
(error
(flymake-log 1 "Failed to delete dir %s, error ignored" dir-name))))
@@ -757,15 +757,11 @@ expression. A match indicates `:warning' type, otherwise
default-directory)
process)
(error
- (let* ((err-str
- (format-message
- "Failed to launch syntax check process `%s' with args %s: %s"
- cmd args (error-message-string err)))
- (source-file-name buffer-file-name)
- (cleanup-f (flymake-proc--get-cleanup-function
source-file-name)))
- (flymake-log 0 err-str)
- (funcall cleanup-f)
- (flymake-proc--panic :make-process-error err-str)))))
+ (flymake-proc--panic :make-process-error
+ (format-message
+ "Failed to launch syntax check process `%s' with
args %s: %s"
+ cmd args (error-message-string err)))
+ (funcall (flymake-proc--get-cleanup-function buffer-file-name)))))
(defun flymake-proc-stop-all-syntax-checks (&optional reason)
"Kill all syntax check processes."
@@ -916,7 +912,6 @@ Return full-name. Names are real, not patched."
(file-name-directory
source-file-name))))
(if buildfile-dir
(setq flymake-proc--base-dir buildfile-dir)
- (flymake-log 1 "no buildfile (%s) for %s" buildfile-name
source-file-name)
(flymake-proc--panic
"NOMK" (format "No buildfile (%s) found for %s"
buildfile-name source-file-name)))))
@@ -932,8 +927,10 @@ Return full-name. Names are real, not patched."
(if (not master-and-temp-master)
(progn
- (flymake-log 1 "cannot find master file for %s" source-file-name)
- (flymake-proc--panic "NOMASTER" "") ; NOMASTER
+ (flymake-proc--panic
+ "NOMASTER"
+ (format-message "cannot find master file for %s"
+ source-file-name))
nil)
(setq flymake-proc--master-file-name (nth 0 master-and-temp-master))
(setq flymake-proc--temp-master-file-name (nth 1
master-and-temp-master)))))
diff --git a/lisp/progmodes/flymake-ui.el b/lisp/progmodes/flymake-ui.el
index 608a2b4..cd5ffe3 100644
--- a/lisp/progmodes/flymake-ui.el
+++ b/lisp/progmodes/flymake-ui.el
@@ -34,7 +34,7 @@
(require 'cl-lib)
(require 'thingatpt) ; end-of-thing
-(require 'warnings) ; warning-numeric-level
+(require 'warnings) ; warning-numeric-level, display-warning
(eval-when-compile (require 'subr-x)) ; when-let*, if-let*
(defgroup flymake nil
@@ -110,6 +110,9 @@ See `flymake-error-bitmap' and `flymake-warning-bitmap'."
-1 = NONE, 0 = ERROR, 1 = WARNING, 2 = INFO, 3 = DEBUG"
:group 'flymake
:type 'integer)
+(make-obsolete-variable 'flymake-log-level
+ "it is superseded by `warning-minimum-log-level.'"
+ "26.1")
(defvar-local flymake-timer nil
"Timer for starting syntax check.")
@@ -126,9 +129,24 @@ If LEVEL is higher than `flymake-log-level', the message is
ignored. Otherwise, it is printed using `message'.
TEXT is a format control string, and the remaining arguments ARGS
are the string substitutions (see the function `format')."
- (if (<= level flymake-log-level)
- (let* ((msg (apply #'format-message text args)))
- (message "%s" msg))))
+ (let* ((msg (apply #'format-message text args))
+ (warning-minimum-level :emergency))
+ (display-warning
+ 'flymake
+ (format "%s: %s" (buffer-name) msg)
+ (if (numberp level)
+ (or (nth level
+ '(:error :warning :debug :debug) )
+ :error)
+ level)
+ "*Flymake log*")))
+
+(defun flymake-error (text &rest args)
+ "Signal an error for flymake."
+ (let ((msg (format-message text args)))
+ (flymake-log :error msg)
+ (error (concat "[flymake] "
+ (format text args)))))
(cl-defstruct (flymake--diag
(:constructor flymake--diag-make))
@@ -147,7 +165,7 @@ description of the problem detected in this region."
(defun flymake-ler-make-ler (file line type text &optional full-file)
(let* ((file (or full-file file))
(buf (find-buffer-visiting file)))
- (unless buf (error "No buffer visiting %s" file))
+ (unless buf (flymake-error "No buffer visiting %s" file))
(pcase-let* ((`(,beg . ,end)
(with-current-buffer buf
(flymake-diag-region line nil))))
@@ -241,8 +259,7 @@ Or nil if the region is invalid."
(let* ((beg (fallback-bol))
(end (fallback-eol beg)))
(cons beg end))))))
- (error (flymake-log 4 "Invalid region for diagnostic %s")
- nil)))
+ (error (flymake-error "Invalid region line=%s col=%s" line col))))
(defvar flymake-diagnostic-functions nil
"List of flymake backends i.e. sources of flymake diagnostics.
@@ -471,7 +488,7 @@ A backend is disabled if it reported `:panic'.")
"Handle reports from flymake backend identified by BACKEND."
(cond
((not (memq backend flymake--running-backends))
- (error "Ignoring unexpected report from backend %s" backend))
+ (flymake-error "Ignoring unexpected report from backend %s" backend))
((eq action :progress)
(flymake-log 3 "Backend %s reports progress: %s" backend explanation))
((eq :panic action)
@@ -560,7 +577,7 @@ sources."
(flymake-mode
(cond
((not flymake-diagnostic-functions)
- (error "flymake cannot check syntax in buffer %s" (buffer-name)))
+ (flymake-error "No backends to check buffer %s" (buffer-name)))
(t
(add-hook 'after-change-functions 'flymake-after-change-function nil t)
(add-hook 'after-save-hook 'flymake-after-save-hook nil t)
@@ -591,13 +608,13 @@ sources."
(defun flymake-mode-on ()
"Turn flymake mode on."
(flymake-mode 1)
- (flymake-log 1 "flymake mode turned ON for buffer %s" (buffer-name)))
+ (flymake-log 1 "flymake mode turned ON"))
;;;###autoload
(defun flymake-mode-off ()
"Turn flymake mode off."
(flymake-mode 0)
- (flymake-log 1 "flymake mode turned OFF for buffer %s" (buffer-name)))
+ (flymake-log 1 "flymake mode turned OFF"))
(defun flymake-after-change-function (start stop _len)
"Start syntax check for current buffer if it isn't already running."
@@ -609,10 +626,9 @@ sources."
(setq flymake-last-change-time (float-time))))
(defun flymake-after-save-hook ()
- (if (local-variable-p 'flymake-mode (current-buffer)) ; (???) other
way to determine whether flymake is active in buffer being saved?
- (progn
- (flymake-log 3 "starting syntax check as buffer was saved")
- (flymake--start-syntax-check)))) ; no more mode 3. cannot start check
if mode 3 (to temp copies) is active - (???)
+ (when flymake-mode
+ (flymake-log 3 "starting syntax check as buffer was saved")
+ (flymake--start-syntax-check))) ; no more mode 3. cannot start check if
mode 3 (to temp copies) is active - (???)
(defun flymake-kill-buffer-hook ()
(when flymake-timer
@@ -624,7 +640,7 @@ sources."
(unless (or flymake-mode
(null flymake-diagnostic-functions))
(flymake-mode)
- (flymake-log 3 "automatically turned ON flymake mode")))
+ (flymake-log 3 "automatically turned ON")))
(defun flymake-goto-next-error (&optional n interactive)
"Go to next, or Nth next, flymake error in buffer."
- [Emacs-diffs] scratch/flymake-refactor f3b8a72 20/52: Refactor flymake-tests.el in preparation for more tests, (continued)
- [Emacs-diffs] scratch/flymake-refactor f3b8a72 20/52: Refactor flymake-tests.el in preparation for more tests, João Távora, 2017/10/01
- [Emacs-diffs] scratch/flymake-refactor 593d4303 23/52: Add a new flymake test for multiple errors and warnings, João Távora, 2017/10/01
- [Emacs-diffs] scratch/flymake-refactor d68448f 26/52: More cleanup before advancing to backend redesign, João Távora, 2017/10/01
- [Emacs-diffs] scratch/flymake-refactor 245114e 33/52: Fix autoload conflict between flymake.el and flymake-ui.el, João Távora, 2017/10/01
- [Emacs-diffs] scratch/flymake-refactor 4fea8a9 30/52: Allow filtering in flymake-goto-[next/prev]-error, João Távora, 2017/10/01
- [Emacs-diffs] scratch/flymake-refactor 192cb7f 24/52: flymake-ui.el highlights GCC notes detected by flymake-proc.el, João Távora, 2017/10/01
- [Emacs-diffs] scratch/flymake-refactor 879dcef 29/52: Misc cleanup in flymake-proc.el, João Távora, 2017/10/01
- [Emacs-diffs] scratch/flymake-refactor 820b460 35/52: Add interactive flymake-start function, João Távora, 2017/10/01
- [Emacs-diffs] scratch/flymake-refactor 8e42a5d 31/52: Cleanup some flymake-ui.el internals, João Távora, 2017/10/01
- [Emacs-diffs] scratch/flymake-refactor e1b913f 36/52: Re-implement wraparound for flymake-goto-next-error, João Távora, 2017/10/01
- [Emacs-diffs] scratch/flymake-refactor 3dfe11c 28/52: Simplify flymake logging and erroring.,
João Távora <=
- [Emacs-diffs] scratch/flymake-refactor 9329265 40/52: Treat flymake errors as just another type of diagnostic, João Távora, 2017/10/01
- [Emacs-diffs] scratch/flymake-refactor 38c7d4f 41/52: Remove old flymake-display-err-menu-for-current-line, it's useless, João Távora, 2017/10/01
- [Emacs-diffs] scratch/flymake-refactor 7a22358 34/52: A couple of new flymake backends for emacs-lisp-mode, João Távora, 2017/10/01
- [Emacs-diffs] scratch/flymake-refactor 9d93d46 42/52: New flymake fringe bitmaps, João Távora, 2017/10/01
- [Emacs-diffs] scratch/flymake-refactor 4e2cbaa 32/52: Fancy mode-line construct for flymake-mode, João Távora, 2017/10/01
- [Emacs-diffs] scratch/flymake-refactor 54ec5eb 47/52: Improve use of flymake-no-changes-timeout, João Távora, 2017/10/01
- [Emacs-diffs] scratch/flymake-refactor 95c126c 46/52: flymake-diagnostic-types-alist now uses flymake-category, João Távora, 2017/10/01
- [Emacs-diffs] scratch/flymake-refactor 1d58e32 39/52: Fix flymake-wrap-around for buffers with no errors, João Távora, 2017/10/01
- [Emacs-diffs] scratch/flymake-refactor 1116aa7 43/52: * lisp/progmodes/flymake-ui.el (flymake-mode-map): Bind "M-n" and "M-p", João Távora, 2017/10/01
- [Emacs-diffs] scratch/flymake-refactor 7d3d3d3 38/52: Fix flymake problems when checking C header files, João Távora, 2017/10/01