emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master fb759a7 2/4: Let Flymake backends attach arbitrary


From: João Távora
Subject: [Emacs-diffs] master fb759a7 2/4: Let Flymake backends attach arbitrary data to diagnostics
Date: Tue, 5 Jun 2018 10:22:51 -0400 (EDT)

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

    Let Flymake backends attach arbitrary data to diagnostics
    
    This is easier that setting properties on diagnostics' text.
    
    * lisp/progmodes/flymake.el (flymake--diag): Add data slot.
    (flymake-make-diagnostic): Add DATA arg.
    (flymake-diagnostic-data): New accessor.
---
 lisp/progmodes/flymake.el | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/lisp/progmodes/flymake.el b/lisp/progmodes/flymake.el
index ee0da45..35d5672 100644
--- a/lisp/progmodes/flymake.el
+++ b/lisp/progmodes/flymake.el
@@ -222,18 +222,22 @@ generated it."
 
 (cl-defstruct (flymake--diag
                (:constructor flymake--diag-make))
-  buffer beg end type text backend)
+  buffer beg end type text backend data)
 
 ;;;###autoload
 (defun flymake-make-diagnostic (buffer
                                 beg
                                 end
                                 type
-                                text)
+                                text
+                                &optional data)
   "Make a Flymake diagnostic for BUFFER's region from BEG to END.
 TYPE is a key to `flymake-diagnostic-types-alist' and TEXT is a
-description of the problem detected in this region."
-  (flymake--diag-make :buffer buffer :beg beg :end end :type type :text text))
+description of the problem detected in this region.  DATA is any
+object that the caller wishes to attach to the created diagnostic
+for later retrieval."
+  (flymake--diag-make :buffer buffer :beg beg :end end
+                      :type type :text text :data data))
 
 ;;;###autoload
 (defun flymake-diagnostics (&optional beg end)
@@ -257,6 +261,7 @@ diagnostics at BEG."
 (flymake--diag-accessor flymake-diagnostic-beg flymake--diag-beg beg)
 (flymake--diag-accessor flymake-diagnostic-end flymake--diag-end end)
 (flymake--diag-accessor flymake-diagnostic-backend flymake--diag-backend 
backend)
+(flymake--diag-accessor flymake-diagnostic-data flymake--diag-data backend)
 
 (cl-defun flymake--overlays (&key beg end filter compare key)
   "Get flymake-related overlays.



reply via email to

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