diff options
| author | João Távora | 2017-10-10 02:14:46 +0100 |
|---|---|---|
| committer | João Távora | 2017-10-10 13:08:41 +0100 |
| commit | 1c2e1884407f6210b0787e76e0707049e2babc8f (patch) | |
| tree | 44f48b1f20c9199bdb7cba4fa9e07d565d67c94b /lisp | |
| parent | 0f7f677f82677a29a7f5abacbb1045cd26c003c5 (diff) | |
| download | emacs-1c2e1884407f6210b0787e76e0707049e2babc8f.tar.gz emacs-1c2e1884407f6210b0787e76e0707049e2babc8f.zip | |
Add full documentation on new Flymake API
Also, as a minor addition to this API, set flymake-text
on the diagnostic overlay. This enables a good example in
the section "Customization Flymake annotations".
* doc/misc/flymake.texi (Overview of Flymake)
(Syntax check statuses): Rework.
(Backend exceptions): Rename from "Troubleshooting"
(Customizable variables): Add flymake-start-on-flymake-mode. Rework.
(Extending Flymake): Write chapter.
(Customizing Flymake annotations, Flymake backends)
(Flymake utility functions, An annotated example backend):
New sections and subsections
* lisp/progmodes/flymake.el (flymake-diagnostic-functions)
(flymake-diagnostic-types-alist): Rework docstring.
(flymake--highlight-line): Set and use flymake-text property in overlay.
(flymake-goto-next-error, flymake-goto-prev-error): Fix funny quotes.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/progmodes/flymake.el | 41 |
1 files changed, 21 insertions, 20 deletions
diff --git a/lisp/progmodes/flymake.el b/lisp/progmodes/flymake.el index fa0c756ae30..c52dad722ce 100644 --- a/lisp/progmodes/flymake.el +++ b/lisp/progmodes/flymake.el | |||
| @@ -322,12 +322,12 @@ region is invalid." | |||
| 322 | (defvar flymake-diagnostic-functions nil | 322 | (defvar flymake-diagnostic-functions nil |
| 323 | "Special hook of Flymake backends that check a buffer. | 323 | "Special hook of Flymake backends that check a buffer. |
| 324 | 324 | ||
| 325 | The functions in this hook diagnose problems in a buffer’s | 325 | The functions in this hook diagnose problems in a buffer's |
| 326 | contents and provide information to the Flymake user interface | 326 | contents and provide information to the Flymake user interface |
| 327 | about where and how to annotate problems diagnosed in a buffer. | 327 | about where and how to annotate problems diagnosed in a buffer. |
| 328 | 328 | ||
| 329 | Whenever Flymake or the user decides to re-check the buffer, each | 329 | Each backend function must be prepared to accept an arbitrary |
| 330 | function is called with an arbitrary number of arguments: | 330 | number of arguments: |
| 331 | 331 | ||
| 332 | * the first argument is always REPORT-FN, a callback function | 332 | * the first argument is always REPORT-FN, a callback function |
| 333 | detailed below; | 333 | detailed below; |
| @@ -337,11 +337,12 @@ function is called with an arbitrary number of arguments: | |||
| 337 | no such arguments, but backend functions must be prepared to | 337 | no such arguments, but backend functions must be prepared to |
| 338 | accept and possibly ignore any number of them. | 338 | accept and possibly ignore any number of them. |
| 339 | 339 | ||
| 340 | Backend functions are expected to initiate the buffer check, but | 340 | Whenever Flymake or the user decides to re-check the buffer, |
| 341 | aren't required to complete it check before exiting: if the | 341 | backend functions are called as detailed above and are expected |
| 342 | computation involved is expensive, especially for large buffers, | 342 | to initiate this check, but aren't required to complete it before |
| 343 | that task can be scheduled for the future using asynchronous | 343 | exiting: if the computation involved is expensive, especially for |
| 344 | processes or other asynchronous mechanisms. | 344 | large buffers, that task can be scheduled for the future using |
| 345 | asynchronous processes or other asynchronous mechanisms. | ||
| 345 | 346 | ||
| 346 | In any case, backend functions are expected to return quickly or | 347 | In any case, backend functions are expected to return quickly or |
| 347 | signal an error, in which case the backend is disabled. Flymake | 348 | signal an error, in which case the backend is disabled. Flymake |
| @@ -375,10 +376,10 @@ Currently accepted values for REPORT-ACTION are: | |||
| 375 | 376 | ||
| 376 | Currently accepted REPORT-KEY arguments are: | 377 | Currently accepted REPORT-KEY arguments are: |
| 377 | 378 | ||
| 378 | * ‘:explanation’: value should give user-readable details of | 379 | * `:explanation' value should give user-readable details of |
| 379 | the situation encountered, if any. | 380 | the situation encountered, if any. |
| 380 | 381 | ||
| 381 | * ‘:force’: value should be a boolean suggesting that Flymake | 382 | * `:force': value should be a boolean suggesting that Flymake |
| 382 | consider the report even if it was somehow unexpected.") | 383 | consider the report even if it was somehow unexpected.") |
| 383 | 384 | ||
| 384 | (defvar flymake-diagnostic-types-alist | 385 | (defvar flymake-diagnostic-types-alist |
| @@ -407,12 +408,12 @@ properties are: | |||
| 407 | 408 | ||
| 408 | * `severity', a non-negative integer specifying the diagnostic's | 409 | * `severity', a non-negative integer specifying the diagnostic's |
| 409 | severity. The higher, the more serious. If the overlay | 410 | severity. The higher, the more serious. If the overlay |
| 410 | priority `priority' is not specified, `severity' is used to set | 411 | property `priority' is not specified, `severity' is used to set |
| 411 | it and help sort overlapping overlays. | 412 | it and help sort overlapping overlays. |
| 412 | 413 | ||
| 413 | * `flymake-category', a symbol whose property list is considered | 414 | * `flymake-category', a symbol whose property list is considered |
| 414 | as a default for missing values of any other properties. This | 415 | a default for missing values of any other properties. This is |
| 415 | is useful to backend authors when creating new diagnostic types | 416 | useful to backend authors when creating new diagnostic types |
| 416 | that differ from an existing type by only a few properties.") | 417 | that differ from an existing type by only a few properties.") |
| 417 | 418 | ||
| 418 | (put 'flymake-error 'face 'flymake-error) | 419 | (put 'flymake-error 'face 'flymake-error) |
| @@ -497,8 +498,7 @@ associated `flymake-category' return DEFAULT." | |||
| 497 | (lambda (_window _ov pos) | 498 | (lambda (_window _ov pos) |
| 498 | (mapconcat | 499 | (mapconcat |
| 499 | (lambda (ov) | 500 | (lambda (ov) |
| 500 | (let ((diag (overlay-get ov 'flymake--diagnostic))) | 501 | (overlay-get ov 'flymake-text)) |
| 501 | (flymake--diag-text diag))) | ||
| 502 | (flymake--overlays :beg pos) | 502 | (flymake--overlays :beg pos) |
| 503 | "\n"))) | 503 | "\n"))) |
| 504 | (default-maybe 'severity (warning-numeric-level :error)) | 504 | (default-maybe 'severity (warning-numeric-level :error)) |
| @@ -507,6 +507,7 @@ associated `flymake-category' return DEFAULT." | |||
| 507 | ;; | 507 | ;; |
| 508 | (overlay-put ov 'evaporate t) | 508 | (overlay-put ov 'evaporate t) |
| 509 | (overlay-put ov 'flymake t) | 509 | (overlay-put ov 'flymake t) |
| 510 | (overlay-put ov 'flymake-text (flymake--diag-text diagnostic)) | ||
| 510 | (overlay-put ov 'flymake--diagnostic diagnostic))) | 511 | (overlay-put ov 'flymake--diagnostic diagnostic))) |
| 511 | 512 | ||
| 512 | ;; Nothing in Flymake uses this at all any more, so this is just for | 513 | ;; Nothing in Flymake uses this at all any more, so this is just for |
| @@ -715,7 +716,7 @@ Interactively, with a prefix arg, FORCE is t." | |||
| 715 | (remove-hook 'post-command-hook #'start-post-command | 716 | (remove-hook 'post-command-hook #'start-post-command |
| 716 | nil) | 717 | nil) |
| 717 | (with-current-buffer buffer | 718 | (with-current-buffer buffer |
| 718 | (flymake-start (remove 'post-command deferred) force))) | 719 | (flymake-start (remove 'post-command deferred) force))) |
| 719 | (start-on-display | 720 | (start-on-display |
| 720 | () | 721 | () |
| 721 | (remove-hook 'window-configuration-change-hook #'start-on-display | 722 | (remove-hook 'window-configuration-change-hook #'start-on-display |
| @@ -873,9 +874,9 @@ Do it only if `flymake-no-changes-timeout' is non-nil." | |||
| 873 | (defun flymake-goto-next-error (&optional n filter interactive) | 874 | (defun flymake-goto-next-error (&optional n filter interactive) |
| 874 | "Go to Nth next Flymake error in buffer matching FILTER. | 875 | "Go to Nth next Flymake error in buffer matching FILTER. |
| 875 | Interactively, always move to the next error. With a prefix arg, | 876 | Interactively, always move to the next error. With a prefix arg, |
| 876 | skip any diagnostics with a severity less than ‘:warning’. | 877 | skip any diagnostics with a severity less than `:warning'. |
| 877 | 878 | ||
| 878 | If ‘flymake-wrap-around’ is non-nil and no more next errors, | 879 | If `flymake-wrap-around' is non-nil and no more next errors, |
| 879 | resumes search from top. | 880 | resumes search from top. |
| 880 | 881 | ||
| 881 | FILTER is a list of diagnostic types found in | 882 | FILTER is a list of diagnostic types found in |
| @@ -928,9 +929,9 @@ applied." | |||
| 928 | (defun flymake-goto-prev-error (&optional n filter interactive) | 929 | (defun flymake-goto-prev-error (&optional n filter interactive) |
| 929 | "Go to Nth previous Flymake error in buffer matching FILTER. | 930 | "Go to Nth previous Flymake error in buffer matching FILTER. |
| 930 | Interactively, always move to the previous error. With a prefix | 931 | Interactively, always move to the previous error. With a prefix |
| 931 | arg, skip any diagnostics with a severity less than ‘:warning’. | 932 | arg, skip any diagnostics with a severity less than `:warning'. |
| 932 | 933 | ||
| 933 | If ‘flymake-wrap-around’ is non-nil and no more previous errors, | 934 | If `flymake-wrap-around' is non-nil and no more previous errors, |
| 934 | resumes search from bottom. | 935 | resumes search from bottom. |
| 935 | 936 | ||
| 936 | FILTER is a list of diagnostic types found in | 937 | FILTER is a list of diagnostic types found in |