aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/progmodes/flymake-proc.el33
-rw-r--r--lisp/progmodes/flymake.el68
2 files changed, 53 insertions, 48 deletions
diff --git a/lisp/progmodes/flymake-proc.el b/lisp/progmodes/flymake-proc.el
index 2e593bd758d..05f2cab1af6 100644
--- a/lisp/progmodes/flymake-proc.el
+++ b/lisp/progmodes/flymake-proc.el
@@ -423,18 +423,24 @@ Create parent directories as needed."
423 for col-string = (and col-idx (match-string col-idx)) 423 for col-string = (and col-idx (match-string col-idx))
424 for col-number = (and col-string 424 for col-number = (and col-string
425 (string-to-number col-string)) 425 (string-to-number col-string))
426 collect (with-current-buffer (process-buffer proc) 426 for full-file = (with-current-buffer (process-buffer proc)
427 (flymake-make-diagnostic 427 (and fname
428 :file fname 428 (funcall
429 :line line-number 429 (flymake-proc--get-real-file-name-function
430 :col col-number 430 fname)
431 :type (guess-type flymake-proc-diagnostic-type-pred message) 431 fname)))
432 :text message 432 for buffer = (and full-file
433 :full-file (and fname 433 (find-buffer-visiting full-file))
434 (funcall 434 if (eq buffer (process-buffer proc))
435 (flymake-proc--get-real-file-name-function 435 collect (with-current-buffer buffer
436 fname) 436 (pcase-let ((`(,beg . ,end)
437 fname))))) 437 (flymake-diag-region line-number col-number)))
438 (flymake-make-diagnostic
439 buffer beg end
440 (guess-type flymake-proc-diagnostic-type-pred message)
441 message)))
442 else
443 do (flymake-log 2 "No buffer found for diagnosed file %s" fname))
438 (error 444 (error
439 (flymake-log 1 "Error parsing process output for pattern %s: %s" 445 (flymake-log 1 "Error parsing process output for pattern %s: %s"
440 pattern err) 446 pattern err)
@@ -486,7 +492,8 @@ Create parent directories as needed."
486 492
487 (flymake-log 2 "process %d exited with code %d" 493 (flymake-log 2 "process %d exited with code %d"
488 (process-id process) exit-status) 494 (process-id process) exit-status)
489 (kill-buffer (process-get process 'flymake-proc--output-buffer)) 495 (unless (> flymake-log-level 2)
496 (kill-buffer (process-get process 'flymake-proc--output-buffer)))
490 (condition-case err 497 (condition-case err
491 (progn 498 (progn
492 (flymake-log 3 "cleaning up using %s" cleanup-f) 499 (flymake-log 3 "cleaning up using %s" cleanup-f)
diff --git a/lisp/progmodes/flymake.el b/lisp/progmodes/flymake.el
index b5abf5c6ffe..ea9e7c92ead 100644
--- a/lisp/progmodes/flymake.el
+++ b/lisp/progmodes/flymake.el
@@ -139,10 +139,29 @@ are the string substitutions (see the function `format')."
139 (message "%s" msg)))) 139 (message "%s" msg))))
140 140
141(cl-defstruct (flymake--diag 141(cl-defstruct (flymake--diag
142 (:constructor flymake-make-diagnostic)) 142 (:constructor flymake--diag-make))
143 file line col type text full-file) 143 buffer beg end type text)
144(define-obsolete-function-alias 'flymake-ler-make 'flymake-make-diagnostic "26.1" 144
145 "Constructor for objects of type `flymake--diag'") 145(defun flymake-make-diagnostic (buffer
146 beg
147 end
148 type
149 text)
150 "Mark BUFFER's region from BEG to END with a flymake diagnostic.
151TYPE is a key to `flymake-diagnostic-types-alist' and TEXT is a
152description of the problem detected in this region."
153 (flymake--diag-make :buffer buffer :beg beg :end end :type type :text text))
154
155(defun flymake-ler-make-ler (file line type text &optional full-file)
156 (let* ((file (or full-file file))
157 (buf (find-buffer-visiting file)))
158 (unless buf (error "No buffer visiting %s" file))
159 (pcase-let* ((`(,beg . ,end)
160 (with-current-buffer buf
161 (flymake-diag-region line nil))))
162 (flymake-make-diagnostic buf beg end type text))))
163
164(make-obsolete 'flymake-ler-make-ler 'flymake-make-diagnostic "26.1")
146 165
147(cl-defun flymake--overlays (&key beg end filter compare key) 166(cl-defun flymake--overlays (&key beg end filter compare key)
148 "Get flymake-related overlays. 167 "Get flymake-related overlays.
@@ -201,15 +220,14 @@ verify FILTER, sort them by COMPARE (using KEY)."
201(define-obsolete-face-alias 'flymake-warnline 'flymake-warning "26.1") 220(define-obsolete-face-alias 'flymake-warnline 'flymake-warning "26.1")
202(define-obsolete-face-alias 'flymake-errline 'flymake-error "26.1") 221(define-obsolete-face-alias 'flymake-errline 'flymake-error "26.1")
203 222
204(defun flymake--diag-region (diagnostic) 223(defun flymake-diag-region (line col)
205 "Return the region (BEG . END) for DIAGNOSTIC. 224 "Compute region (BEG . END) corresponding to LINE and COL.
206Or nil if the region is invalid." 225Or nil if the region is invalid."
207 ;; FIXME: make this a generic function
208 (condition-case-unless-debug _err 226 (condition-case-unless-debug _err
209 (save-excursion 227 (let ((line (min (max line 1)
210 (goto-char (point-min)) 228 (line-number-at-pos (point-max) 'absolute))))
211 (let ((line (flymake--diag-line diagnostic)) 229 (save-excursion
212 (col (flymake--diag-col diagnostic))) 230 (goto-char (point-min))
213 (forward-line (1- line)) 231 (forward-line (1- line))
214 (cl-flet ((fallback-bol 232 (cl-flet ((fallback-bol
215 () (progn (back-to-indentation) (point))) 233 () (progn (back-to-indentation) (point)))
@@ -316,8 +334,9 @@ If TYPE doesn't declare PROP in either
316 334
317(defun flymake--highlight-line (diagnostic) 335(defun flymake--highlight-line (diagnostic)
318 "Highlight buffer with info in DIAGNOSTIC." 336 "Highlight buffer with info in DIAGNOSTIC."
319 (when-let* ((region (flymake--diag-region diagnostic)) 337 (when-let* ((ov (make-overlay
320 (ov (make-overlay (car region) (cdr region)))) 338 (flymake--diag-beg diagnostic)
339 (flymake--diag-end diagnostic))))
321 ;; First set `category' in the overlay, then copy over every other 340 ;; First set `category' in the overlay, then copy over every other
322 ;; property. 341 ;; property.
323 ;; 342 ;;
@@ -387,12 +406,7 @@ If TYPE doesn't declare PROP in either
387 (user-error "No flymake problem for current line"))) 406 (user-error "No flymake problem for current line")))
388 (menu (mapcar (lambda (ov) 407 (menu (mapcar (lambda (ov)
389 (let ((diag (overlay-get ov 'flymake--diagnostic))) 408 (let ((diag (overlay-get ov 'flymake--diagnostic)))
390 (cons (format "%s - %s(%s)" 409 (cons (flymake--diag-text diag)
391 (flymake--diag-text diag)
392 (or (flymake--diag-file diag)
393 "(no file)")
394 (or (flymake--diag-line diag)
395 "?"))
396 ov))) 410 ov)))
397 diag-overlays)) 411 diag-overlays))
398 (event (if (mouse-event-p event) 412 (event (if (mouse-event-p event)
@@ -444,26 +458,10 @@ If TYPE doesn't declare PROP in either
444 (flymake-log 0 "switched OFF Flymake mode for buffer %s due to fatal status %s, warning %s" 458 (flymake-log 0 "switched OFF Flymake mode for buffer %s due to fatal status %s, warning %s"
445 (buffer-name) status warning)) 459 (buffer-name) status warning))
446 460
447(defun flymake--fix-line-numbers (diagnostic)
448 "Ensure DIAGNOSTIC has sensible error lines"
449 (setf (flymake--diag-line diagnostic)
450 (min (max (flymake--diag-line diagnostic)
451 1)
452 (line-number-at-pos (point-max) 'absolute))))
453
454(defun flymake-report (diagnostics) 461(defun flymake-report (diagnostics)
455 (save-restriction 462 (save-restriction
456 (widen) 463 (widen)
457 (flymake-delete-own-overlays) 464 (flymake-delete-own-overlays)
458 (setq diagnostics
459 (cl-remove-if-not
460 (lambda (diag)
461 (let ((ff (flymake--diag-full-file diag)))
462 (and ff
463 (equal (expand-file-name ff)
464 (expand-file-name (buffer-file-name))))))
465 diagnostics))
466 (mapc #'flymake--fix-line-numbers diagnostics)
467 (mapc #'flymake--highlight-line diagnostics) 465 (mapc #'flymake--highlight-line diagnostics)
468 (let ((err-count (cl-count-if #'flymake--diag-errorp diagnostics)) 466 (let ((err-count (cl-count-if #'flymake--diag-errorp diagnostics))
469 (warn-count (cl-count-if-not #'flymake--diag-errorp diagnostics))) 467 (warn-count (cl-count-if-not #'flymake--diag-errorp diagnostics)))