summaryrefslogtreecommitdiff
path: root/lisp/progmodes/flymake.el
diff options
context:
space:
mode:
authorJoão Távora <joaotavora@gmail.com>2018-06-05 14:25:47 +0100
committerJoão Távora <joaotavora@gmail.com>2018-06-05 15:18:04 +0100
commitfb759a75007d38a8aea6e8c1a22bbc004453a73f (patch)
treeec0493fac44a4fd751c36eddc234ff043095ee65 /lisp/progmodes/flymake.el
parentbd4f22b6289d51762db1365d8d05de529ec77aeb (diff)
downloademacs-fb759a75007d38a8aea6e8c1a22bbc004453a73f.tar.gz
emacs-fb759a75007d38a8aea6e8c1a22bbc004453a73f.tar.bz2
emacs-fb759a75007d38a8aea6e8c1a22bbc004453a73f.zip
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.
Diffstat (limited to 'lisp/progmodes/flymake.el')
-rw-r--r--lisp/progmodes/flymake.el13
1 files changed, 9 insertions, 4 deletions
diff --git a/lisp/progmodes/flymake.el b/lisp/progmodes/flymake.el
index ee0da45bd91..35d56725445 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.