aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoão Távora2017-10-10 02:14:46 +0100
committerJoão Távora2017-10-10 13:08:41 +0100
commit1c2e1884407f6210b0787e76e0707049e2babc8f (patch)
tree44f48b1f20c9199bdb7cba4fa9e07d565d67c94b
parent0f7f677f82677a29a7f5abacbb1045cd26c003c5 (diff)
downloademacs-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.
-rw-r--r--doc/misc/flymake.texi464
-rw-r--r--lisp/progmodes/flymake.el41
2 files changed, 444 insertions, 61 deletions
diff --git a/doc/misc/flymake.texi b/doc/misc/flymake.texi
index a85fe4a30e1..9207ed496f7 100644
--- a/doc/misc/flymake.texi
+++ b/doc/misc/flymake.texi
@@ -66,23 +66,11 @@ modify this GNU manual.''
66Flymake is a universal on-the-fly buffer checker implemented as an 66Flymake is a universal on-the-fly buffer checker implemented as an
67Emacs minor mode. When enabled, Flymake visually annotates the buffer 67Emacs minor mode. When enabled, Flymake visually annotates the buffer
68with diagnostic information coming from one or more different sources, 68with diagnostic information coming from one or more different sources,
69or @emph{backends}. 69or @dfn{backends}.
70
71Historically, Flymake used to accept diagnostics from a single, albeit
72reasonably flexible, backend.
73
74This backend isn't (yet) obsolete and so is still available as a
75fallback and active by default(@pxref{The legacy Proc backend}). It works by
76selecting a syntax check tool from a preconfigured list (compiler for
77C++ files, @code{perl} for perl files, etc.), and executing it in the
78background, passing it a temporary file which is a copy of the current
79buffer, and parsing the output for known error/warning message
80patterns.
81 70
82Flymake annotates the buffer by highlighting problematic buffer 71Flymake annotates the buffer by highlighting problematic buffer
83regions with a special space. It also displays an overall buffer 72regions with a special space. It displays an overall buffer status in
84status in the mode line. Status information displayed by Flymake 73the mode line containing totals for different types of diagnostics.
85contains totals for different types of diagnostics.
86 74
87@code{flymake-goto-next-error} and @code{flymake-goto-prev-error} are 75@code{flymake-goto-next-error} and @code{flymake-goto-prev-error} are
88commands that allow easy navigation to the next/previous erroneous 76commands that allow easy navigation to the next/previous erroneous
@@ -97,14 +85,30 @@ and @kbd{M-p} in @code{flymake-mode}, by adding to your init file:
97Syntax check is done ``on-the-fly''. It is started whenever 85Syntax check is done ``on-the-fly''. It is started whenever
98 86
99@itemize @bullet 87@itemize @bullet
100@item @code{flymake-mode} is started; 88@item @code{flymake-mode} is started, unless
101@item a newline character is added to the buffer; 89 @code{flymake-start-on-flymake-mode} is nil.
102@item some changes were made to the buffer more than @code{0.5} seconds ago (the 90
103delay is configurable). 91@item a newline character is added to the buffer, unless
92 @code{flymake-start-syntax-check-on-newline} is nil.
93
94@item some changes were made to the buffer more than @code{0.5}
95 seconds ago (the delay is configurable in
96 @code{flymake-no-changes-timeout}).
104@end itemize 97@end itemize
105 98
106Flymake is a universal syntax checker in the sense that it's easily 99Flymake is a universal syntax checker in the sense that it's easily
107extended to support new backends. @xref{Customizable variables}. 100extended to support new backends @pxref{Extending Flymake}.
101
102Historically, Flymake used to accept diagnostics from a single, albeit
103reasonably flexible, backend.
104
105This backend isn't (yet) obsolete and so is still available as a
106fallback and active by default(@pxref{The legacy Proc backend}). It works by
107selecting a syntax check tool from a preconfigured list (compiler for
108C++ files, @code{perl} for perl files, etc.), and executing it in the
109background, passing it a temporary file which is a copy of the current
110buffer, and parsing the output for known error/warning message
111patterns.
108 112
109@node Installing Flymake 113@node Installing Flymake
110@chapter Installing 114@chapter Installing
@@ -123,7 +127,7 @@ nothing to do by way of installation.
123* Running the syntax check:: 127* Running the syntax check::
124* Navigating to error lines:: @c * Viewing error messages:: 128* Navigating to error lines:: @c * Viewing error messages::
125* Syntax check statuses:: 129* Syntax check statuses::
126* Troubleshooting:: 130* Backend exceptions::
127* Customizable variables:: 131* Customizable variables::
128@end menu 132@end menu
129 133
@@ -151,7 +155,7 @@ line in @code{.emacs}:
151When @code{flymake-mode} is active, syntax check is started 155When @code{flymake-mode} is active, syntax check is started
152automatically on any of the three conditions mentioned above. Syntax 156automatically on any of the three conditions mentioned above. Syntax
153check can also be started manually by using the @code{flymake-start} 157check can also be started manually by using the @code{flymake-start}
154function. 158command.
155 159
156@node Navigating to error lines 160@node Navigating to error lines
157@section Navigating to error lines 161@section Navigating to error lines
@@ -160,17 +164,17 @@ function.
160After syntax check is completed, lines for which at least one error or 164After syntax check is completed, lines for which at least one error or
161warning has been reported are highlighted, and total number of errors 165warning has been reported are highlighted, and total number of errors
162and warning is shown in the mode line. Use the following functions to 166and warning is shown in the mode line. Use the following functions to
163navigate the highlighted lines. 167navigate the highlighted lines:
164 168
165@multitable @columnfractions 0.25 0.75 169@table @code
166 170
167@item @code{flymake-goto-next-error} 171@item flymake-goto-next-error
168@tab Moves point to the next erroneous line, if any. 172Moves point to the next erroneous line, if any.
169 173
170@item @code{flymake-goto-prev-error} 174@item flymake-goto-prev-error
171@tab Moves point to the previous erroneous line. 175Moves point to the previous erroneous line.
172 176
173@end multitable 177@end table
174 178
175If the user option @code{flymake-wrap-around} is active 179If the user option @code{flymake-wrap-around} is active
176(@pxref{Customizable variables}), these functions treat diagnostics 180(@pxref{Customizable variables}), these functions treat diagnostics
@@ -181,7 +185,7 @@ to the first diagnostic when invoked in the end of the buffer.
181@section Syntax check statuses 185@section Syntax check statuses
182@cindex Syntax check statuses 186@cindex Syntax check statuses
183 187
184After syntax check is finished, its status is displayed in the mode line. 188While enabled, Flymake displays its status in the mode line.
185The following statuses are defined: 189The following statuses are defined:
186 190
187@multitable @columnfractions 0.25 0.75 191@multitable @columnfractions 0.25 0.75
@@ -191,8 +195,9 @@ where questioned.
191 195
192@item @code{!} 196@item @code{!}
193@tab All the configured Flymake backends have disabled themselves. 197@tab All the configured Flymake backends have disabled themselves.
194Left-clicking the ``Flymake'' mode line indicator beings the user 198Left-clicking Flymake's mode line indicator pops up a menu listing the
195@code{*Flymake log*} buffer where these situations may be investigated 199option to visit Flymake's log buffer. In this buffer these situations
200can be investigated.
196 201
197@item @code{?} 202@item @code{?}
198@tab There are no configured Flymake backends in 203@tab There are no configured Flymake backends in
@@ -203,12 +208,25 @@ Left-clicking the ``Flymake'' mode line indicator beings the user
203check process. 208check process.
204@end multitable 209@end multitable
205 210
206@node Troubleshooting 211@node Backend exceptions
207@section Troubleshooting 212@section Backend exceptions
208@cindex Logging 213@cindex Logging
209@cindex Troubleshooting 214@cindex Backend exceptions
215
216Some backends may take longer than others to respond or complete, and
217some may decide to @dfn{disable} themselves if they are not suitable
218for the current buffer. A disabled backend is not tried again for
219future checks of the current buffer.
220
221The commands @code{flymake-reporting-backends},
222@code{flymake-running-backends} and @code{flymake-disabled-backends}
223inform on the specific situation.
210 224
211Flymake uses a simple logging facility for indicating important points 225Toggling @code{flymake-mode} off and on again or invoking
226@code{flymake-start} with a prefix argument is one way to reset the
227disabled backend list so they will be tried again in the next check.
228
229Flymake also uses a simple logging facility for indicating important points
212in the control flow. The logging facility sends logging messages to 230in the control flow. The logging facility sends logging messages to
213the @file{*Flymake log*} buffer. The information logged can be used for 231the @file{*Flymake log*} buffer. The information logged can be used for
214resolving various problems related to Flymake. 232resolving various problems related to Flymake.
@@ -220,17 +238,22 @@ and @code{warning-minimum-level} variables.
220@section Customizable variables 238@section Customizable variables
221@cindex Customizable variables 239@cindex Customizable variables
222 240
223This section summarizes variables used for the configuration of the 241This section summarizes customization variables used for the
224Flymake user interface. 242configuration of the Flymake user interface.
225 243
226@table @code 244@table @code
227@item flymake-no-changes-timeout 245@item flymake-no-changes-timeout
228If any changes are made to the buffer, syntax check is automatically 246If any changes are made to the buffer, syntax check is automatically
229started after @code{flymake-no-changes-timeout} seconds. 247started after this many seconds, unless the user makes another change,
248which resets the timer.
230 249
231@item flymake-start-syntax-check-on-newline 250@item flymake-start-syntax-check-on-newline
232A boolean flag indicating whether to start syntax check after a 251A boolean flag indicating whether to start syntax check immediately
233newline character is added to the buffer. 252after a newline character is added to the buffer.
253
254@item flymake-start-on-flymake-mode
255A boolean flag indicating whether to start syntax check immediately
256after enabling @code{flymake-mode}.
234 257
235@item flymake-error 258@item flymake-error
236A custom face for highlighting regions for which an error has been 259A custom face for highlighting regions for which an error has been
@@ -265,6 +288,365 @@ If non-nil, moving to errors with @code{flymake-goto-next-error} and
265@chapter Extending Flymake 288@chapter Extending Flymake
266@cindex Extending Flymake 289@cindex Extending Flymake
267 290
291Flymake can primarily be extended in one of two ways:
292
293@enumerate
294@item
295By changing the look and feel of the annotations produced by the
296different backends.
297
298@item
299By adding a new buffer-checking backend.
300@end enumerate
301
302The following sections discuss each approach in detail:
303
304@menu
305* Flymake error types::
306* Backend functions::
307@end menu
308
309@node Flymake error types
310@section Customizing Flymake error types
311
312The variable @code{flymake-diagnostic-types-alist} is looked up by
313Flymake every time an annotation for a diagnostic is created in the
314buffer. Specifically, this variable holds a table of correspondence
315between symbols designating diagnostic types and an additional
316sub-table of properties pertaining to each diagnostic type.
317
318Both tables are laid out in association list (@pxref{Association
319Lists,,, elisp, The Emacs Lisp Reference Manual}) format, and thus can
320be conveniently accessed with the functions of the @code{assoc}
321family.
322
323You can use any symbol-value association in the properties sub-table,
324but some symbols have special meaning as to where and how Flymake
325presents the diagnostic:
326
327@itemize
328
329@item @code{bitmap}, an image displayed in the fringe according to
330@code{flymake-fringe-indicator-position}. The value actually follows
331the syntax of @code{flymake-error-bitmap}(@pxref{Customizable
332variables}). It is overridden by any @code{before-string} overlay
333property.
334
335@item @code{severity} is a non-negative integer specifying the diagnostic's
336severity. The higher, the more serious. If the overlay property
337@code{priority} is not specified, @code{severity} is used to set it
338and help sort overlapping overlays.
339
340@item Every property pertaining to overlays (@pxref{Overlay
341Properties,,, elisp, The Emacs Lisp Reference Manual}), except
342@code{category} and @code{evaporate}. These properties are used to
343affect the appearance of Flymake annotations.
344
345As an example, here's how to make errors (diagnostics of the type
346@code{:error}) stand out even more prominently in the buffer, by
347raising the characters with a @code{display} overlay property.
348
349@example
350(push '(display . (raise 1.2))
351 (cdr (assoc :error flymake-diagnostic-types-alist)))
352@end example
353
354@item @code{flymake-category} is a symbol whose property list is considered
355a default for missing values of any other properties.
356@end itemize
357
358Three default diagnostic types, @code{:error}, @code{:warning} and
359@code{:note} are predefined in
360@code{flymake-diagnostic-types-alist}. By default each lists a single
361@code{flymake-category} property whose value is, respectively, the
362symbols @code{flymake-error}, @code{flymake-warning} and
363@code{flymake-note}.
364
365These category symbols' plists is where the values of customizable
366variables and faces such as @code{flymake-error-bitmap} are found.
367Thus, if you change their plists, Flymake may stop honouring these
368user customizations.
369
370The @code{flymake-category} special property is also especially useful
371to backend authors that create diagnostics objects with non-default
372types that differ from an existing type by only a few properties
373(@pxref{Flymake utility functions}).
374
375As an example, consider configuring a new diagnostic type
376@code{:low-priority-note} that behaves much like the @code{:note}
377priority but without an overlay face.
378
379@example
380(add-to-list
381 'flymake-diagnostic-types-alist
382 `(:low-priority-note . ((face . nil)
383 (flymake-category . flymake-note))))
384@end example
385
386As you might have guessed, Flymake's annotations are implemented as
387overlays(@pxref{Overlays,,, elisp, The Emacs Lisp Reference Manual}).
388Along with the properties that you specify for the specific type of
389diagnostic, Flymake adds the property @code{flymake-text} to these
390overlays, and sets it to the message string that the backend used to
391describe the diagnostic.
392
393Since overlays also support arbitrary keymaps, you can use this
394property @code{flymake-text} to create interactive annotations, such
395as in the following example binding a @kbd{mouse-3} event (middle
396mouse button click) to an internet search for the text of a
397@code{:warning} or @code{:error}.
398
399@example
400(defun my-search-for-message (event)
401 (interactive "e")
402 (let ((ovs (overlays-at (posn-point (event-start event))))
403 ov)
404 ;; loop until flymake overlay we clicked on is recovered
405 (while (not (overlay-get (setq ov (pop ovs)) 'flymake-text)))
406 (when ov
407 (eww-browse-url
408 (concat "https://duckduckgo.com/?q="
409 (replace-regexp-in-string " "
410 "+"
411 (overlay-get ov 'flymake-text)))
412 t))))
413
414(dolist (type '(:warning :error))
415 (let ((a (assoc type flymake-diagnostic-types-alist)))
416 (setf (cdr a)
417 (append `((mouse-face . highlight)
418 (keymap . ,(let ((map (make-sparse-keymap)))
419 (define-key map [mouse-2]
420 'my-search-for-message)
421 map)))
422 (cdr a)))))
423@end example
424
425@node Backend functions
426@section Backend functions
427
428Flymake backends are Lisp functions placed in the special hook
429@code{flymake-diagnostic-functions}.
430
431A backend's responsibility is to diagnose the contents of a buffer for
432problems, registering these problem's positions, type and summarized
433description. This information is collected in the form of diagnostic
434objects created with the function @code{flymake-make-diagnostic} and
435then handed over to Flymake, which then proceeds to annotate the
436buffer.
437
438A request for a buffer check and the subsequent delivery of
439diagnostics are the two key events of the interaction between Flymake
440and backend. Each such event corresponds to a well-defined function
441calling convention: one for calls made by Flymake into the backend via
442the backend function, and second one in the reverse direction via a
443callback. To be usable, backends must adhere to both.
444
445Backend functions must accept an arbitrary number of arguments:
446
447@itemize
448@item the first argument is always @var{report-fn}, a callback function
449detailed below;
450
451@item the remaining arguments are keyword-value pairs in the
452form (@var{:key} @var{value} @var{:key2} @var{value2}...). Currently,
453Flymake provides no such arguments, but backend functions must be
454prepared to accept (and possibly ignore) any number of them.
455@end itemize
456
457Whenever Flymake or the user decides to re-check the buffer, backend
458functions are called as detailed above and are expected to initiate
459this check, but aren't in any way required to complete it before
460exiting: if the computation involved is computationally expensive, as
461is often the case in large buffers, that slower task should be
462scheduled for the future using asynchronous processes or other
463asynchronous mechanisms.
464
465In any case, backend functions are expected to return quickly or
466signal an error, in which case the backend is disabled
467(@pxref{Backend exceptions}).
468
469If the function returns, Flymake considers the backend to be
470@dfn{running}. If it has not done so already, the backend is expected
471to call the function @var{report-fn} passed to it, at which point
472Flymake considers the backend to be @dfn{reporting}. Backends call
473@var{report-fn} by passing it a single argument @var{report-action}
474followed by an optional list of keyword-value pairs in the form
475(@var{:report-key} @var{value} @var{:report-key2} @var{value2}...).
476
477Currently accepted values for @var{report-action} are:
478
479@itemize
480@item A (possibly empty) list of diagnostic objects created with
481@code{flymake-make-diagnostic}, causing Flymake to annotate the
482buffer with this information.
483
484A backend may call @var{report-fn} repeatedly in this manner, but only
485until Flymake considers that the most recently requested buffer check
486is now obsolete because, say, buffer contents have changed in the
487meantime. The backend is only given notice of this via a renewed call
488to the backend function. Thus, to prevent making obsolete reports and
489wasting resources, backend functions should first cancel any ongoing
490processing from previous calls.
491
492@item The symbol @code{:panic}, signaling that the backend has encountered
493an exceptional situation and should be disabled.
494@end itemize
495
496Currently accepted @var{report-key} arguments are:
497
498@itemize
499@item @code{:explanation}: value should give user-readable
500details of the situation encountered, if any.
501
502@item @code{:force}: value should be a boolean suggesting
503that Flymake consider the report even if it was somehow
504unexpected.
505@end itemize
506
507@menu
508* Flymake utility functions::
509* An annotated example backend::
510@end menu
511
512@node Flymake utility functions
513@subsection Flymake utility functions
514
515Before delivering them to Flymake, backends create diagnostic objects
516by calling the function @code{flymake-make-diagnostic}.
517
518@deffn Function flymake-make-diagnostic buffer beg end type text
519Make a Flymake diagnostic for @var{buffer}'s region from @var{beg} to
520@var{end}. @var{type} is a key to
521@code{flymake-diagnostic-types-alist} and @var{text} is a description
522of the problem detected in this region.
523@end deffn
524
525It is often the case with external syntax tools that a diagnostic's
526position is reported in terms of a line number, and sometimes a column
527number. To convert this information into a buffer position, backends
528can use the following function:
529
530@deffn Function flymake-diag-region buffer line &optional col
531Compute @var{buffer}'s region (@var{beg} . @var{end}) corresponding to
532@var{line} and @var{col}. If @var{col} is nil, return a region just
533for @var{line}. Return nil if the region is invalid.
534@end deffn
535
536For troubleshooting purposes, backends may record arbitrary
537exceptional or erroneous situations into the Flymake log
538buffer (@pxref{Backend exceptions}):
539
540@deffn Macro flymake-log level msg &optional args
541Log, at level @var{level}, the message @var{msg} formatted with
542@var{args}. @var{level} is passed to @code{display-warning}, which is
543used to display the warning in Flymake's log buffer.
544@end deffn
545
546@node An annotated example backend
547@subsection An annotated example backend
548
549This section presents an annotated example of a complete working
550Flymake backend. The example illustrates the process of writing a
551backend as outlined above.
552
553The backend in question is used for checking Ruby source files. It
554uses asynchronous processes (@pxref{Asynchronous Processes,,, elisp,
555The Emacs Lisp Reference Manual}), a common technique for performing
556parallel processing in Emacs.
557
558The following code needs lexical binding (@pxref{Using Lexical
559Binding,,, elisp, The Emacs Lisp Reference Manual}) to be active.
560
561@example
562;;; ruby-flymake.el --- A ruby Flymake backend -*- lexical-binding: t; -*-
563(defvar-local ruby--flymake-proc nil)
564
565(defun ruby-flymake (report-fn &rest _args)
566 ;; Not having a ruby interpreter is a serious problem which should cause
567 ;; the backend to disable itself, so an @code{error} is signalled.
568 ;;
569 (unless (executable-find
570 "ruby") (error "Cannot find a suitable ruby"))
571 ;; If a live process launched in an earlier check was found, that
572 ;; process is killed. When that process's sentinel eventually runs,
573 ;; it will notice its obsoletion, since if have since reset
574 ;; `ruby-flymake-proc' to a different value
575 ;;
576 (when (process-live-p ruby--flymake-proc)
577 (kill-process ruby--flymake-proc))
578
579 ;; save the current buffer, the narrowing restrinction, remove any
580 ;; narrowing restriction
581 ;;
582 (let ((source (current-buffer)))
583 (save-restriction
584 (widen)
585 ;; reset the `ruby--flymake-proc' process to a new process
586 ;; calling the ruby tool
587 ;;
588 (setq
589 ruby--flymake-proc
590 (make-process
591 :name "ruby-flymake" :noquery t :connection-type 'pipe
592 ;; make output goes to a temporary buffer
593 ;;
594 :buffer (generate-new-buffer " *ruby-flymake*")
595 :command '("ruby" "-w" "-c")
596 :sentinel
597 (lambda (proc _event)
598 ;; Check that the process as indeed exited, as it might
599 ;; be simply suspended
600 ;;
601 (when (eq 'exit (process-status proc))
602 (unwind-protect
603 ;; Only proceed if `proc' is the same as
604 ;; `ruby--flymake-proc' which indicates that
605 ;; `proc' is not an obsolete process.
606 ;;
607 (if (eq proc ruby--flymake-proc)
608 (with-current-buffer (process-buffer proc)
609 (goto-char (point-min))
610 ;; Parse the output buffer for diagnostic's
611 ;; messages and locations, collect them in a list
612 ;; of objects, and call `report-fn'.
613 ;;
614 (cl-loop
615 while (search-forward-regexp
616 "^\\(?:.*.rb\\|-\\):\\([0-9]+\\): \\(.*\\)$"
617 nil t)
618 for msg = (match-string 2)
619 for (beg . end) = (flymake-diag-region
620 source
621 (string-to-number (match-string 1)))
622 for type = (if (string-match "^warning" msg)
623 :warning
624 :error)
625 collect (flymake-make-diagnostic source
626 beg
627 end
628 type
629 msg)
630 into diags
631 finally (funcall report-fn diags)))
632 (flymake-log :warning "Cancelling obsolete check %s"
633 proc))
634 ;; Cleanup the temporary buffer used to hold the
635 ;; check's output.
636 ;;
637 (kill-buffer (process-buffer proc)))))))
638 ;; send the buffer contents to the process's stdin, followed by
639 ;; an EOF
640 ;;
641 (process-send-region ruby--flymake-proc (point-min) (point-max))
642 (process-send-eof ruby--flymake-proc))))
643
644(defun ruby-setup-flymake-backend ()
645 (add-hook 'flymake-diagnostic-functions 'ruby-flymake nil t))
646
647(add-hook 'ruby-mode-hook 'ruby-setup-flymake-backend)
648@end example
649
268@node The legacy Proc backend 650@node The legacy Proc backend
269@chapter The legacy ``Proc'' backend 651@chapter The legacy ``Proc'' backend
270@cindex The legacy Proc backend 652@cindex The legacy Proc backend
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
325The functions in this hook diagnose problems in a buffers 325The functions in this hook diagnose problems in a buffer's
326contents and provide information to the Flymake user interface 326contents and provide information to the Flymake user interface
327about where and how to annotate problems diagnosed in a buffer. 327about where and how to annotate problems diagnosed in a buffer.
328 328
329Whenever Flymake or the user decides to re-check the buffer, each 329Each backend function must be prepared to accept an arbitrary
330function is called with an arbitrary number of arguments: 330number 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
340Backend functions are expected to initiate the buffer check, but 340Whenever Flymake or the user decides to re-check the buffer,
341aren't required to complete it check before exiting: if the 341backend functions are called as detailed above and are expected
342computation involved is expensive, especially for large buffers, 342to initiate this check, but aren't required to complete it before
343that task can be scheduled for the future using asynchronous 343exiting: if the computation involved is expensive, especially for
344processes or other asynchronous mechanisms. 344large buffers, that task can be scheduled for the future using
345asynchronous processes or other asynchronous mechanisms.
345 346
346In any case, backend functions are expected to return quickly or 347In any case, backend functions are expected to return quickly or
347signal an error, in which case the backend is disabled. Flymake 348signal an error, in which case the backend is disabled. Flymake
@@ -375,10 +376,10 @@ Currently accepted values for REPORT-ACTION are:
375 376
376Currently accepted REPORT-KEY arguments are: 377Currently 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.
875Interactively, always move to the next error. With a prefix arg, 876Interactively, always move to the next error. With a prefix arg,
876skip any diagnostics with a severity less than :warning. 877skip any diagnostics with a severity less than `:warning'.
877 878
878If flymake-wrap-around is non-nil and no more next errors, 879If `flymake-wrap-around' is non-nil and no more next errors,
879resumes search from top. 880resumes search from top.
880 881
881FILTER is a list of diagnostic types found in 882FILTER 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.
930Interactively, always move to the previous error. With a prefix 931Interactively, always move to the previous error. With a prefix
931arg, skip any diagnostics with a severity less than :warning. 932arg, skip any diagnostics with a severity less than `:warning'.
932 933
933If flymake-wrap-around is non-nil and no more previous errors, 934If `flymake-wrap-around' is non-nil and no more previous errors,
934resumes search from bottom. 935resumes search from bottom.
935 936
936FILTER is a list of diagnostic types found in 937FILTER is a list of diagnostic types found in