From: João Távora Date: Wed, 3 Jul 2019 23:27:08 +0000 (+0100) Subject: Fix Flymake's treatment of region-specific reports X-Git-Tag: emacs-27.0.90~2109 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=22d99801edb8647c7adad01e6825a12849426419;p=emacs.git Fix Flymake's treatment of region-specific reports We're supposed to delete intersecting diagnostics in that situation, but the intersection logic was way off. * lisp/progmodes/flymake.el (version): Bump to 1.0.7. (flymake--intersects-p): New helper. (flymake--handle-report): Fix handling of :region. --- diff --git a/lisp/progmodes/flymake.el b/lisp/progmodes/flymake.el index 6f3d2d59b5c..d662aaf4257 100644 --- a/lisp/progmodes/flymake.el +++ b/lisp/progmodes/flymake.el @@ -4,7 +4,7 @@ ;; Author: Pavel Kobyakov ;; Maintainer: João Távora -;; Version: 1.0.6 +;; Version: 1.0.7 ;; Package-Requires: ((emacs "26.1")) ;; Keywords: c languages tools @@ -697,6 +697,14 @@ backend is operating normally.") "Tell if Flymake has running backends in this buffer" (flymake-running-backends)) +;; FIXME: clone of `isearch-intesects-p'! Make this an util. +(defun flymake--intersects-p (start0 end0 start1 end1) + "Return t if regions START0..END0 and START1..END1 intersect." + (or (and (>= start0 start1) (< start0 end1)) + (and (> end0 start1) (<= end0 end1)) + (and (>= start1 start0) (< start1 end0)) + (and (> end1 start0) (<= end1 end0)))) + (cl-defun flymake--handle-report (backend token report-action &key explanation force region &allow-other-keys) @@ -744,9 +752,12 @@ report applies to that region." (cond (region (cl-loop for diag in (flymake--backend-state-diags state) - if (or (> (flymake--diag-end diag) (car region)) - (< (flymake--diag-beg diag) (cdr region))) - do (delete-overlay (flymake--diag-overlay diag)) + for ov = (flymake--diag-overlay diag) + if (or (not (overlay-buffer ov)) + (flymake--intersects-p + (overlay-start ov) (overlay-end ov) + (car region) (cdr region))) + do (delete-overlay ov) else collect diag into surviving finally (setf (flymake--backend-state-diags state) surviving)))