diff options
Diffstat (limited to 'doc/misc')
| -rw-r--r-- | doc/misc/flymake.texi | 61 |
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 | ||
| 365 | As you might have guessed, Flymake's annotations are implemented as | 370 | As you might have guessed, Flymake's annotations are implemented as |
| 366 | overlays (@pxref{Overlays,,, elisp, The Emacs Lisp Reference Manual}). | 371 | overlays (@pxref{Overlays,,, elisp, The Emacs Lisp Reference Manual}). |
| 367 | Along with the properties that you specify for the specific type of | 372 | Along with the properties that you specify for the specific type of |
| 368 | diagnostic, Flymake adds the property @code{flymake-text} to these | 373 | diagnostic, Flymake adds the property @code{flymake-diagnostic} to |
| 369 | overlays, and sets it to the message string that the backend used to | 374 | these overlays, and sets it to the object that the backend created |
| 370 | describe the diagnostic. | 375 | with @code{flymake-make-diagnostic}. |
| 371 | 376 | ||
| 372 | Since overlays also support arbitrary keymaps, you can use this | 377 | Since overlays also support arbitrary keymaps, you can this along with |
| 373 | property @code{flymake-text} to create interactive annotations, such | 378 | the functions @code{flymake-diagnostics} and |
| 374 | as in the following example of binding a @kbd{mouse-3} event (middle | 379 | @code{flymake-diagnostic-text} (@pxref{Flymake utility functions}) to |
| 375 | mouse button click) to an Internet search for the text of a | 380 | create interactive annotations, such as in the following example of |
| 376 | @code{:warning} or @code{:error}. | 381 | binding a @kbd{mouse-3} event (middle mouse button click) to an |
| 382 | Internet 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 | |||
| 513 | of the problem detected in this region. | 517 | of the problem detected in this region. |
| 514 | @end deffn | 518 | @end deffn |
| 515 | 519 | ||
| 520 | @cindex access diagnostic object | ||
| 521 | These 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 | |||
| 526 | Additionally, the function @code{flymake-diagnostics} will collect | ||
| 527 | such objects in the region you specify. | ||
| 528 | |||
| 529 | @cindex collect diagnostic objects | ||
| 530 | @deffn Function flymake-diagnostics beg end | ||
| 531 | Get a list of Flymake diagnostics in the region comprised between | ||
| 532 | @var{beg} and @var{end}. If neither @var{beg} or @var{end} is | ||
| 533 | supplied, 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 |
| 517 | It is often the case with external syntax tools that a diagnostic's | 538 | It is often the case with external syntax tools that a diagnostic's |
| 518 | position is reported in terms of a line number, and sometimes a column | 539 | position is reported in terms of a line number, and sometimes a column |