diff options
| author | João Távora | 2018-06-05 15:13:02 +0100 |
|---|---|---|
| committer | João Távora | 2018-06-05 15:22:16 +0100 |
| commit | fa794d1b603e52e2a80d69c5610b782904ee6a69 (patch) | |
| tree | e6dbf1d0ac1460488235e7785bf392caf472404c | |
| parent | aadac04923c9ae47f0bccc706857b94166c9d355 (diff) | |
| download | emacs-fa794d1b603e52e2a80d69c5610b782904ee6a69.tar.gz emacs-fa794d1b603e52e2a80d69c5610b782904ee6a69.zip | |
Obsolete Flymake's flymake-diagnostic-types-alist
That varaiable was an association between symbols and properties,
effecively duplicating symbol's property lists. It is simpler to just
put properties on symbols. Backward compatibility to the old variable
has been kept.
* doc/misc/flymake.texi (Flymake error types): Don't mention
flymake-diagnostic-types-alist.
(Flymake error types): Rework section.
(Backend functions): Refill a paragraph.
(Flymake utility functions): Don't mention
flymake-diagnostic-types-alist.
(Proc customization variables): Don't mention
flymake-diagnostic-types-alist.
* etc/NEWS: Mention obsoletion of flymake-diagnostic-types-alist.
* lisp/progmodes/flymake-proc.el
(flymake-proc--diagnostics-for-pattern): Don't use
flymake-diagnostic-types-alist.
* lisp/progmodes/flymake.el: Rewrite commentary.
(flymake-make-diagnostic, flymake-mode, flymake-goto-next-error)
(flymake-goto-prev-error): Don't mention
flymake-diagnostic-types-alist in docstring.
(flymake-diagnostic-types-alist): Make obsolete.
(:error, :warning, :note): Put flymake-category in these symbols.
(flymake-error, flymake-warning, flymake-note): Put
`flymake-bitmap', not `bitmap' in these symbols.
(flymake--lookup-type-property, flymake--highlight-line): Rewrite.
Honor flymake-diagnostic-types-alist for backward
compatibility.
* lisp/progmodes/python.el (python-flymake-msg-alist): Don't
mention flymake-diagnostic-types-alist.
| -rw-r--r-- | doc/misc/flymake.texi | 150 | ||||
| -rw-r--r-- | etc/NEWS | 7 | ||||
| -rw-r--r-- | lisp/progmodes/flymake-proc.el | 13 | ||||
| -rw-r--r-- | lisp/progmodes/flymake.el | 223 | ||||
| -rw-r--r-- | lisp/progmodes/python.el | 7 |
5 files changed, 228 insertions, 172 deletions
diff --git a/doc/misc/flymake.texi b/doc/misc/flymake.texi index 9260f4f22ba..e7f4da75bb9 100644 --- a/doc/misc/flymake.texi +++ b/doc/misc/flymake.texi | |||
| @@ -275,54 +275,61 @@ The following sections discuss each approach in detail. | |||
| 275 | @cindex customizing error types | 275 | @cindex customizing error types |
| 276 | @cindex error types, customization | 276 | @cindex error types, customization |
| 277 | 277 | ||
| 278 | @vindex flymake-diagnostic-types-alist | 278 | To customize the appearance of error types, set properties on the |
| 279 | The variable @code{flymake-diagnostic-types-alist} is looked up by | 279 | symbols associated with each diagnostic type. The standard diagnostic |
| 280 | Flymake every time an annotation for a diagnostic is created in the | 280 | symbols are @code{:error}, @code{:warning} and @code{:note} (though |
| 281 | buffer. Specifically, this variable holds a table of correspondence | 281 | the backend may define more, @pxref{Backend functions}). |
| 282 | between symbols designating diagnostic types and an additional | 282 | |
| 283 | sub-table of properties pertaining to each diagnostic type. | 283 | The following properties can be set: |
| 284 | |||
| 285 | Both tables are laid out in association list (@pxref{Association | ||
| 286 | Lists,,, elisp, The Emacs Lisp Reference Manual}) format, and thus can | ||
| 287 | be conveniently accessed with the functions of the @code{assoc} | ||
| 288 | family. | ||
| 289 | |||
| 290 | You can use any symbol-value association in the properties sub-table, | ||
| 291 | but some symbols have special meaning as to where and how Flymake | ||
| 292 | presents the diagnostic: | ||
| 293 | 284 | ||
| 294 | @itemize | 285 | @itemize |
| 295 | 286 | ||
| 296 | @item | 287 | @item |
| 297 | @cindex bitmap of diagnostic | 288 | @cindex bitmap of diagnostic |
| 298 | @code{bitmap}, an image displayed in the fringe according to | 289 | @code{flymake-bitmap}, an image displayed in the fringe according to |
| 299 | @code{flymake-fringe-indicator-position}. The value actually follows | 290 | @code{flymake-fringe-indicator-position}. The value actually follows |
| 300 | the syntax of @code{flymake-error-bitmap} (@pxref{Customizable | 291 | the syntax of @code{flymake-error-bitmap} (@pxref{Customizable |
| 301 | variables}). It is overridden by any @code{before-string} overlay | 292 | variables}). It is overridden by any @code{before-string} overlay |
| 302 | property. | 293 | property. |
| 303 | 294 | ||
| 304 | @item | 295 | @item |
| 305 | @cindex severity of diagnostic | 296 | @code{flymake-overlay-control}, an alist ((@var{OVPROP} . @var{VALUE}) |
| 306 | @code{severity} is a non-negative integer specifying the diagnostic's | 297 | @var{...}) of further properties used to affect the appearance of |
| 307 | severity. The higher the value, the more serious is the error. If | 298 | Flymake annotations. With the exception of @code{category} and |
| 308 | the overlay property @code{priority} is not specified, @code{severity} | 299 | @code{evaporate}, these properties are applied directly to the created |
| 309 | is used to set it and help sort overlapping overlays. | 300 | overlay (@pxref{Overlay Properties,,, elisp, The Emacs Lisp Reference |
| 301 | Manual}). | ||
| 310 | 302 | ||
| 311 | @item | 303 | As an example, here's how to make diagnostics of the type @code{:note} |
| 312 | Every property pertaining to overlays (@pxref{Overlay Properties,,, | 304 | stand out more prominently: |
| 313 | elisp, The Emacs Lisp Reference Manual}), except @code{category} and | ||
| 314 | @code{evaporate}. These properties are used to affect the appearance | ||
| 315 | of Flymake annotations. | ||
| 316 | 305 | ||
| 317 | As an example, here's how to make errors (diagnostics of the type | 306 | @example |
| 318 | @code{:error}) stand out even more prominently in the buffer, by | 307 | (push '(face . highlight) (get :note 'flymake-overlay-control)) |
| 319 | raising the characters using a @code{display} overlay property. | 308 | @end example |
| 309 | |||
| 310 | If you push another alist entry in front, it overrides the previous | ||
| 311 | one. So this effectively removes the face from @code{:note} | ||
| 312 | diagnostics: | ||
| 320 | 313 | ||
| 321 | @example | 314 | @example |
| 322 | (push '(display . (raise 1.2)) | 315 | (push '(face . nil) (get :note 'flymake-overlay-control)) |
| 323 | (cdr (assoc :error flymake-diagnostic-types-alist))) | ||
| 324 | @end example | 316 | @end example |
| 325 | 317 | ||
| 318 | To restore the original look for @code{:note} types, empty or remove | ||
| 319 | its @code{flymake-overlay-control} property: | ||
| 320 | |||
| 321 | @example | ||
| 322 | (put :note 'flymake-overlay-control '()) | ||
| 323 | @end example | ||
| 324 | |||
| 325 | @item | ||
| 326 | @cindex severity of diagnostic | ||
| 327 | @code{flymake-severity} is a non-negative integer specifying the | ||
| 328 | diagnostic's severity. The higher the value, the more serious is the | ||
| 329 | error. If the overlay property @code{priority} is not specified in | ||
| 330 | @code{flymake-overlay-control}, @code{flymake-severity} is used to set | ||
| 331 | it and help sort overlapping overlays. | ||
| 332 | |||
| 326 | @item | 333 | @item |
| 327 | @vindex flymake-category | 334 | @vindex flymake-category |
| 328 | @code{flymake-category} is a symbol whose property list is considered | 335 | @code{flymake-category} is a symbol whose property list is considered |
| @@ -333,32 +340,29 @@ the default for missing values of any other properties. | |||
| 333 | @vindex flymake-error | 340 | @vindex flymake-error |
| 334 | @vindex flymake-warning | 341 | @vindex flymake-warning |
| 335 | @vindex flymake-note | 342 | @vindex flymake-note |
| 336 | Three default diagnostic types, @code{:error}, @code{:warning} and | 343 | Three default diagnostic types are predefined: @code{:error}, |
| 337 | @code{:note} are predefined in | 344 | @code{:warning}, and @code{:note}. By default, each one of them has a |
| 338 | @code{flymake-diagnostic-types-alist}. By default each lists a single | ||
| 339 | @code{flymake-category} property whose value is, respectively, the | 345 | @code{flymake-category} property whose value is, respectively, the |
| 340 | symbols @code{flymake-error}, @code{flymake-warning} and | 346 | category symbol @code{flymake-error}, @code{flymake-warning} and |
| 341 | @code{flymake-note}. | 347 | @code{flymake-note}. |
| 342 | 348 | ||
| 343 | These category symbols' plists is where the values of customizable | 349 | These category symbols' plist is where the values of customizable |
| 344 | variables and faces such as @code{flymake-error-bitmap} are found. | 350 | variables and faces (such as @code{flymake-error-bitmap}) are found. |
| 345 | Thus, if you change their plists, Flymake may stop honoring these | 351 | Thus, if you change their plists, Flymake may stop honoring these user |
| 346 | user customizations. | 352 | customizations. |
| 347 | 353 | ||
| 348 | The @code{flymake-category} special property is also especially useful | 354 | The @code{flymake-category} special property is especially useful for |
| 349 | for backends which create diagnostics objects with non-default | 355 | backends which create diagnostics objects with non-default types that |
| 350 | types that differ from an existing type by only a few properties | 356 | differ from an existing type by only a few properties (@pxref{Flymake |
| 351 | (@pxref{Flymake utility functions}). | 357 | utility functions}). |
| 352 | 358 | ||
| 353 | As an example, consider configuring a new diagnostic type | 359 | As an example, consider configuring a new diagnostic type |
| 354 | @code{:low-priority-note} that behaves much like the @code{:note} | 360 | @code{:low-priority-note} that behaves much like @code{:note}, but |
| 355 | priority but without an overlay face. | 361 | without an overlay face. |
| 356 | 362 | ||
| 357 | @example | 363 | @example |
| 358 | (add-to-list | 364 | (put :low-priority-note 'flymake-overlay-control '((face . nil))) |
| 359 | 'flymake-diagnostic-types-alist | 365 | (put :low-priority-note 'flymake-category 'flymake-note) |
| 360 | `(:low-priority-note . ((face . nil) | ||
| 361 | (flymake-category . flymake-note)))) | ||
| 362 | @end example | 366 | @end example |
| 363 | 367 | ||
| 364 | @vindex flymake-diagnostics | 368 | @vindex flymake-diagnostics |
| @@ -389,20 +393,17 @@ Internet search for the text of a @code{:warning} or @code{:error}. | |||
| 389 | (eww-browse-url | 393 | (eww-browse-url |
| 390 | (concat | 394 | (concat |
| 391 | "https://duckduckgo.com/?q=" | 395 | "https://duckduckgo.com/?q=" |
| 392 | (replace-regexp-in-string " " | 396 | (replace-regexp-in-string |
| 393 | "+" | 397 | " " "+" (flymake-diagnostic-text topmost-diag))) |
| 394 | (flymake-diagnostic-text topmost-diag))) | ||
| 395 | t))) | 398 | t))) |
| 396 | 399 | ||
| 397 | (dolist (type '(:warning :error)) | 400 | (dolist (type '(:warning :error)) |
| 398 | (let ((a (assoc type flymake-diagnostic-types-alist))) | 401 | (push '(mouse-face . highlight) (get type 'flymake-overlay-control)) |
| 399 | (setf (cdr a) | 402 | (push `(keymap . ,(let ((map (make-sparse-keymap))) |
| 400 | (append `((mouse-face . highlight) | 403 | (define-key map [mouse-2] |
| 401 | (keymap . ,(let ((map (make-sparse-keymap))) | 404 | 'my-search-for-message) |
| 402 | (define-key map [mouse-2] | 405 | map)) |
| 403 | 'my-search-for-message) | 406 | (get type 'flymake-overlay-control))) |
| 404 | map))) | ||
| 405 | (cdr a))))) | ||
| 406 | @end example | 407 | @end example |
| 407 | 408 | ||
| 408 | @node Backend functions | 409 | @node Backend functions |
| @@ -436,10 +437,10 @@ the first argument is always @var{report-fn}, a callback function | |||
| 436 | detailed below; | 437 | detailed below; |
| 437 | 438 | ||
| 438 | @item | 439 | @item |
| 439 | the remaining arguments are keyword-value pairs of the | 440 | the remaining arguments are keyword-value pairs of the form |
| 440 | form @w{@code{(@var{:key} @var{value} @var{:key2} @var{value2}...)}}. Currently, | 441 | @w{@code{(@var{:key} @var{value} @var{:key2} @var{value2}...)}}. |
| 441 | Flymake provides no such arguments, but backend functions must be | 442 | Currently, Flymake provides no such arguments, but backend functions |
| 442 | prepared to accept (and possibly ignore) any number of them. | 443 | must be prepared to accept (and possibly ignore) any number of them. |
| 443 | @end itemize | 444 | @end itemize |
| 444 | 445 | ||
| 445 | Whenever Flymake or the user decide to re-check the buffer, backend | 446 | Whenever Flymake or the user decide to re-check the buffer, backend |
| @@ -512,9 +513,9 @@ by calling the function @code{flymake-make-diagnostic}. | |||
| 512 | 513 | ||
| 513 | @deffn Function flymake-make-diagnostic buffer beg end type text | 514 | @deffn Function flymake-make-diagnostic buffer beg end type text |
| 514 | Make a Flymake diagnostic for @var{buffer}'s region from @var{beg} to | 515 | Make a Flymake diagnostic for @var{buffer}'s region from @var{beg} to |
| 515 | @var{end}. @var{type} is a key to | 516 | @var{end}. @var{type} is a diagnostic symbol (@pxref{Flymake error |
| 516 | @code{flymake-diagnostic-types-alist} and @var{text} is a description | 517 | types}), and @var{text} is a description of the problem detected in |
| 517 | of the problem detected in this region. | 518 | this region. |
| 518 | @end deffn | 519 | @end deffn |
| 519 | 520 | ||
| 520 | @cindex access diagnostic object | 521 | @cindex access diagnostic object |
| @@ -715,14 +716,13 @@ Patterns for error/warning messages in the form @code{(regexp file-idx | |||
| 715 | line-idx col-idx err-text-idx)}. @xref{Parsing the output}. | 716 | line-idx col-idx err-text-idx)}. @xref{Parsing the output}. |
| 716 | 717 | ||
| 717 | @item flymake-proc-diagnostic-type-pred | 718 | @item flymake-proc-diagnostic-type-pred |
| 718 | A function to classify a diagnostic text as particular type of | 719 | A function to classify a diagnostic text as particular type of error. |
| 719 | error. Should be a function taking an error text and returning one of | 720 | Should be a function taking an error text and returning a diagnostic |
| 720 | the symbols indexing @code{flymake-diagnostic-types-alist}. If non-nil | 721 | symbol (@pxref{Flymake error types}). If non-nil is returned but |
| 721 | is returned but there is no such symbol in that table, a warning is | 722 | there is no such symbol in that table, a warning is assumed. If nil |
| 722 | assumed. If nil is returned, an error is assumed. Can also be a | 723 | is returned, an error is assumed. Can also be a regular expression |
| 723 | regular expression that should match only warnings. This variable | 724 | that should match only warnings. This variable replaces the old |
| 724 | replaces the old @code{flymake-warning-re} and | 725 | @code{flymake-warning-re} and @code{flymake-warning-predicate}. |
| 725 | @code{flymake-warning-predicate}. | ||
| 726 | 726 | ||
| 727 | @item flymake-proc-compilation-prevents-syntax-check | 727 | @item flymake-proc-compilation-prevents-syntax-check |
| 728 | A flag indicating whether compilation and syntax check of the same | 728 | A flag indicating whether compilation and syntax check of the same |
| @@ -176,6 +176,13 @@ interface that's more like functions like @code{search-forward}. | |||
| 176 | It now treats the optional 2nd argument to mean that the URL should be | 176 | It now treats the optional 2nd argument to mean that the URL should be |
| 177 | shown in the currently selected window. | 177 | shown in the currently selected window. |
| 178 | 178 | ||
| 179 | ** Flymake | ||
| 180 | |||
| 181 | +++ | ||
| 182 | *** The variable 'flymake-diagnostic-types-alist' is obsolete | ||
| 183 | You should instead set properties on known diagnostic symbols, like | ||
| 184 | ':error' and ':warning', as demonstrated in the Flymake manual. | ||
| 185 | |||
| 179 | ** Package | 186 | ** Package |
| 180 | *** New 'package-quickstart' feature | 187 | *** New 'package-quickstart' feature |
| 181 | When 'package-quickstart' is non-nil, package.el precomputes a big autoloads | 188 | When 'package-quickstart' is non-nil, package.el precomputes a big autoloads |
diff --git a/lisp/progmodes/flymake-proc.el b/lisp/progmodes/flymake-proc.el index e38e4a75d45..8600be9b97c 100644 --- a/lisp/progmodes/flymake-proc.el +++ b/lisp/progmodes/flymake-proc.el | |||
| @@ -196,11 +196,10 @@ from compile.el") | |||
| 196 | 'flymake-proc-default-guess | 196 | 'flymake-proc-default-guess |
| 197 | "Predicate matching against diagnostic text to detect its type. | 197 | "Predicate matching against diagnostic text to detect its type. |
| 198 | Takes a single argument, the diagnostic's text and should return | 198 | Takes a single argument, the diagnostic's text and should return |
| 199 | a value suitable for indexing | 199 | a diagnostic symbol naming a type. If the returned value is nil, |
| 200 | `flymake-diagnostic-types-alist' (which see). If the returned | 200 | a type of `:error' is assumed. For some backward compatibility, |
| 201 | value is nil, a type of `:error' is assumed. For some backward | 201 | if a non-nil value is returned that doesn't name a type, |
| 202 | compatibility, if a non-nil value is returned that doesn't | 202 | `:warning' is assumed. |
| 203 | index that alist, a type of `:warning' is assumed. | ||
| 204 | 203 | ||
| 205 | Instead of a function, it can also be a string, a regular | 204 | Instead of a function, it can also be a string, a regular |
| 206 | expression. A match indicates `:warning' type, otherwise | 205 | expression. A match indicates `:warning' type, otherwise |
| @@ -516,8 +515,8 @@ Create parent directories as needed." | |||
| 516 | :error)) | 515 | :error)) |
| 517 | ((functionp pred) | 516 | ((functionp pred) |
| 518 | (let ((probe (funcall pred message))) | 517 | (let ((probe (funcall pred message))) |
| 519 | (cond ((assoc-default probe | 518 | (cond ((and (symbolp probe) |
| 520 | flymake-diagnostic-types-alist) | 519 | (get probe 'flymake-category)) |
| 521 | probe) | 520 | probe) |
| 522 | (probe | 521 | (probe |
| 523 | :warning) | 522 | :warning) |
diff --git a/lisp/progmodes/flymake.el b/lisp/progmodes/flymake.el index ec933ad16ba..27bf1bd17a9 100644 --- a/lisp/progmodes/flymake.el +++ b/lisp/progmodes/flymake.el | |||
| @@ -34,13 +34,77 @@ | |||
| 34 | ;; results produced by these backends, as well as entry points for | 34 | ;; results produced by these backends, as well as entry points for |
| 35 | ;; backends to hook on to. | 35 | ;; backends to hook on to. |
| 36 | ;; | 36 | ;; |
| 37 | ;; The main entry points are `flymake-mode' and `flymake-start' | 37 | ;; The main interactive entry point is the `flymake-mode' minor mode, |
| 38 | ;; which periodically and automatically initiates checks as the user | ||
| 39 | ;; is editing the buffer. The variables `flymake-no-changes-timeout', | ||
| 40 | ;; `flymake-start-syntax-check-on-newline' and | ||
| 41 | ;; `flymake-start-on-flymake-mode' give finer control over the events | ||
| 42 | ;; triggering a check, as does the interactive command | ||
| 43 | ;; `flymake-start', which immediately starts a check. | ||
| 38 | ;; | 44 | ;; |
| 39 | ;; The docstrings of these variables are relevant to understanding how | 45 | ;; Shortly after each check, a summary of collected diagnostics should |
| 40 | ;; Flymake works for both the user and the backend programmer: | 46 | ;; appear in the mode-line. If it doesn't, there might not be a |
| 47 | ;; suitable Flymake backend for the current buffer's major mode, in | ||
| 48 | ;; which case Flymake will indicate this in the mode-line. The | ||
| 49 | ;; indicator will be `!' (exclamation mark), if all the configured | ||
| 50 | ;; backends errored (or decided to disable themselves) and `?' | ||
| 51 | ;; (question mark) if no backends were even configured. | ||
| 41 | ;; | 52 | ;; |
| 42 | ;; * `flymake-diagnostic-functions' | 53 | ;; For programmers interested in writing a new Flymake backend, the |
| 43 | ;; * `flymake-diagnostic-types-alist' | 54 | ;; docstring of `flymake-diagnostic-functions', the Flymake manual, |
| 55 | ;; and the code of existing backends are probably a good starting | ||
| 56 | ;; point. | ||
| 57 | ;; | ||
| 58 | ;; The user wishing to customize the appearance of error types should | ||
| 59 | ;; set properties on the symbols associated with each diagnostic type. | ||
| 60 | ;; The standard diagnostic symbols are `:error', `:warning' and | ||
| 61 | ;; `:note' (though a specific backend may define and use more). The | ||
| 62 | ;; following properties can be set: | ||
| 63 | ;; | ||
| 64 | ;; * `flymake-bitmap', an image displayed in the fringe according to | ||
| 65 | ;; `flymake-fringe-indicator-position'. The value actually follows | ||
| 66 | ;; the syntax of `flymake-error-bitmap' (which see). It is overridden | ||
| 67 | ;; by any `before-string' overlay property. | ||
| 68 | ;; | ||
| 69 | ;; * `flymake-severity', a non-negative integer specifying the | ||
| 70 | ;; diagnostic's severity. The higher, the more serious. If the | ||
| 71 | ;; overlay property `priority' is not specified, `severity' is used to | ||
| 72 | ;; set it and help sort overlapping overlays. | ||
| 73 | ;; | ||
| 74 | ;; * `flymake-overlay-control', an alist ((OVPROP . VALUE) ...) of | ||
| 75 | ;; further properties used to affect the appearance of Flymake | ||
| 76 | ;; annotations. With the exception of `category' and `evaporate', | ||
| 77 | ;; these properties are applied directly to the created overlay. See | ||
| 78 | ;; Info Node `(elisp)Overlay Properties'. | ||
| 79 | ;; | ||
| 80 | ;; * `flymake-category', a symbol whose property list is considered a | ||
| 81 | ;; default for missing values of any other properties. This is useful | ||
| 82 | ;; to backend authors when creating new diagnostic types that differ | ||
| 83 | ;; from an existing type by only a few properties. The category | ||
| 84 | ;; symbols `flymake-error', `flymake-warning' and `flymake-note' make | ||
| 85 | ;; good candidates for values of this property. | ||
| 86 | ;; | ||
| 87 | ;; For instance, to omit the fringe bitmap displayed for the standard | ||
| 88 | ;; `:note' type, set its `flymake-bitmap' property to nil: | ||
| 89 | ;; | ||
| 90 | ;; (put :note 'flymake-bitmap nil) | ||
| 91 | ;; | ||
| 92 | ;; To change the face for `:note' type, add a `face' entry to its | ||
| 93 | ;; `flymake-overlay-control' property. | ||
| 94 | ;; | ||
| 95 | ;; (push '(face . highlight) (get :note 'flymake-overlay-control)) | ||
| 96 | ;; | ||
| 97 | ;; If you push another alist entry in front, it overrides the previous | ||
| 98 | ;; one. So this effectively removes the face from `:note' | ||
| 99 | ;; diagnostics. | ||
| 100 | ;; | ||
| 101 | ;; (push '(face . nil) (get :note 'flymake-overlay-control)) | ||
| 102 | ;; | ||
| 103 | ;; To erase customizations and go back to the original look for | ||
| 104 | ;; `:note' types: | ||
| 105 | ;; | ||
| 106 | ;; (cl-remf (symbol-plist :note) 'flymake-overlay-control) | ||
| 107 | ;; (cl-remf (symbol-plist :note) 'flymake-bitmap) | ||
| 44 | ;; | 108 | ;; |
| 45 | ;;; Code: | 109 | ;;; Code: |
| 46 | 110 | ||
| @@ -232,10 +296,9 @@ generated it." | |||
| 232 | text | 296 | text |
| 233 | &optional data) | 297 | &optional data) |
| 234 | "Make a Flymake diagnostic for BUFFER's region from BEG to END. | 298 | "Make a Flymake diagnostic for BUFFER's region from BEG to END. |
| 235 | TYPE is a key to `flymake-diagnostic-types-alist' and TEXT is a | 299 | TYPE is a key to symbol and TEXT is a description of the problem |
| 236 | description of the problem detected in this region. DATA is any | 300 | detected in this region. DATA is any object that the caller |
| 237 | object that the caller wishes to attach to the created diagnostic | 301 | wishes to attach to the created diagnostic for later retrieval." |
| 238 | for later retrieval." | ||
| 239 | (flymake--diag-make :buffer buffer :beg beg :end end | 302 | (flymake--diag-make :buffer buffer :beg beg :end end |
| 240 | :type type :text text :data data)) | 303 | :type type :text text :data data)) |
| 241 | 304 | ||
| @@ -426,74 +489,56 @@ Currently accepted REPORT-KEY arguments are: | |||
| 426 | 489 | ||
| 427 | (put 'flymake-diagnostic-functions 'safe-local-variable #'null) | 490 | (put 'flymake-diagnostic-functions 'safe-local-variable #'null) |
| 428 | 491 | ||
| 429 | (defvar flymake-diagnostic-types-alist | 492 | (put :error 'flymake-category 'flymake-error) |
| 430 | `((:error | 493 | (put :warning 'flymake-category 'flymake-warning) |
| 431 | . ((flymake-category . flymake-error))) | 494 | (put :note 'flymake-category 'flymake-note) |
| 432 | (:warning | 495 | |
| 433 | . ((flymake-category . flymake-warning))) | 496 | (defvar flymake-diagnostic-types-alist `() "") |
| 434 | (:note | 497 | (make-obsolete-variable |
| 435 | . ((flymake-category . flymake-note)))) | 498 | 'flymake-diagnostic-types-alist |
| 436 | "Alist ((KEY . PROPS)*) of properties of Flymake diagnostic types. | 499 | "Set properties on the diagnostic symbols instead. See Info |
| 437 | KEY designates a kind of diagnostic can be anything passed as | 500 | Node `(Flymake)Flymake error types'" |
| 438 | `:type' to `flymake-make-diagnostic'. | 501 | "27.1") |
| 439 | |||
| 440 | PROPS is an alist of properties that are applied, in order, to | ||
| 441 | the diagnostics of the type designated by KEY. The recognized | ||
| 442 | properties are: | ||
| 443 | |||
| 444 | * Every property pertaining to overlays, except `category' and | ||
| 445 | `evaporate' (see Info Node `(elisp)Overlay Properties'), used | ||
| 446 | to affect the appearance of Flymake annotations. | ||
| 447 | |||
| 448 | * `bitmap', an image displayed in the fringe according to | ||
| 449 | `flymake-fringe-indicator-position'. The value actually | ||
| 450 | follows the syntax of `flymake-error-bitmap' (which see). It | ||
| 451 | is overridden by any `before-string' overlay property. | ||
| 452 | |||
| 453 | * `severity', a non-negative integer specifying the diagnostic's | ||
| 454 | severity. The higher, the more serious. If the overlay | ||
| 455 | property `priority' is not specified, `severity' is used to set | ||
| 456 | it and help sort overlapping overlays. | ||
| 457 | |||
| 458 | * `flymake-category', a symbol whose property list is considered | ||
| 459 | a default for missing values of any other properties. This is | ||
| 460 | useful to backend authors when creating new diagnostic types | ||
| 461 | that differ from an existing type by only a few properties.") | ||
| 462 | 502 | ||
| 463 | (put 'flymake-error 'face 'flymake-error) | 503 | (put 'flymake-error 'face 'flymake-error) |
| 464 | (put 'flymake-error 'bitmap 'flymake-error-bitmap) | 504 | (put 'flymake-error 'flymake-bitmap 'flymake-error-bitmap) |
| 465 | (put 'flymake-error 'severity (warning-numeric-level :error)) | 505 | (put 'flymake-error 'severity (warning-numeric-level :error)) |
| 466 | (put 'flymake-error 'mode-line-face 'compilation-error) | 506 | (put 'flymake-error 'mode-line-face 'compilation-error) |
| 467 | 507 | ||
| 468 | (put 'flymake-warning 'face 'flymake-warning) | 508 | (put 'flymake-warning 'face 'flymake-warning) |
| 469 | (put 'flymake-warning 'bitmap 'flymake-warning-bitmap) | 509 | (put 'flymake-warning 'flymake-bitmap 'flymake-warning-bitmap) |
| 470 | (put 'flymake-warning 'severity (warning-numeric-level :warning)) | 510 | (put 'flymake-warning 'severity (warning-numeric-level :warning)) |
| 471 | (put 'flymake-warning 'mode-line-face 'compilation-warning) | 511 | (put 'flymake-warning 'mode-line-face 'compilation-warning) |
| 472 | 512 | ||
| 473 | (put 'flymake-note 'face 'flymake-note) | 513 | (put 'flymake-note 'face 'flymake-note) |
| 474 | (put 'flymake-note 'bitmap 'flymake-note-bitmap) | 514 | (put 'flymake-note 'flymake-bitmap 'flymake-note-bitmap) |
| 475 | (put 'flymake-note 'severity (warning-numeric-level :debug)) | 515 | (put 'flymake-note 'severity (warning-numeric-level :debug)) |
| 476 | (put 'flymake-note 'mode-line-face 'compilation-info) | 516 | (put 'flymake-note 'mode-line-face 'compilation-info) |
| 477 | 517 | ||
| 478 | (defun flymake--lookup-type-property (type prop &optional default) | 518 | (defun flymake--lookup-type-property (type prop &optional default) |
| 479 | "Look up PROP for TYPE in `flymake-diagnostic-types-alist'. | 519 | "Look up PROP for diagnostic TYPE. |
| 480 | If TYPE doesn't declare PROP in either | 520 | If TYPE doesn't declare PROP in its plist or in the symbol of its |
| 481 | `flymake-diagnostic-types-alist' or in the symbol of its | ||
| 482 | associated `flymake-category' return DEFAULT." | 521 | associated `flymake-category' return DEFAULT." |
| 483 | (let ((alist-probe (assoc type flymake-diagnostic-types-alist))) | 522 | ;; This function also consults `flymake-diagnostic-types-alist' for |
| 484 | (cond (alist-probe | 523 | ;; backward compatibility. |
| 485 | (let* ((alist (cdr alist-probe)) | 524 | ;; |
| 486 | (prop-probe (assoc prop alist))) | 525 | (if (plist-member (symbol-plist type) prop) |
| 487 | (if prop-probe | 526 | ;; allow nil values to survive |
| 488 | (cdr prop-probe) | 527 | (get type prop) |
| 489 | (if-let* ((cat (assoc-default 'flymake-category alist)) | 528 | (let (alist) |
| 490 | (plist (and (symbolp cat) | 529 | (or |
| 491 | (symbol-plist cat))) | 530 | (alist-get |
| 492 | (cat-probe (plist-member plist prop))) | 531 | prop (setq |
| 493 | (cadr cat-probe) | 532 | alist |
| 494 | default)))) | 533 | (alist-get type flymake-diagnostic-types-alist))) |
| 495 | (t | 534 | (when-let* ((cat (or |
| 496 | default)))) | 535 | (get type 'flymake-category) |
| 536 | (alist-get 'flymake-category alist))) | ||
| 537 | (plist (and (symbolp cat) | ||
| 538 | (symbol-plist cat))) | ||
| 539 | (cat-probe (plist-member plist prop))) | ||
| 540 | (cadr cat-probe)) | ||
| 541 | default)))) | ||
| 497 | 542 | ||
| 498 | (defun flymake--fringe-overlay-spec (bitmap &optional recursed) | 543 | (defun flymake--fringe-overlay-spec (bitmap &optional recursed) |
| 499 | (if (and (symbolp bitmap) | 544 | (if (and (symbolp bitmap) |
| @@ -510,34 +555,38 @@ associated `flymake-category' return DEFAULT." | |||
| 510 | (list bitmap))))))) | 555 | (list bitmap))))))) |
| 511 | 556 | ||
| 512 | (defun flymake--highlight-line (diagnostic) | 557 | (defun flymake--highlight-line (diagnostic) |
| 513 | "Highlight buffer with info in DIAGNOSTIC." | 558 | "Highlight buffer with info in DIGNOSTIC." |
| 514 | (when-let* ((ov (make-overlay | 559 | (when-let* ((type (flymake--diag-type diagnostic)) |
| 560 | (ov (make-overlay | ||
| 515 | (flymake--diag-beg diagnostic) | 561 | (flymake--diag-beg diagnostic) |
| 516 | (flymake--diag-end diagnostic)))) | 562 | (flymake--diag-end diagnostic)))) |
| 517 | ;; First set `category' in the overlay, then copy over every other | 563 | ;; First set `category' in the overlay |
| 518 | ;; property. | ||
| 519 | ;; | 564 | ;; |
| 520 | (let ((alist (assoc-default (flymake--diag-type diagnostic) | 565 | (overlay-put ov 'category |
| 521 | flymake-diagnostic-types-alist))) | 566 | (flymake--lookup-type-property type 'flymake-category)) |
| 522 | (overlay-put ov 'category (assoc-default 'flymake-category alist)) | 567 | ;; Now "paint" the overlay with all the other non-category |
| 523 | (cl-loop for (k . v) in alist | 568 | ;; properties. |
| 524 | unless (eq k 'category) | 569 | (cl-loop |
| 525 | do (overlay-put ov k v))) | 570 | for (ov-prop . value) in |
| 571 | (append (reverse ; ensure ealier props override later ones | ||
| 572 | (flymake--lookup-type-property type 'flymake-overlay-control)) | ||
| 573 | (alist-get type flymake-diagnostic-types-alist)) | ||
| 574 | do (overlay-put ov ov-prop value)) | ||
| 526 | ;; Now ensure some essential defaults are set | 575 | ;; Now ensure some essential defaults are set |
| 527 | ;; | 576 | ;; |
| 528 | (cl-flet ((default-maybe | 577 | (cl-flet ((default-maybe |
| 529 | (prop value) | 578 | (prop value) |
| 530 | (unless (or (plist-member (overlay-properties ov) prop) | 579 | (unless (plist-member (overlay-properties ov) prop) |
| 531 | (let ((cat (overlay-get ov | 580 | (overlay-put ov prop (flymake--lookup-type-property |
| 532 | 'flymake-category))) | 581 | type prop value))))) |
| 533 | (and cat | ||
| 534 | (plist-member (symbol-plist cat) prop)))) | ||
| 535 | (overlay-put ov prop value)))) | ||
| 536 | (default-maybe 'bitmap 'flymake-error-bitmap) | ||
| 537 | (default-maybe 'face 'flymake-error) | 582 | (default-maybe 'face 'flymake-error) |
| 538 | (default-maybe 'before-string | 583 | (default-maybe 'before-string |
| 539 | (flymake--fringe-overlay-spec | 584 | (flymake--fringe-overlay-spec |
| 540 | (overlay-get ov 'bitmap))) | 585 | (flymake--lookup-type-property |
| 586 | type | ||
| 587 | 'flymake-bitmap | ||
| 588 | (alist-get 'bitmap (alist-get type ; backward compat | ||
| 589 | flymake-diagnostic-types-alist))))) | ||
| 541 | (default-maybe 'help-echo | 590 | (default-maybe 'help-echo |
| 542 | (lambda (window _ov pos) | 591 | (lambda (window _ov pos) |
| 543 | (with-selected-window window | 592 | (with-selected-window window |
| @@ -825,7 +874,9 @@ The commands `flymake-goto-next-error' and | |||
| 825 | diagnostics annotated in the buffer. | 874 | diagnostics annotated in the buffer. |
| 826 | 875 | ||
| 827 | The visual appearance of each type of diagnostic can be changed | 876 | The visual appearance of each type of diagnostic can be changed |
| 828 | in the variable `flymake-diagnostic-types-alist'. | 877 | by setting properties `flymake-overlay-control', `flymake-bitmap' |
| 878 | and `flymake-severity' on the symbols of diagnostic types (like | ||
| 879 | `:error', `:warning' and `:note'). | ||
| 829 | 880 | ||
| 830 | Activation or deactivation of backends used by Flymake in each | 881 | Activation or deactivation of backends used by Flymake in each |
| 831 | buffer happens via the special hook | 882 | buffer happens via the special hook |
| @@ -929,9 +980,8 @@ arg, skip any diagnostics with a severity less than `:warning'. | |||
| 929 | If `flymake-wrap-around' is non-nil and no more next diagnostics, | 980 | If `flymake-wrap-around' is non-nil and no more next diagnostics, |
| 930 | resumes search from top. | 981 | resumes search from top. |
| 931 | 982 | ||
| 932 | FILTER is a list of diagnostic types found in | 983 | FILTER is a list of diagnostic types, or nil, if no filter is to |
| 933 | `flymake-diagnostic-types-alist', or nil, if no filter is to be | 984 | be applied." |
| 934 | applied." | ||
| 935 | ;; TODO: let filter be a number, a severity below which diags are | 985 | ;; TODO: let filter be a number, a severity below which diags are |
| 936 | ;; skipped. | 986 | ;; skipped. |
| 937 | (interactive (list 1 | 987 | (interactive (list 1 |
| @@ -985,9 +1035,8 @@ prefix arg, skip any diagnostics with a severity less than | |||
| 985 | If `flymake-wrap-around' is non-nil and no more previous | 1035 | If `flymake-wrap-around' is non-nil and no more previous |
| 986 | diagnostics, resumes search from bottom. | 1036 | diagnostics, resumes search from bottom. |
| 987 | 1037 | ||
| 988 | FILTER is a list of diagnostic types found in | 1038 | FILTER is a list of diagnostic types found in, or nil, if no |
| 989 | `flymake-diagnostic-types-alist', or nil, if no filter is to be | 1039 | filter is to be applied." |
| 990 | applied." | ||
| 991 | (interactive (list 1 (if current-prefix-arg | 1040 | (interactive (list 1 (if current-prefix-arg |
| 992 | '(:error :warning)) | 1041 | '(:error :warning)) |
| 993 | t)) | 1042 | t)) |
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index a09ca2f2f29..6f4a343310c 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el | |||
| @@ -5209,9 +5209,10 @@ be used." | |||
| 5209 | (defcustom python-flymake-msg-alist | 5209 | (defcustom python-flymake-msg-alist |
| 5210 | '(("\\(^redefinition\\|.*unused.*\\|used$\\)" . :warning)) | 5210 | '(("\\(^redefinition\\|.*unused.*\\|used$\\)" . :warning)) |
| 5211 | "Alist used to associate messages to their types. | 5211 | "Alist used to associate messages to their types. |
| 5212 | Each element should be a cons-cell (REGEXP . TYPE), where TYPE must be | 5212 | Each element should be a cons-cell (REGEXP . TYPE), where TYPE |
| 5213 | one defined in the variable `flymake-diagnostic-types-alist'. | 5213 | should be a diagnostic type symbol like `:error', `:warning' or |
| 5214 | For example, when using `flake8' a possible configuration could be: | 5214 | `:note'. For example, when using `flake8' a possible |
| 5215 | configuration could be: | ||
| 5215 | 5216 | ||
| 5216 | ((\"\\(^redefinition\\|.*unused.*\\|used$\\)\" . :warning) | 5217 | ((\"\\(^redefinition\\|.*unused.*\\|used$\\)\" . :warning) |
| 5217 | (\"^E999\" . :error) | 5218 | (\"^E999\" . :error) |