]> code.delx.au - gnu-emacs/blob - doc/misc/flymake.texi
79259a76503a60c3c3587841ab146b41732bdb76
[gnu-emacs] / doc / misc / flymake.texi
1 \input texinfo @c -*-texinfo-*-
2 @comment %**start of header
3 @setfilename ../../info/flymake
4 @set VERSION 0.3
5 @set UPDATED April 2004
6 @settitle GNU Flymake @value{VERSION}
7 @syncodeindex pg cp
8 @comment %**end of header
9
10 @copying
11 This manual is for GNU Flymake (version @value{VERSION}, @value{UPDATED}),
12 which is a universal on-the-fly syntax checker for GNU Emacs.
13
14 Copyright @copyright{} 2004--2013 Free Software Foundation, Inc.
15
16 @quotation
17 Permission is granted to copy, distribute and/or modify this document
18 under the terms of the GNU Free Documentation License, Version 1.3 or
19 any later version published by the Free Software Foundation; with no
20 Invariant Sections, with the Front-Cover texts being ``A GNU Manual,''
21 and with the Back-Cover Texts as in (a) below. A copy of the license
22 is included in the section entitled ``GNU Free Documentation License''.
23
24 (a) The FSF's Back-Cover Text is: ``You have the freedom to copy and
25 modify this GNU manual.''
26 @end quotation
27 @end copying
28
29 @dircategory Emacs misc features
30 @direntry
31 * Flymake: (flymake). A universal on-the-fly syntax checker.
32 @end direntry
33
34 @titlepage
35 @title GNU Flymake
36 @subtitle for version @value{VERSION}, @value{UPDATED}
37 @author Pavel Kobiakov(@email{pk_at_work@@yahoo.com})
38 @page
39 @vskip 0pt plus 1filll
40 @insertcopying
41 @end titlepage
42
43 @contents
44
45 @ifnottex
46 @node Top
47 @top GNU Flymake
48 @insertcopying
49 @end ifnottex
50
51 @menu
52 * Overview of Flymake::
53 * Installing Flymake::
54 * Using Flymake::
55 * Configuring Flymake::
56 * Flymake Implementation::
57 * GNU Free Documentation License::
58 * Index::
59 @end menu
60
61 @node Overview of Flymake
62 @chapter Overview
63 @cindex Overview of Flymake
64
65 Flymake is a universal on-the-fly syntax checker implemented as an
66 Emacs minor mode. Flymake runs the pre-configured syntax check tool
67 (compiler for C++ files, @code{perl} for perl files, etc.)@: in the
68 background, passing it a temporary copy of the current buffer, and
69 parses the output for known error/warning message patterns. Flymake
70 then highlights erroneous lines (i.e., lines for which at least one
71 error or warning has been reported by the syntax check tool), and
72 displays an overall buffer status in the mode line. Status information
73 displayed by Flymake contains total number of errors and warnings
74 reported for the buffer during the last syntax check.
75
76 @code{flymake-goto-next-error} and @code{flymake-goto-prev-error}
77 functions allow for easy navigation to the next/previous erroneous
78 line, respectively.
79
80 Calling @code{flymake-display-err-menu-for-current-line} will popup a
81 menu containing error messages reported by the syntax check tool for
82 the current line. Errors/warnings belonging to another file, such as a
83 @code{.h} header file included by a @code{.c} file, are shown in the
84 current buffer as belonging to the first line. Menu items for such
85 messages also contain a filename and a line number. Selecting such a
86 menu item will automatically open the file and jump to the line with
87 error.
88
89 Syntax check is done 'on-the-fly'. It is started whenever
90
91 @itemize @bullet
92 @item buffer is loaded
93 @item a newline character is added to the buffer
94 @item some changes were made to the buffer more than @code{0.5} seconds ago (the
95 delay is configurable).
96 @end itemize
97
98 Flymake is a universal syntax checker in the sense that it's easily
99 extended to support new syntax check tools and error message
100 patterns. @xref{Configuring Flymake}.
101
102 @node Installing Flymake
103 @chapter Installing
104 @cindex Installing Flymake
105
106
107 Flymake is packaged in a single file, @code{flymake.el}.
108
109 To install/update Flymake, place @code{flymake.el} to a directory
110 somewhere on Emacs load path. You might also want to byte-compile
111 @code{flymake.el} to improve performance.
112
113 Also, place the following line in the @code{.emacs} file.
114
115 @lisp
116 (require 'flymake)
117 @end lisp
118
119 You might also map the most frequently used Flymake functions, such as
120 @code{flymake-goto-next-error}, to some keyboard shortcuts:
121
122 @lisp
123 (global-set-key [f3] 'flymake-display-err-menu-for-current-line)
124 (global-set-key [f4] 'flymake-goto-next-error)
125 @end lisp
126
127 @node Using Flymake
128 @chapter Using Flymake
129 @cindex Using Flymake
130
131 @menu
132 * Flymake mode::
133 * Running the syntax check::
134 * Navigating to error lines::
135 * Viewing error messages::
136 * Syntax check statuses::
137 * Troubleshooting::
138 @end menu
139
140 @node Flymake mode
141 @section Flymake mode
142 @cindex flymake-mode
143
144 Flymake is an Emacs minor mode. To use Flymake, you
145 must first activate @code{flymake-mode} by using the
146 @code{flymake-mode} function.
147
148 Instead of manually activating @code{flymake-mode}, you can configure
149 Flymake to automatically enable @code{flymake-mode} upon opening any
150 file for which syntax check is possible. To do so, place the following
151 line in @code{.emacs}:
152
153 @lisp
154 (add-hook 'find-file-hook 'flymake-find-file-hook)
155 @end lisp
156
157 @node Running the syntax check
158 @section Running the syntax check
159 @cindex Manually starting the syntax check
160
161 When @code{flymake-mode} is active, syntax check is started
162 automatically on any of the three conditions mentioned above. Syntax
163 check can also be started manually by using the
164 @code{flymake-start-syntax-check-for-current-buffer} function. This
165 can be used, for example, when changes were made to some other buffer
166 affecting the current buffer.
167
168 @node Navigating to error lines
169 @section Navigating to error lines
170 @cindex Navigating to error lines
171
172 After syntax check is completed, lines for which at least one error or
173 warning has been reported are highlighted, and total number of errors
174 and warning is shown in the mode line. Use the following functions to
175 navigate the highlighted lines.
176
177 @multitable @columnfractions 0.25 0.75
178
179 @item @code{flymake-goto-next-error}
180 @tab Moves point to the next erroneous line, if any.
181
182 @item @code{flymake-goto-prev-error}
183 @tab Moves point to the previous erroneous line.
184
185 @end multitable
186
187 These functions treat erroneous lines as a linked list. Therefore,
188 @code{flymake-goto-next-error} will go to the first erroneous line
189 when invoked in the end of the buffer.
190
191 @node Viewing error messages
192 @section Viewing error messages
193 @cindex Viewing error messages
194
195 To view error messages belonging to the current line, use the
196 @code{flymake-display-err-menu-for-current-line} function. If there's
197 at least one error or warning reported for the current line, this
198 function will display a popup menu with error/warning texts.
199 Selecting the menu item whose error belongs to another file brings
200 forward that file with the help of the
201 @code{flymake-goto-file-and-line} function.
202
203 @node Syntax check statuses
204 @section Syntax check statuses
205 @cindex Syntax check statuses
206
207 After syntax check is finished, its status is displayed in the mode line.
208 The following statuses are defined.
209
210 @multitable @columnfractions 0.25 0.75
211 @item Flymake* or Flymake:E/W*
212 @tab Flymake is currently running. For the second case, E/W contains the
213 error and warning count for the previous run.
214
215 @item Flymake
216 @tab Syntax check is not running. Usually this means syntax check was
217 successfully passed (no errors, no warnings). Other possibilities are:
218 syntax check was killed as a result of executing
219 @code{flymake-compile}, or syntax check cannot start as compilation
220 is currently in progress.
221
222 @item Flymake:E/W
223 @tab Number of errors/warnings found by the syntax check process.
224
225 @item Flymake:!
226 @tab Flymake was unable to find master file for the current buffer.
227 @end multitable
228
229 The following errors cause a warning message and switch flymake mode
230 OFF for the buffer.
231
232 @multitable @columnfractions 0.25 0.75
233 @item CFGERR
234 @tab Syntax check process returned nonzero exit code, but no
235 errors/warnings were reported. This indicates a possible configuration
236 error (for example, no suitable error message patterns for the
237 syntax check tool).
238
239 @item NOMASTER
240 @tab Flymake was unable to find master file for the current buffer.
241
242 @item NOMK
243 @tab Flymake was unable to find a suitable buildfile for the current buffer.
244
245 @item PROCERR
246 @tab Flymake was unable to launch a syntax check process.
247 @end multitable
248
249
250 @node Troubleshooting
251 @section Troubleshooting
252 @cindex Logging
253 @cindex Troubleshooting
254
255 Flymake uses a simple logging facility for indicating important points
256 in the control flow. The logging facility sends logging messages to
257 the @code{*Messages*} buffer. The information logged can be used for
258 resolving various problems related to Flymake.
259
260 Logging output is controlled by the @code{flymake-log-level}
261 variable. @code{3} is the most verbose level, and @code{-1} switches
262 logging off.
263
264 @node Configuring Flymake
265 @chapter Configuring and Extending Flymake
266 @cindex Configuring and Extending Flymake
267
268 @menu
269 * Customizable variables::
270 * Adding support for a new syntax check tool::
271 @end menu
272
273 Flymake was designed to be easily extended for supporting new syntax
274 check tools and error message patterns.
275
276 @node Customizable variables
277 @section Customizable variables
278 @cindex Customizable variables
279
280 This section summarizes variables used for Flymake
281 configuration.
282
283 @table @code
284 @item flymake-log-level
285 Controls logging output, see @ref{Troubleshooting}.
286
287 @item flymake-allowed-file-name-masks
288 A list of @code{(filename-regexp, init-function, cleanup-function
289 getfname-function)} for configuring syntax check tools. @xref{Adding
290 support for a new syntax check tool}.
291
292 @ignore
293 @item flymake-buildfile-dirs
294 A list of directories (relative paths) for searching a
295 buildfile. @xref{Locating the buildfile}.
296 @end ignore
297
298 @item flymake-master-file-dirs
299 A list of directories for searching a master file. @xref{Locating a
300 master file}.
301
302 @item flymake-get-project-include-dirs-function
303 A function used for obtaining a list of project include dirs (C/C++
304 specific). @xref{Getting the include directories}.
305
306 @item flymake-master-file-count-limit
307 @itemx flymake-check-file-limit
308 Used when looking for a master file. @xref{Locating a master file}.
309
310 @item flymake-err-line-patterns
311 Patterns for error/warning messages in the form @code{(regexp file-idx
312 line-idx col-idx err-text-idx)}. @xref{Parsing the output}.
313
314 @item flymake-compilation-prevents-syntax-check
315 A flag indicating whether compilation and syntax check of the same
316 file cannot be run simultaneously.
317
318 @item flymake-no-changes-timeout
319 If any changes are made to the buffer, syntax check is automatically
320 started after @code{flymake-no-changes-timeout} seconds.
321
322 @item flymake-gui-warnings-enabled
323 A boolean flag indicating whether Flymake will show message boxes for
324 non-recoverable errors. If @code{flymake-gui-warnings-enabled} is
325 @code{nil}, these errors will only be logged to the @code{*Messages*}
326 buffer.
327
328 @item flymake-start-syntax-check-on-newline
329 A boolean flag indicating whether to start syntax check after a
330 newline character is added to the buffer.
331
332 @item flymake-errline
333 A custom face for highlighting lines for which at least one error has
334 been reported.
335
336 @item flymake-warnline
337 A custom face for highlighting lines for which at least one warning
338 and no errors have been reported.
339
340 @item flymake-error-bitmap
341 A bitmap used in the fringe to mark lines for which an error has
342 been reported.
343
344 @item flymake-warning-bitmap
345 A bitmap used in the fringe to mark lines for which a warning has
346 been reported.
347
348 @item flymake-fringe-indicator-position
349 Which fringe (if any) should show the warning/error bitmaps.
350
351 @end table
352
353 @node Adding support for a new syntax check tool
354 @section Adding support for a new syntax check tool
355 @cindex Adding support for a new syntax check tool
356
357 @menu
358 * Example---Configuring a tool called directly::
359 * Example---Configuring a tool called via make::
360 @end menu
361
362 Syntax check tools are configured using the
363 @code{flymake-allowed-file-name-masks} list. Each item of this list
364 has the following format:
365
366 @lisp
367 (filename-regexp, init-function, cleanup-function, getfname-function)
368 @end lisp
369
370 @table @code
371 @item filename-regexp
372 This field is used as a key for locating init/cleanup/getfname
373 functions for the buffer. Items in
374 @code{flymake-allowed-file-name-masks} are searched sequentially. The
375 first item with @code{filename-regexp} matching buffer filename is
376 selected. If no match is found, @code{flymake-mode} is switched off.
377
378 @item init-function
379 @code{init-function} is required to initialize the syntax check,
380 usually by creating a temporary copy of the buffer contents. The
381 function must return @code{(list cmd-name arg-list)}. If
382 @code{init-function} returns null, syntax check is aborted, by
383 @code{flymake-mode} is not switched off.
384
385 @item cleanup-function
386 @code{cleanup-function} is called after the syntax check process is
387 complete and should take care of proper deinitialization, which is
388 usually deleting a temporary copy created by the @code{init-function}.
389
390 @item getfname-function
391 This function is used for translating filenames reported by the syntax
392 check tool into ``real'' filenames. Filenames reported by the tool
393 will be different from the real ones, as actually the tool works with
394 the temporary copy. In most cases, the default implementation
395 provided by Flymake, @code{flymake-get-real-file-name}, can be used as
396 @code{getfname-function}.
397
398 @end table
399
400 To add support for a new syntax check tool, write corresponding
401 @code{init-function}, and, optionally @code{cleanup-function} and
402 @code{getfname-function}. If the format of error messages reported by
403 the new tool is not yet supported by Flymake, add a new entry to
404 the @code{flymake-err-line-patterns} list.
405
406 The following sections contain some examples of configuring Flymake
407 support for various syntax check tools.
408
409 @node Example---Configuring a tool called directly
410 @subsection Example---Configuring a tool called directly
411 @cindex Adding support for perl
412
413 In this example, we will add support for @code{perl} as a syntax check
414 tool. @code{perl} supports the @code{-c} option which does syntax
415 checking.
416
417 First, we write the @code{init-function}:
418
419 @lisp
420 (defun flymake-perl-init ()
421 (let* ((temp-file (flymake-init-create-temp-buffer-copy
422 'flymake-create-temp-inplace))
423 (local-file (file-relative-name
424 temp-file
425 (file-name-directory buffer-file-name))))
426 (list "perl" (list "-wc " local-file))))
427 @end lisp
428
429 @code{flymake-perl-init} creates a temporary copy of the buffer
430 contents with the help of
431 @code{flymake-init-create-temp-buffer-copy}, and builds an appropriate
432 command line.
433
434 Next, we add a new entry to the
435 @code{flymake-allowed-file-name-masks}:
436
437 @lisp
438 (setq flymake-allowed-file-name-masks
439 (cons '(".+\\.pl$"
440 flymake-perl-init
441 flymake-simple-cleanup
442 flymake-get-real-file-name)
443 flymake-allowed-file-name-masks))
444 @end lisp
445
446 Note that we use standard @code{cleanup-function} and
447 @code{getfname-function}.
448
449 Finally, we add an entry to @code{flymake-err-line-patterns}:
450
451 @lisp
452 (setq flymake-err-line-patterns
453 (cons '("\\(.*\\) at \\([^ \n]+\\) line \\([0-9]+\\)[,.\n]"
454 2 3 nil 1)
455 flymake-err-line-patterns))
456 @end lisp
457
458 @node Example---Configuring a tool called via make
459 @subsection Example---Configuring a tool called via make
460 @cindex Adding support for C (gcc+make)
461
462 In this example we will add support for C files syntax checked by
463 @command{gcc} called via @command{make}.
464
465 We're not required to write any new functions, as Flymake already has
466 functions for @command{make}. We just add a new entry to the
467 @code{flymake-allowed-file-name-masks}:
468
469 @lisp
470 (setq flymake-allowed-file-name-masks
471 (cons '(".+\\.c$"
472 flymake-simple-make-init
473 flymake-simple-cleanup
474 flymake-get-real-file-name)
475 flymake-allowed-file-name-masks))
476 @end lisp
477
478 @code{flymake-simple-make-init} builds the following @command{make}
479 command line:
480
481 @lisp
482 (list "make"
483 (list "-s" "-C"
484 base-dir
485 (concat "CHK_SOURCES=" source)
486 "SYNTAX_CHECK_MODE=1"
487 "check-syntax"))
488 @end lisp
489
490 @code{base-dir} is a directory containing @code{Makefile}, see @ref{Locating the buildfile}.
491
492 Thus, @code{Makefile} must contain the @code{check-syntax} target. In
493 our case this target might look like this:
494
495 @verbatim
496 check-syntax:
497 gcc -o /dev/null -S ${CHK_SOURCES}
498 @end verbatim
499
500 @noindent
501 The format of error messages reported by @command{gcc} is already
502 supported by Flymake, so we don't have to add a new entry to
503 @code{flymake-err-line-patterns}. Note that if you are using
504 Automake, you may want to replace @code{gcc} with the standard
505 Automake variable @code{COMPILE}:
506
507 @verbatim
508 check-syntax:
509 $(COMPILE) -o /dev/null -S ${CHK_SOURCES}
510 @end verbatim
511
512 @node Flymake Implementation
513 @chapter Flymake Implementation
514 @cindex Implementation details
515
516 @menu
517 * Determining whether syntax check is possible::
518 * Making a temporary copy::
519 * Locating a master file::
520 * Getting the include directories::
521 * Locating the buildfile::
522 * Starting the syntax check process::
523 * Parsing the output::
524 * Highlighting erroneous lines::
525 * Interaction with other modes::
526 @end menu
527
528 Syntax check is started by calling @code{flymake-start-syntax-check-for-current-buffer}.
529 Flymake first determines whether it is able to do syntax
530 check. It then saves a copy of the buffer in a temporary file in the
531 buffer's directory (or in the system temp directory, for java
532 files), creates a syntax check command and launches a process with
533 this command. The output is parsed using a list of error message patterns,
534 and error information (file name, line number, type and text) is
535 saved. After the process has finished, Flymake highlights erroneous
536 lines in the buffer using the accumulated error information.
537
538 @node Determining whether syntax check is possible
539 @section Determining whether syntax check is possible
540 @cindex Syntax check models
541 @cindex Master file
542
543 Syntax check is considered possible if there's an entry in
544 @code{flymake-allowed-file-name-masks} matching buffer's filename and
545 its @code{init-function} returns non-@code{nil} value.
546
547 Two syntax check modes are distinguished:
548
549 @enumerate
550
551 @item
552 Buffer can be syntax checked in a standalone fashion, that is, the
553 file (its temporary copy, in fact) can be passed over to the compiler to
554 do the syntax check. Examples are C/C++ (.c, .cpp) and Java (.java)
555 sources.
556
557 @item
558 Buffer can be syntax checked, but additional file, called master file,
559 is required to perform this operation. A master file is a file that
560 includes the current file, so that running a syntax check tool on it
561 will also check syntax in the current file. Examples are C/C++ (.h,
562 .hpp) headers.
563
564 @end enumerate
565
566 These modes are handled inside init/cleanup/getfname functions, see
567 @ref{Adding support for a new syntax check tool}.
568
569 Flymake contains implementations of all functionality required to
570 support different syntax check modes described above (making temporary
571 copies, finding master files, etc.), as well as some tool-specific
572 (routines for Make, Ant, etc.)@: code.
573
574
575 @node Making a temporary copy
576 @section Making a temporary copy
577 @cindex Temporary copy of the buffer
578 @cindex Master file
579
580 After the possibility of the syntax check has been determined, a
581 temporary copy of the current buffer is made so that the most recent
582 unsaved changes could be seen by the syntax check tool. Making a copy
583 is quite straightforward in a standalone case (mode @code{1}), as it's
584 just saving buffer contents to a temporary file.
585
586 Things get trickier, however, when master file is involved, as it
587 requires to
588
589 @itemize @bullet
590 @item locate a master file
591 @item patch it to include the current file using its new (temporary)
592 name.
593 @end itemize
594
595 Locating a master file is discussed in the following section.
596
597 Patching just changes all appropriate lines of the master file so that they
598 use the new (temporary) name of the current file. For example, suppose current
599 file name is @code{file.h}, the master file is @code{file.cpp}, and
600 it includes current file via @code{#include "file.h"}. Current file's copy
601 is saved to file @code{file_flymake.h}, so the include line must be
602 changed to @code{#include "file_flymake.h"}. Finally, patched master file
603 is saved to @code{file_flymake_master.cpp}, and the last one is passed to
604 the syntax check tool.
605
606 @node Locating a master file
607 @section Locating a master file
608 @cindex Master file
609
610 Master file is located in two steps.
611
612 First, a list of possible master files is built. A simple name
613 matching is used to find the files. For a C++ header @code{file.h},
614 Flymake searches for all @code{.cpp} files in the directories whose relative paths are
615 stored in a customizable variable @code{flymake-master-file-dirs}, which
616 usually contains something like @code{("." "./src")}. No more than
617 @code{flymake-master-file-count-limit} entries is added to the master file
618 list. The list is then sorted to move files with names @code{file.cpp} to
619 the top.
620
621 Next, each master file in a list is checked to contain the appropriate
622 include directives. No more than @code{flymake-check-file-limit} of each
623 file are parsed.
624
625 For @code{file.h}, the include directives to look for are
626 @code{#include "file.h"}, @code{#include "../file.h"}, etc. Each
627 include is checked against a list of include directories
628 (see @ref{Getting the include directories}) to be sure it points to the
629 correct @code{file.h}.
630
631 First matching master file found stops the search. The master file is then
632 patched and saved to disk. In case no master file is found, syntax check is
633 aborted, and corresponding status (!) is reported in the mode line.
634
635 @node Getting the include directories
636 @section Getting the include directories
637 @cindex Include directories (C/C++ specific)
638
639 Two sets of include directories are distinguished: system include directories
640 and project include directories. The former is just the contents of the
641 @code{INCLUDE} environment variable. The latter is not so easy to obtain,
642 and the way it can be obtained can vary greatly for different projects.
643 Therefore, a customizable variable
644 @code{flymake-get-project-include-dirs-function} is used to provide the
645 way to implement the desired behavior.
646
647 The default implementation, @code{flymake-get-project-include-dirs-imp},
648 uses a @command{make} call. This requires a correct base directory, that is, a
649 directory containing a correct @file{Makefile}, to be determined.
650
651 As obtaining the project include directories might be a costly operation, its
652 return value is cached in the hash table. The cache is cleared in the beginning
653 of every syntax check attempt.
654
655 @node Locating the buildfile
656 @section Locating the buildfile
657 @cindex Locating the buildfile
658 @cindex buildfile, locating
659 @cindex Makefile, locating
660
661 Flymake can be configured to use different tools for performing syntax
662 checks. For example, it can use direct compiler call to syntax check a perl
663 script or a call to @command{make} for a more complicated case of a
664 @code{C/C++} source. The general idea is that simple files, like perl
665 scripts and html pages, can be checked by directly invoking a
666 corresponding tool. Files that are usually more complex and generally
667 used as part of larger projects, might require non-trivial options to
668 be passed to the syntax check tool, like include directories for
669 C++. The latter files are syntax checked using some build tool, like
670 Make or Ant.
671
672 All Make configuration data is usually stored in a file called
673 @code{Makefile}. To allow for future extensions, flymake uses a notion of
674 buildfile to reference the 'project configuration' file.
675
676 Special function, @code{flymake-find-buildfile} is provided for locating buildfiles.
677 Searching for a buildfile is done in a manner similar to that of searching
678 for possible master files.
679 @ignore
680 A customizable variable
681 @code{flymake-buildfile-dirs} holds a list of relative paths to the
682 buildfile. They are checked sequentially until a buildfile is found.
683 @end ignore
684 In case there's no build file, syntax check is aborted.
685
686 Buildfile values are also cached.
687
688 @node Starting the syntax check process
689 @section Starting the syntax check process
690 @cindex Syntax check process
691
692 The command line (command name and the list of arguments) for launching a process is returned by the
693 initialization function. Flymake then just calls @code{start-process}
694 to start an asynchronous process and configures process filter and
695 sentinel which is used for processing the output of the syntax check
696 tool.
697
698 @node Parsing the output
699 @section Parsing the output
700 @cindex Parsing the output
701
702 The output generated by the syntax check tool is parsed in the process
703 filter/sentinel using the error message patterns stored in the
704 @code{flymake-err-line-patterns} variable. This variable contains a
705 list of items of the form @code{(regexp file-idx line-idx
706 err-text-idx)}, used to determine whether a particular line is an
707 error message and extract file name, line number and error text,
708 respectively. Error type (error/warning) is also guessed by matching
709 error text with the '@code{^[wW]arning}' pattern. Anything that was not
710 classified as a warning is considered an error. Type is then used to
711 sort error menu items, which shows error messages first.
712
713 Flymake is also able to interpret error message patterns missing err-text-idx
714 information. This is done by merely taking the rest of the matched line
715 (@code{(substring line (match-end 0))}) as error text. This trick allows
716 to make use of a huge collection of error message line patterns from
717 @code{compile.el}. All these error patterns are appended to
718 the end of @code{flymake-err-line-patterns}.
719
720 The error information obtained is saved in a buffer local
721 variable. The buffer for which the process output belongs is
722 determined from the process-id@w{}->@w{}buffer mapping updated
723 after every process launch/exit.
724
725 @node Highlighting erroneous lines
726 @section Highlighting erroneous lines
727 @cindex Erroneous lines, faces
728
729 Highlighting is implemented with overlays and happens in the process
730 sentinel, after calling the cleanup function. Two customizable faces
731 are used: @code{flymake-errline} and
732 @code{flymake-warnline}. Errors belonging outside the current
733 buffer are considered to belong to line 1 of the current buffer.
734
735 @c This manual does not use vindex.
736 @c @vindex flymake-fringe-indicator-position
737 @c @vindex flymake-error-bitmap
738 @c @vindex flymake-warning-bitmap
739 If the option @code{flymake-fringe-indicator-position} is non-@code{nil},
740 errors and warnings are also highlighted in the left or right fringe,
741 using the bitmaps specified by @code{flymake-error-bitmap}
742 and @code{flymake-warning-bitmap}.
743
744 @node Interaction with other modes
745 @section Interaction with other modes
746 @cindex Interaction with other modes
747 @cindex Interaction with compile mode
748
749 The only mode flymake currently knows about is @code{compile}.
750
751 Flymake can be configured to not start syntax check if it thinks the
752 compilation is in progress. The check is made by the
753 @code{flymake-compilation-is-running}, which tests the
754 @code{compilation-in-progress} variable. The reason why this might be
755 useful is saving CPU time in case both syntax check and compilation
756 are very CPU intensive. The original reason for adding this feature,
757 though, was working around a locking problem with MS Visual C++ compiler.
758
759 Flymake also provides an alternative command for starting compilation,
760 @code{flymake-compile}:
761
762 @lisp
763 (defun flymake-compile ()
764 "Kill all flymake syntax checks then start compilation."
765 (interactive)
766 (flymake-stop-all-syntax-checks)
767 (call-interactively 'compile))
768 @end lisp
769
770 It just kills all the active syntax check processes before calling
771 @code{compile}.
772
773 @node GNU Free Documentation License
774 @appendix GNU Free Documentation License
775 @include doclicense.texi
776
777 @node Index
778 @unnumbered Index
779
780 @printindex cp
781
782 @bye