aboutsummaryrefslogtreecommitdiffstats
path: root/doc/misc
diff options
context:
space:
mode:
Diffstat (limited to 'doc/misc')
-rw-r--r--doc/misc/flymake.texi61
1 files changed, 41 insertions, 20 deletions
diff --git a/doc/misc/flymake.texi b/doc/misc/flymake.texi
index 99ab1271ac9..6e0928f0ee2 100644
--- a/doc/misc/flymake.texi
+++ b/doc/misc/flymake.texi
@@ -361,34 +361,38 @@ priority but without an overlay face.
361 (flymake-category . flymake-note)))) 361 (flymake-category . flymake-note))))
362@end example 362@end example
363 363
364@vindex flymake-text 364@vindex flymake-diagnostics
365@vindex flymake-diagnostic-backend
366@vindex flymake-diagnostic-buffer
367@vindex flymake-diagnostic-text
368@vindex flymake-diagnostic-beg
369@vindex flymake-diagnostic-end
365As you might have guessed, Flymake's annotations are implemented as 370As you might have guessed, Flymake's annotations are implemented as
366overlays (@pxref{Overlays,,, elisp, The Emacs Lisp Reference Manual}). 371overlays (@pxref{Overlays,,, elisp, The Emacs Lisp Reference Manual}).
367Along with the properties that you specify for the specific type of 372Along with the properties that you specify for the specific type of
368diagnostic, Flymake adds the property @code{flymake-text} to these 373diagnostic, Flymake adds the property @code{flymake-diagnostic} to
369overlays, and sets it to the message string that the backend used to 374these overlays, and sets it to the object that the backend created
370describe the diagnostic. 375with @code{flymake-make-diagnostic}.
371 376
372Since overlays also support arbitrary keymaps, you can use this 377Since overlays also support arbitrary keymaps, you can this along with
373property @code{flymake-text} to create interactive annotations, such 378the functions @code{flymake-diagnostics} and
374as in the following example of binding a @kbd{mouse-3} event (middle 379@code{flymake-diagnostic-text} (@pxref{Flymake utility functions}) to
375mouse button click) to an Internet search for the text of a 380create interactive annotations, such as in the following example of
376@code{:warning} or @code{:error}. 381binding a @kbd{mouse-3} event (middle mouse button click) to an
382Internet search for the text of a @code{:warning} or @code{:error}.
377 383
378@example 384@example
379(defun my-search-for-message (event) 385(defun my-search-for-message (event)
380 (interactive "e") 386 (interactive "e")
381 (let ((ovs (overlays-at (posn-point (event-start event)))) 387 (let* ((diags (flymake-diagnostics (posn-point (event-start event))))
382 ov) 388 (topmost-diag (car diags)))
383 ;; loop until flymake overlay we clicked on is recovered 389 (eww-browse-url
384 (while (not (overlay-get (setq ov (pop ovs)) 'flymake-text))) 390 (concat
385 (when ov 391 "https://duckduckgo.com/?q="
386 (eww-browse-url 392 (replace-regexp-in-string " "
387 (concat "https://duckduckgo.com/?q=" 393 "+"
388 (replace-regexp-in-string " " 394 (flymake-diagnostic-text topmost-diag)))
389 "+" 395 t)))
390 (overlay-get ov 'flymake-text)))
391 t))))
392 396
393(dolist (type '(:warning :error)) 397(dolist (type '(:warning :error))
394 (let ((a (assoc type flymake-diagnostic-types-alist))) 398 (let ((a (assoc type flymake-diagnostic-types-alist)))
@@ -513,6 +517,23 @@ Make a Flymake diagnostic for @var{buffer}'s region from @var{beg} to
513of the problem detected in this region. 517of the problem detected in this region.
514@end deffn 518@end deffn
515 519
520@cindex access diagnostic object
521These objects' properties can be accessed with the functions
522@code{flymake-diagnostic-backend}, @code{flymake-diagnostic-buffer},
523@code{flymake-diagnostic-text}, @code{flymake-diagnostic-beg},
524@code{flymake-diagnostic-end} and @code{flymake-diagnostic-type}.
525
526Additionally, the function @code{flymake-diagnostics} will collect
527such objects in the region you specify.
528
529@cindex collect diagnostic objects
530@deffn Function flymake-diagnostics beg end
531Get a list of Flymake diagnostics in the region comprised between
532@var{beg} and @var{end}. If neither @var{beg} or @var{end} is
533supplied, use the whole buffer, otherwise if @var{beg} is non-nil and
534@var{end} is nil, consider only diagnostics at @var{beg}.
535@end deffn
536
516@cindex buffer position from line and column number 537@cindex buffer position from line and column number
517It is often the case with external syntax tools that a diagnostic's 538It is often the case with external syntax tools that a diagnostic's
518position is reported in terms of a line number, and sometimes a column 539position is reported in terms of a line number, and sometimes a column