emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 22d9980 1/2: Fix Flymake's treatment of region-spec


From: João Távora
Subject: [Emacs-diffs] master 22d9980 1/2: Fix Flymake's treatment of region-specific reports
Date: Wed, 3 Jul 2019 19:40:25 -0400 (EDT)

branch: master
commit 22d99801edb8647c7adad01e6825a12849426419
Author: João Távora <address@hidden>
Commit: João Távora <address@hidden>

    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.
---
 lisp/progmodes/flymake.el | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/lisp/progmodes/flymake.el b/lisp/progmodes/flymake.el
index 6f3d2d5..d662aaf 100644
--- a/lisp/progmodes/flymake.el
+++ b/lisp/progmodes/flymake.el
@@ -4,7 +4,7 @@
 
 ;; Author: Pavel Kobyakov <address@hidden>
 ;; Maintainer: João Távora <address@hidden>
-;; 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)))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]