diff options
| author | Eli Zaretskii | 2017-10-10 17:08:51 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2017-10-10 17:08:51 +0300 |
| commit | 00adeb43e90d549eaa45499380ee007321e4ea0a (patch) | |
| tree | a2faa15e070ee9f4a0d3ac6a5b1da3e5960ab70b /doc/misc | |
| parent | 44c6401733227d0a1b416bd217d99877d586ead8 (diff) | |
| download | emacs-00adeb43e90d549eaa45499380ee007321e4ea0a.tar.gz emacs-00adeb43e90d549eaa45499380ee007321e4ea0a.zip | |
Improve the Flymake manual
* doc/misc/flymake.texi: Add a 'coding' cookie. Add a
@syncodeindex directive for @vindex. Use 2 spaces between
sentences. Lower-case @cindex entries.
(Overview of Flymake): Fix use of @itemize and @pxref. Fix
punctuation and markup.
(Backend exceptions): Use @emph instead of @dfn. Add more
indexing.
(Customizable variables, Extending Flymake): Improve wording.
(Flymake error types): Fix usage of @itemize. Improve wording.
(Backend functions): Fix punctuation. Fix markup. Add a
cross-reference to ELisp manual.
(Flymake utility functions): Add a cross-reference to ELisp manual.
(An annotated example backend): Fix punctuation and typos.
(Flymake mode, Running the syntax check)
(Navigating to error lines, Backend exceptions)
(Customizable variables, Flymake error types, Backend functions)
(Flymake utility functions, Proc customization variables)
(Locating a master file, Locating the buildfile)
(Starting the syntax check process, Parsing the output)
(Interaction with other modes): Fix indexing. Add index entries
for functions, variables, and concepts.
Diffstat (limited to 'doc/misc')
| -rw-r--r-- | doc/misc/flymake.texi | 385 |
1 files changed, 219 insertions, 166 deletions
diff --git a/doc/misc/flymake.texi b/doc/misc/flymake.texi index 9207ed496f7..d89a555ff73 100644 --- a/doc/misc/flymake.texi +++ b/doc/misc/flymake.texi | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | \input texinfo @c -*-texinfo-*- | 1 | \input texinfo @c -*-texinfo; coding: utf-8 -*- |
| 2 | @comment %**start of header | 2 | @comment %**start of header |
| 3 | @setfilename ../../info/flymake.info | 3 | @setfilename ../../info/flymake.info |
| 4 | @set VERSION 0.3 | 4 | @set VERSION 0.3 |
| @@ -6,6 +6,8 @@ | |||
| 6 | @settitle GNU Flymake @value{VERSION} | 6 | @settitle GNU Flymake @value{VERSION} |
| 7 | @include docstyle.texi | 7 | @include docstyle.texi |
| 8 | @syncodeindex pg cp | 8 | @syncodeindex pg cp |
| 9 | @syncodeindex vr cp | ||
| 10 | @syncodeindex fn cp | ||
| 9 | @comment %**end of header | 11 | @comment %**end of header |
| 10 | 12 | ||
| 11 | @copying | 13 | @copying |
| @@ -61,20 +63,20 @@ modify this GNU manual.'' | |||
| 61 | 63 | ||
| 62 | @node Overview of Flymake | 64 | @node Overview of Flymake |
| 63 | @chapter Overview | 65 | @chapter Overview |
| 64 | @cindex Overview of Flymake | 66 | @cindex overview of flymake |
| 65 | 67 | ||
| 66 | Flymake is a universal on-the-fly buffer checker implemented as an | 68 | Flymake is a universal on-the-fly buffer checker implemented as an |
| 67 | Emacs minor mode. When enabled, Flymake visually annotates the buffer | 69 | Emacs minor mode. When enabled, Flymake visually annotates the buffer |
| 68 | with diagnostic information coming from one or more different sources, | 70 | with diagnostic information coming from one or more different sources, |
| 69 | or @dfn{backends}. | 71 | or @dfn{backends}. |
| 70 | 72 | ||
| 71 | Flymake annotates the buffer by highlighting problematic buffer | 73 | Flymake annotates the buffer by highlighting problematic buffer |
| 72 | regions with a special space. It displays an overall buffer status in | 74 | regions with a special space. It displays an overall buffer status in |
| 73 | the mode line containing totals for different types of diagnostics. | 75 | the mode line containing totals for different types of diagnostics. |
| 74 | 76 | ||
| 75 | @code{flymake-goto-next-error} and @code{flymake-goto-prev-error} are | 77 | @code{flymake-goto-next-error} and @code{flymake-goto-prev-error} are |
| 76 | commands that allow easy navigation to the next/previous erroneous | 78 | commands that allow easy navigation to the next/previous erroneous |
| 77 | line, respectively. If might be a good idea to map them to @kbd{M-n} | 79 | line, respectively. If might be a good idea to map them to @kbd{M-n} |
| 78 | and @kbd{M-p} in @code{flymake-mode}, by adding to your init file: | 80 | and @kbd{M-p} in @code{flymake-mode}, by adding to your init file: |
| 79 | 81 | ||
| 80 | @lisp | 82 | @lisp |
| @@ -85,42 +87,44 @@ and @kbd{M-p} in @code{flymake-mode}, by adding to your init file: | |||
| 85 | Syntax check is done ``on-the-fly''. It is started whenever | 87 | Syntax check is done ``on-the-fly''. It is started whenever |
| 86 | 88 | ||
| 87 | @itemize @bullet | 89 | @itemize @bullet |
| 88 | @item @code{flymake-mode} is started, unless | 90 | @item |
| 89 | @code{flymake-start-on-flymake-mode} is nil. | 91 | @code{flymake-mode} is started, unless |
| 92 | @code{flymake-start-on-flymake-mode} is nil. | ||
| 90 | 93 | ||
| 91 | @item a newline character is added to the buffer, unless | 94 | @item |
| 92 | @code{flymake-start-syntax-check-on-newline} is nil. | 95 | a newline character is added to the buffer, unless |
| 96 | @code{flymake-start-syntax-check-on-newline} is nil. | ||
| 93 | 97 | ||
| 94 | @item some changes were made to the buffer more than @code{0.5} | 98 | @item |
| 95 | seconds ago (the delay is configurable in | 99 | some changes were made to the buffer more than @code{0.5} seconds ago |
| 96 | @code{flymake-no-changes-timeout}). | 100 | (the delay is configurable in @code{flymake-no-changes-timeout}). |
| 97 | @end itemize | 101 | @end itemize |
| 98 | 102 | ||
| 99 | Flymake is a universal syntax checker in the sense that it's easily | 103 | Flymake is a universal syntax checker in the sense that it's easily |
| 100 | extended to support new backends @pxref{Extending Flymake}. | 104 | extended to support new backends (@pxref{Extending Flymake}). |
| 101 | 105 | ||
| 102 | Historically, Flymake used to accept diagnostics from a single, albeit | 106 | Historically, Flymake used to accept diagnostics from a single, albeit |
| 103 | reasonably flexible, backend. | 107 | reasonably flexible, backend. |
| 104 | 108 | ||
| 105 | This backend isn't (yet) obsolete and so is still available as a | 109 | This backend isn't (yet) obsolete, and so is still available as a |
| 106 | fallback and active by default(@pxref{The legacy Proc backend}). It works by | 110 | fallback and active by default (@pxref{The legacy Proc backend}). It works by |
| 107 | selecting a syntax check tool from a preconfigured list (compiler for | 111 | selecting a syntax check tool from a preconfigured list (compiler for |
| 108 | C++ files, @code{perl} for perl files, etc.), and executing it in the | 112 | C@t{++} files, @command{perl} for Perl files, etc.), and executing it in the |
| 109 | background, passing it a temporary file which is a copy of the current | 113 | background, passing it a temporary file which is a copy of the current |
| 110 | buffer, and parsing the output for known error/warning message | 114 | buffer, and parsing the output for known error/warning message |
| 111 | patterns. | 115 | patterns. |
| 112 | 116 | ||
| 113 | @node Installing Flymake | 117 | @node Installing Flymake |
| 114 | @chapter Installing | 118 | @chapter Installing |
| 115 | @cindex Installing Flymake | 119 | @cindex installing flymake |
| 116 | 120 | ||
| 117 | Flymake is included with Emacs and its main commands, like | 121 | Flymake is included with Emacs and its main commands, like |
| 118 | @code{flymake-mode}, are autoloaded. This means there is usually | 122 | @code{flymake-mode}, are autoloaded. This means there is usually |
| 119 | nothing to do by way of installation. | 123 | nothing to do by way of installation. |
| 120 | 124 | ||
| 121 | @node Using Flymake | 125 | @node Using Flymake |
| 122 | @chapter Using Flymake | 126 | @chapter Using Flymake |
| 123 | @cindex Using Flymake | 127 | @cindex using flymake |
| 124 | 128 | ||
| 125 | @menu | 129 | @menu |
| 126 | * Flymake mode:: | 130 | * Flymake mode:: |
| @@ -134,15 +138,16 @@ nothing to do by way of installation. | |||
| 134 | @node Flymake mode | 138 | @node Flymake mode |
| 135 | @section Flymake mode | 139 | @section Flymake mode |
| 136 | @cindex flymake-mode | 140 | @cindex flymake-mode |
| 141 | @cindex activating flymake-mode | ||
| 137 | 142 | ||
| 138 | Flymake is an Emacs minor mode. To use Flymake, you | 143 | Flymake is an Emacs minor mode. To use Flymake, you |
| 139 | must first activate @code{flymake-mode} by using the | 144 | must first activate @code{flymake-mode} by using the command |
| 140 | @code{flymake-mode} function. | 145 | @kbd{flymake-mode}. |
| 141 | 146 | ||
| 142 | Instead of manually activating @code{flymake-mode}, you can configure | 147 | Instead of manually activating @code{flymake-mode}, you can configure |
| 143 | Flymake to automatically enable @code{flymake-mode} upon opening any | 148 | Emacs to automatically enable @code{flymake-mode} upon opening any |
| 144 | file for which syntax check is possible. To do so, place the following | 149 | file for which syntax check is possible. To do so, place the following |
| 145 | line in @code{.emacs}: | 150 | line in your @file{~/.emacs}: |
| 146 | 151 | ||
| 147 | @lisp | 152 | @lisp |
| 148 | (add-hook 'find-file-hook 'flymake-find-file-hook) | 153 | (add-hook 'find-file-hook 'flymake-find-file-hook) |
| @@ -150,30 +155,32 @@ line in @code{.emacs}: | |||
| 150 | 155 | ||
| 151 | @node Running the syntax check | 156 | @node Running the syntax check |
| 152 | @section Running the syntax check | 157 | @section Running the syntax check |
| 153 | @cindex Manually starting the syntax check | 158 | @cindex manually starting syntax check |
| 159 | @cindex syntax check, start manually | ||
| 154 | 160 | ||
| 161 | @findex flymake-start | ||
| 155 | When @code{flymake-mode} is active, syntax check is started | 162 | When @code{flymake-mode} is active, syntax check is started |
| 156 | automatically on any of the three conditions mentioned above. Syntax | 163 | automatically on any of the three conditions mentioned in |
| 157 | check can also be started manually by using the @code{flymake-start} | 164 | @ref{Overview of Flymake}. Syntax check can also be started manually |
| 158 | command. | 165 | by typing the @kbd{M-x flymake-start @key{RET}} command. |
| 159 | 166 | ||
| 160 | @node Navigating to error lines | 167 | @node Navigating to error lines |
| 161 | @section Navigating to error lines | 168 | @section Navigating to error lines |
| 162 | @cindex Navigating to error lines | 169 | @cindex navigating to error lines |
| 163 | 170 | ||
| 164 | After syntax check is completed, lines for which at least one error or | 171 | After syntax check is completed, lines for which at least one error or |
| 165 | warning has been reported are highlighted, and total number of errors | 172 | warning has been reported are highlighted, and the total number of errors |
| 166 | and warning is shown in the mode line. Use the following functions to | 173 | and warning is shown in the mode line. Use the following functions to |
| 167 | navigate the highlighted lines: | 174 | navigate the highlighted lines: |
| 168 | 175 | ||
| 169 | @table @code | 176 | @table @code |
| 170 | 177 | @findex flymake-goto-next-error | |
| 171 | @item flymake-goto-next-error | 178 | @item flymake-goto-next-error |
| 172 | Moves point to the next erroneous line, if any. | 179 | Moves point to the next erroneous line, if any. |
| 173 | 180 | ||
| 181 | @findex flymake-goto-prev-error | ||
| 174 | @item flymake-goto-prev-error | 182 | @item flymake-goto-prev-error |
| 175 | Moves point to the previous erroneous line. | 183 | Moves point to the previous erroneous line. |
| 176 | |||
| 177 | @end table | 184 | @end table |
| 178 | 185 | ||
| 179 | If the user option @code{flymake-wrap-around} is active | 186 | If the user option @code{flymake-wrap-around} is active |
| @@ -196,7 +203,7 @@ where questioned. | |||
| 196 | @item @code{!} | 203 | @item @code{!} |
| 197 | @tab All the configured Flymake backends have disabled themselves. | 204 | @tab All the configured Flymake backends have disabled themselves. |
| 198 | Left-clicking Flymake's mode line indicator pops up a menu listing the | 205 | Left-clicking Flymake's mode line indicator pops up a menu listing the |
| 199 | option to visit Flymake's log buffer. In this buffer these situations | 206 | option to visit Flymake's log buffer. In this buffer these situations |
| 200 | can be investigated. | 207 | can be investigated. |
| 201 | 208 | ||
| 202 | @item @code{?} | 209 | @item @code{?} |
| @@ -210,38 +217,48 @@ check process. | |||
| 210 | 217 | ||
| 211 | @node Backend exceptions | 218 | @node Backend exceptions |
| 212 | @section Backend exceptions | 219 | @section Backend exceptions |
| 213 | @cindex Logging | 220 | @cindex backend exceptions |
| 214 | @cindex Backend exceptions | ||
| 215 | 221 | ||
| 222 | @cindex disabled backends | ||
| 223 | @cindex backends, disabled | ||
| 216 | Some backends may take longer than others to respond or complete, and | 224 | Some backends may take longer than others to respond or complete, and |
| 217 | some may decide to @dfn{disable} themselves if they are not suitable | 225 | some may decide to @emph{disable} themselves if they are not suitable |
| 218 | for the current buffer. A disabled backend is not tried again for | 226 | for the current buffer. A disabled backend is not tried again for |
| 219 | future checks of the current buffer. | 227 | future checks of the current buffer. |
| 220 | 228 | ||
| 229 | @findex flymake-reporting-backends | ||
| 230 | @findex flymake-running-backends | ||
| 231 | @findex flymake-disabled-backends | ||
| 221 | The commands @code{flymake-reporting-backends}, | 232 | The commands @code{flymake-reporting-backends}, |
| 222 | @code{flymake-running-backends} and @code{flymake-disabled-backends} | 233 | @code{flymake-running-backends} and @code{flymake-disabled-backends} |
| 223 | inform on the specific situation. | 234 | show the backends currently used and those which are disabled. |
| 224 | 235 | ||
| 225 | Toggling @code{flymake-mode} off and on again or invoking | 236 | @cindex reset disabled backends |
| 237 | Toggling @code{flymake-mode} off and on again, or invoking | ||
| 226 | @code{flymake-start} with a prefix argument is one way to reset the | 238 | @code{flymake-start} with a prefix argument is one way to reset the |
| 227 | disabled backend list so they will be tried again in the next check. | 239 | disabled backend list, so that they will be tried again in the next check. |
| 228 | 240 | ||
| 241 | @cindex logging | ||
| 242 | @cindex flymake logging | ||
| 229 | Flymake also uses a simple logging facility for indicating important points | 243 | Flymake also uses a simple logging facility for indicating important points |
| 230 | in the control flow. The logging facility sends logging messages to | 244 | in the control flow. The logging facility sends logging messages to |
| 231 | the @file{*Flymake log*} buffer. The information logged can be used for | 245 | the @file{*Flymake log*} buffer. The information logged can be used for |
| 232 | resolving various problems related to Flymake. | 246 | resolving various problems related to Flymake. |
| 233 | 247 | ||
| 248 | @vindex warning-minimum-log-level | ||
| 249 | @vindex warning-minimum-level | ||
| 234 | Logging output is controlled by the Emacs @code{warning-minimum-log-level} | 250 | Logging output is controlled by the Emacs @code{warning-minimum-log-level} |
| 235 | and @code{warning-minimum-level} variables. | 251 | and @code{warning-minimum-level} variables. |
| 236 | 252 | ||
| 237 | @node Customizable variables | 253 | @node Customizable variables |
| 238 | @section Customizable variables | 254 | @section Customizable variables |
| 239 | @cindex Customizable variables | 255 | @cindex customizable variables |
| 256 | @cindex variables for customizing flymake | ||
| 240 | 257 | ||
| 241 | This section summarizes customization variables used for the | 258 | This section summarizes customization variables used for the |
| 242 | configuration of the Flymake user interface. | 259 | configuration of the Flymake user interface. |
| 243 | 260 | ||
| 244 | @table @code | 261 | @vtable @code |
| 245 | @item flymake-no-changes-timeout | 262 | @item flymake-no-changes-timeout |
| 246 | If any changes are made to the buffer, syntax check is automatically | 263 | If any changes are made to the buffer, syntax check is automatically |
| 247 | started after this many seconds, unless the user makes another change, | 264 | started after this many seconds, unless the user makes another change, |
| @@ -249,7 +266,7 @@ which resets the timer. | |||
| 249 | 266 | ||
| 250 | @item flymake-start-syntax-check-on-newline | 267 | @item flymake-start-syntax-check-on-newline |
| 251 | A boolean flag indicating whether to start syntax check immediately | 268 | A boolean flag indicating whether to start syntax check immediately |
| 252 | after a newline character is added to the buffer. | 269 | after a newline character is inserted into the buffer. |
| 253 | 270 | ||
| 254 | @item flymake-start-on-flymake-mode | 271 | @item flymake-start-on-flymake-mode |
| 255 | A boolean flag indicating whether to start syntax check immediately | 272 | A boolean flag indicating whether to start syntax check immediately |
| @@ -281,12 +298,11 @@ Which fringe (if any) should show the warning/error bitmaps. | |||
| 281 | @item flymake-wrap-around | 298 | @item flymake-wrap-around |
| 282 | If non-nil, moving to errors with @code{flymake-goto-next-error} and | 299 | If non-nil, moving to errors with @code{flymake-goto-next-error} and |
| 283 | @code{flymake-goto-prev-error} wraps around buffer boundaries. | 300 | @code{flymake-goto-prev-error} wraps around buffer boundaries. |
| 284 | 301 | @end vtable | |
| 285 | @end table | ||
| 286 | 302 | ||
| 287 | @node Extending Flymake | 303 | @node Extending Flymake |
| 288 | @chapter Extending Flymake | 304 | @chapter Extending Flymake |
| 289 | @cindex Extending Flymake | 305 | @cindex extending flymake |
| 290 | 306 | ||
| 291 | Flymake can primarily be extended in one of two ways: | 307 | Flymake can primarily be extended in one of two ways: |
| 292 | 308 | ||
| @@ -299,7 +315,7 @@ different backends. | |||
| 299 | By adding a new buffer-checking backend. | 315 | By adding a new buffer-checking backend. |
| 300 | @end enumerate | 316 | @end enumerate |
| 301 | 317 | ||
| 302 | The following sections discuss each approach in detail: | 318 | The following sections discuss each approach in detail. |
| 303 | 319 | ||
| 304 | @menu | 320 | @menu |
| 305 | * Flymake error types:: | 321 | * Flymake error types:: |
| @@ -308,7 +324,10 @@ The following sections discuss each approach in detail: | |||
| 308 | 324 | ||
| 309 | @node Flymake error types | 325 | @node Flymake error types |
| 310 | @section Customizing Flymake error types | 326 | @section Customizing Flymake error types |
| 327 | @cindex customizing error types | ||
| 328 | @cindex error types, customization | ||
| 311 | 329 | ||
| 330 | @vindex flymake-diagnostic-types-alist | ||
| 312 | The variable @code{flymake-diagnostic-types-alist} is looked up by | 331 | The variable @code{flymake-diagnostic-types-alist} is looked up by |
| 313 | Flymake every time an annotation for a diagnostic is created in the | 332 | Flymake every time an annotation for a diagnostic is created in the |
| 314 | buffer. Specifically, this variable holds a table of correspondence | 333 | buffer. Specifically, this variable holds a table of correspondence |
| @@ -326,49 +345,60 @@ presents the diagnostic: | |||
| 326 | 345 | ||
| 327 | @itemize | 346 | @itemize |
| 328 | 347 | ||
| 329 | @item @code{bitmap}, an image displayed in the fringe according to | 348 | @item |
| 349 | @cindex bitmap of diagnostic | ||
| 350 | @code{bitmap}, an image displayed in the fringe according to | ||
| 330 | @code{flymake-fringe-indicator-position}. The value actually follows | 351 | @code{flymake-fringe-indicator-position}. The value actually follows |
| 331 | the syntax of @code{flymake-error-bitmap}(@pxref{Customizable | 352 | the syntax of @code{flymake-error-bitmap} (@pxref{Customizable |
| 332 | variables}). It is overridden by any @code{before-string} overlay | 353 | variables}). It is overridden by any @code{before-string} overlay |
| 333 | property. | 354 | property. |
| 334 | 355 | ||
| 335 | @item @code{severity} is a non-negative integer specifying the diagnostic's | 356 | @item |
| 336 | severity. The higher, the more serious. If the overlay property | 357 | @cindex severity of diagnostic |
| 337 | @code{priority} is not specified, @code{severity} is used to set it | 358 | @code{severity} is a non-negative integer specifying the diagnostic's |
| 338 | and help sort overlapping overlays. | 359 | severity. The higher the value, the more serious is the error. If |
| 360 | the overlay property @code{priority} is not specified, @code{severity} | ||
| 361 | is used to set it and help sort overlapping overlays. | ||
| 339 | 362 | ||
| 340 | @item Every property pertaining to overlays (@pxref{Overlay | 363 | @item |
| 341 | Properties,,, elisp, The Emacs Lisp Reference Manual}), except | 364 | Every property pertaining to overlays (@pxref{Overlay Properties,,, |
| 342 | @code{category} and @code{evaporate}. These properties are used to | 365 | elisp, The Emacs Lisp Reference Manual}), except @code{category} and |
| 343 | affect the appearance of Flymake annotations. | 366 | @code{evaporate}. These properties are used to affect the appearance |
| 367 | of Flymake annotations. | ||
| 344 | 368 | ||
| 345 | As an example, here's how to make errors (diagnostics of the type | 369 | As an example, here's how to make errors (diagnostics of the type |
| 346 | @code{:error}) stand out even more prominently in the buffer, by | 370 | @code{:error}) stand out even more prominently in the buffer, by |
| 347 | raising the characters with a @code{display} overlay property. | 371 | raising the characters using a @code{display} overlay property. |
| 348 | 372 | ||
| 349 | @example | 373 | @example |
| 350 | (push '(display . (raise 1.2)) | 374 | (push '(display . (raise 1.2)) |
| 351 | (cdr (assoc :error flymake-diagnostic-types-alist))) | 375 | (cdr (assoc :error flymake-diagnostic-types-alist))) |
| 352 | @end example | 376 | @end example |
| 353 | 377 | ||
| 354 | @item @code{flymake-category} is a symbol whose property list is considered | 378 | @item |
| 355 | a default for missing values of any other properties. | 379 | @vindex flymake-category |
| 380 | @code{flymake-category} is a symbol whose property list is considered | ||
| 381 | the default for missing values of any other properties. | ||
| 356 | @end itemize | 382 | @end itemize |
| 357 | 383 | ||
| 384 | @cindex predefined diagnostic types | ||
| 385 | @vindex flymake-error | ||
| 386 | @vindex flymake-warning | ||
| 387 | @vindex flymake-note | ||
| 358 | Three default diagnostic types, @code{:error}, @code{:warning} and | 388 | Three default diagnostic types, @code{:error}, @code{:warning} and |
| 359 | @code{:note} are predefined in | 389 | @code{:note} are predefined in |
| 360 | @code{flymake-diagnostic-types-alist}. By default each lists a single | 390 | @code{flymake-diagnostic-types-alist}. By default each lists a single |
| 361 | @code{flymake-category} property whose value is, respectively, the | 391 | @code{flymake-category} property whose value is, respectively, the |
| 362 | symbols @code{flymake-error}, @code{flymake-warning} and | 392 | symbols @code{flymake-error}, @code{flymake-warning} and |
| 363 | @code{flymake-note}. | 393 | @code{flymake-note}. |
| 364 | 394 | ||
| 365 | These category symbols' plists is where the values of customizable | 395 | These category symbols' plists is where the values of customizable |
| 366 | variables and faces such as @code{flymake-error-bitmap} are found. | 396 | variables and faces such as @code{flymake-error-bitmap} are found. |
| 367 | Thus, if you change their plists, Flymake may stop honouring these | 397 | Thus, if you change their plists, Flymake may stop honoring these |
| 368 | user customizations. | 398 | user customizations. |
| 369 | 399 | ||
| 370 | The @code{flymake-category} special property is also especially useful | 400 | The @code{flymake-category} special property is also especially useful |
| 371 | to backend authors that create diagnostics objects with non-default | 401 | for backends which create diagnostics objects with non-default |
| 372 | types that differ from an existing type by only a few properties | 402 | types that differ from an existing type by only a few properties |
| 373 | (@pxref{Flymake utility functions}). | 403 | (@pxref{Flymake utility functions}). |
| 374 | 404 | ||
| @@ -383,8 +413,9 @@ priority but without an overlay face. | |||
| 383 | (flymake-category . flymake-note)))) | 413 | (flymake-category . flymake-note)))) |
| 384 | @end example | 414 | @end example |
| 385 | 415 | ||
| 416 | @vindex flymake-text | ||
| 386 | As you might have guessed, Flymake's annotations are implemented as | 417 | As you might have guessed, Flymake's annotations are implemented as |
| 387 | overlays(@pxref{Overlays,,, elisp, The Emacs Lisp Reference Manual}). | 418 | overlays (@pxref{Overlays,,, elisp, The Emacs Lisp Reference Manual}). |
| 388 | Along with the properties that you specify for the specific type of | 419 | Along with the properties that you specify for the specific type of |
| 389 | diagnostic, Flymake adds the property @code{flymake-text} to these | 420 | diagnostic, Flymake adds the property @code{flymake-text} to these |
| 390 | overlays, and sets it to the message string that the backend used to | 421 | overlays, and sets it to the message string that the backend used to |
| @@ -392,8 +423,8 @@ describe the diagnostic. | |||
| 392 | 423 | ||
| 393 | Since overlays also support arbitrary keymaps, you can use this | 424 | Since overlays also support arbitrary keymaps, you can use this |
| 394 | property @code{flymake-text} to create interactive annotations, such | 425 | property @code{flymake-text} to create interactive annotations, such |
| 395 | as in the following example binding a @kbd{mouse-3} event (middle | 426 | as in the following example of binding a @kbd{mouse-3} event (middle |
| 396 | mouse button click) to an internet search for the text of a | 427 | mouse button click) to an Internet search for the text of a |
| 397 | @code{:warning} or @code{:error}. | 428 | @code{:warning} or @code{:error}. |
| 398 | 429 | ||
| 399 | @example | 430 | @example |
| @@ -424,82 +455,92 @@ mouse button click) to an internet search for the text of a | |||
| 424 | 455 | ||
| 425 | @node Backend functions | 456 | @node Backend functions |
| 426 | @section Backend functions | 457 | @section Backend functions |
| 458 | @cindex backend functions | ||
| 427 | 459 | ||
| 460 | @vindex flymake-diagnostic-functions | ||
| 428 | Flymake backends are Lisp functions placed in the special hook | 461 | Flymake backends are Lisp functions placed in the special hook |
| 429 | @code{flymake-diagnostic-functions}. | 462 | @code{flymake-diagnostic-functions}. |
| 430 | 463 | ||
| 431 | A backend's responsibility is to diagnose the contents of a buffer for | 464 | A backend's responsibility is to diagnose the contents of a buffer for |
| 432 | problems, registering these problem's positions, type and summarized | 465 | problems, registering the problem's positions, type, and summary |
| 433 | description. This information is collected in the form of diagnostic | 466 | description. This information is collected in the form of diagnostic |
| 434 | objects created with the function @code{flymake-make-diagnostic} and | 467 | objects created by the function @code{flymake-make-diagnostic} |
| 435 | then handed over to Flymake, which then proceeds to annotate the | 468 | (@pxref{Flymake utility functions}), and |
| 469 | then handed over to Flymake, which proceeds to annotate the | ||
| 436 | buffer. | 470 | buffer. |
| 437 | 471 | ||
| 438 | A request for a buffer check and the subsequent delivery of | 472 | A request for a buffer check, and the subsequent delivery of |
| 439 | diagnostics are the two key events of the interaction between Flymake | 473 | diagnostics, are two key events of the interaction between Flymake |
| 440 | and backend. Each such event corresponds to a well-defined function | 474 | and backend. Each such event corresponds to a well-defined function |
| 441 | calling convention: one for calls made by Flymake into the backend via | 475 | calling convention: one for calls made by Flymake into the backend via |
| 442 | the backend function, and second one in the reverse direction via a | 476 | the backend function, the other in the reverse direction via a |
| 443 | callback. To be usable, backends must adhere to both. | 477 | callback. To be usable, backends must adhere to both. |
| 444 | 478 | ||
| 445 | Backend functions must accept an arbitrary number of arguments: | 479 | Backend functions must accept an arbitrary number of arguments: |
| 446 | 480 | ||
| 447 | @itemize | 481 | @itemize |
| 448 | @item the first argument is always @var{report-fn}, a callback function | 482 | @item |
| 483 | the first argument is always @var{report-fn}, a callback function | ||
| 449 | detailed below; | 484 | detailed below; |
| 450 | 485 | ||
| 451 | @item the remaining arguments are keyword-value pairs in the | 486 | @item |
| 452 | form (@var{:key} @var{value} @var{:key2} @var{value2}...). Currently, | 487 | the remaining arguments are keyword-value pairs of the |
| 488 | form @w{@code{(@var{:key} @var{value} @var{:key2} @var{value2}...)}}. Currently, | ||
| 453 | Flymake provides no such arguments, but backend functions must be | 489 | Flymake provides no such arguments, but backend functions must be |
| 454 | prepared to accept (and possibly ignore) any number of them. | 490 | prepared to accept (and possibly ignore) any number of them. |
| 455 | @end itemize | 491 | @end itemize |
| 456 | 492 | ||
| 457 | Whenever Flymake or the user decides to re-check the buffer, backend | 493 | Whenever Flymake or the user decide to re-check the buffer, backend |
| 458 | functions are called as detailed above and are expected to initiate | 494 | functions are called as detailed above, and are expected to initiate |
| 459 | this check, but aren't in any way required to complete it before | 495 | this check, but aren't in any way required to complete it before |
| 460 | exiting: if the computation involved is computationally expensive, as | 496 | exiting: if the computation involved is expensive, as |
| 461 | is often the case in large buffers, that slower task should be | 497 | is often the case with large buffers, that slower task should be |
| 462 | scheduled for the future using asynchronous processes or other | 498 | scheduled for the future using asynchronous sub-processes |
| 463 | asynchronous mechanisms. | 499 | (@pxref{Asynchronous Processes,,, elisp, The Emacs Lisp reference |
| 500 | manual}) or other asynchronous mechanisms. | ||
| 464 | 501 | ||
| 465 | In any case, backend functions are expected to return quickly or | 502 | In any case, backend functions are expected to return quickly or |
| 466 | signal an error, in which case the backend is disabled | 503 | signal an error, in which case the backend is disabled |
| 467 | (@pxref{Backend exceptions}). | 504 | (@pxref{Backend exceptions}). |
| 468 | 505 | ||
| 469 | If the function returns, Flymake considers the backend to be | 506 | If the function returns, Flymake considers the backend to be |
| 470 | @dfn{running}. If it has not done so already, the backend is expected | 507 | @dfn{running}. If it has not done so already, the backend is expected |
| 471 | to call the function @var{report-fn} passed to it, at which point | 508 | to call the function @var{report-fn} passed to it, at which point |
| 472 | Flymake considers the backend to be @dfn{reporting}. Backends call | 509 | Flymake considers the backend to be @dfn{reporting}. Backends call |
| 473 | @var{report-fn} by passing it a single argument @var{report-action} | 510 | @var{report-fn} by passing it a single argument @var{report-action} |
| 474 | followed by an optional list of keyword-value pairs in the form | 511 | followed by an optional list of keyword-value pairs of the form |
| 475 | (@var{:report-key} @var{value} @var{:report-key2} @var{value2}...). | 512 | @w{@code{(@var{:report-key} @var{value} @var{:report-key2} @var{value2}...)}}. |
| 476 | 513 | ||
| 477 | Currently accepted values for @var{report-action} are: | 514 | Currently accepted values for @var{report-action} are: |
| 478 | 515 | ||
| 479 | @itemize | 516 | @itemize |
| 480 | @item A (possibly empty) list of diagnostic objects created with | 517 | @item |
| 518 | A (possibly empty) list of diagnostic objects created by | ||
| 481 | @code{flymake-make-diagnostic}, causing Flymake to annotate the | 519 | @code{flymake-make-diagnostic}, causing Flymake to annotate the |
| 482 | buffer with this information. | 520 | buffer with this information. |
| 483 | 521 | ||
| 484 | A backend may call @var{report-fn} repeatedly in this manner, but only | 522 | A backend may call @var{report-fn} repeatedly in this manner, but only |
| 485 | until Flymake considers that the most recently requested buffer check | 523 | until Flymake considers that the most recently requested buffer check |
| 486 | is now obsolete because, say, buffer contents have changed in the | 524 | is now obsolete, because, say, buffer contents have changed in the |
| 487 | meantime. The backend is only given notice of this via a renewed call | 525 | meantime. The backend is only given notice of this via a renewed call |
| 488 | to the backend function. Thus, to prevent making obsolete reports and | 526 | to the backend function. Thus, to prevent making obsolete reports and |
| 489 | wasting resources, backend functions should first cancel any ongoing | 527 | wasting resources, backend functions should first cancel any ongoing |
| 490 | processing from previous calls. | 528 | processing from previous calls. |
| 491 | 529 | ||
| 492 | @item The symbol @code{:panic}, signaling that the backend has encountered | 530 | @item |
| 531 | The symbol @code{:panic}, signaling that the backend has encountered | ||
| 493 | an exceptional situation and should be disabled. | 532 | an exceptional situation and should be disabled. |
| 494 | @end itemize | 533 | @end itemize |
| 495 | 534 | ||
| 496 | Currently accepted @var{report-key} arguments are: | 535 | Currently accepted @var{report-key} arguments are: |
| 497 | 536 | ||
| 498 | @itemize | 537 | @itemize |
| 499 | @item @code{:explanation}: value should give user-readable | 538 | @item |
| 539 | @code{:explanation}, whose value should give user-readable | ||
| 500 | details of the situation encountered, if any. | 540 | details of the situation encountered, if any. |
| 501 | 541 | ||
| 502 | @item @code{:force}: value should be a boolean suggesting | 542 | @item |
| 543 | @code{:force}, whose value should be a boolean suggesting | ||
| 503 | that Flymake consider the report even if it was somehow | 544 | that Flymake consider the report even if it was somehow |
| 504 | unexpected. | 545 | unexpected. |
| 505 | @end itemize | 546 | @end itemize |
| @@ -511,7 +552,9 @@ unexpected. | |||
| 511 | 552 | ||
| 512 | @node Flymake utility functions | 553 | @node Flymake utility functions |
| 513 | @subsection Flymake utility functions | 554 | @subsection Flymake utility functions |
| 555 | @cindex utility functions | ||
| 514 | 556 | ||
| 557 | @cindex create diagnostic object | ||
| 515 | Before delivering them to Flymake, backends create diagnostic objects | 558 | Before delivering them to Flymake, backends create diagnostic objects |
| 516 | by calling the function @code{flymake-make-diagnostic}. | 559 | by calling the function @code{flymake-make-diagnostic}. |
| 517 | 560 | ||
| @@ -522,36 +565,41 @@ Make a Flymake diagnostic for @var{buffer}'s region from @var{beg} to | |||
| 522 | of the problem detected in this region. | 565 | of the problem detected in this region. |
| 523 | @end deffn | 566 | @end deffn |
| 524 | 567 | ||
| 568 | @cindex buffer position from line and column number | ||
| 525 | It is often the case with external syntax tools that a diagnostic's | 569 | It is often the case with external syntax tools that a diagnostic's |
| 526 | position is reported in terms of a line number, and sometimes a column | 570 | position is reported in terms of a line number, and sometimes a column |
| 527 | number. To convert this information into a buffer position, backends | 571 | number. To convert this information into a buffer position, backends |
| 528 | can use the following function: | 572 | can use the following function: |
| 529 | 573 | ||
| 530 | @deffn Function flymake-diag-region buffer line &optional col | 574 | @deffn Function flymake-diag-region buffer line &optional col |
| 531 | Compute @var{buffer}'s region (@var{beg} . @var{end}) corresponding to | 575 | Compute @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 | 576 | @var{line} and @var{col}. If @var{col} is nil, return a region just |
| 533 | for @var{line}. Return nil if the region is invalid. | 577 | for @var{line}. Return nil if the region is invalid. |
| 534 | @end deffn | 578 | @end deffn |
| 535 | 579 | ||
| 580 | @cindex add a log message | ||
| 536 | For troubleshooting purposes, backends may record arbitrary | 581 | For troubleshooting purposes, backends may record arbitrary |
| 537 | exceptional or erroneous situations into the Flymake log | 582 | exceptional or erroneous situations into the Flymake log |
| 538 | buffer (@pxref{Backend exceptions}): | 583 | buffer (@pxref{Backend exceptions}): |
| 539 | 584 | ||
| 540 | @deffn Macro flymake-log level msg &optional args | 585 | @deffn Macro flymake-log level msg &optional args |
| 541 | Log, at level @var{level}, the message @var{msg} formatted with | 586 | Log, at level @var{level}, the message @var{msg} formatted with |
| 542 | @var{args}. @var{level} is passed to @code{display-warning}, which is | 587 | @var{args}. @var{level} is passed to @code{display-warning} |
| 588 | (@pxref{Warning Basics,,, elisp, The Emacs Lisp reference Manual}), which is | ||
| 543 | used to display the warning in Flymake's log buffer. | 589 | used to display the warning in Flymake's log buffer. |
| 544 | @end deffn | 590 | @end deffn |
| 545 | 591 | ||
| 546 | @node An annotated example backend | 592 | @node An annotated example backend |
| 547 | @subsection An annotated example backend | 593 | @subsection An annotated example backend |
| 594 | @cindex example of backend | ||
| 595 | @cindex backend, annotated example | ||
| 548 | 596 | ||
| 549 | This section presents an annotated example of a complete working | 597 | This section presents an annotated example of a complete working |
| 550 | Flymake backend. The example illustrates the process of writing a | 598 | Flymake backend. The example illustrates the process of writing a |
| 551 | backend as outlined above. | 599 | backend as outlined above. |
| 552 | 600 | ||
| 553 | The backend in question is used for checking Ruby source files. It | 601 | The backend in question is used for checking Ruby source files. It |
| 554 | uses asynchronous processes (@pxref{Asynchronous Processes,,, elisp, | 602 | uses asynchronous sub-processes (@pxref{Asynchronous Processes,,, elisp, |
| 555 | The Emacs Lisp Reference Manual}), a common technique for performing | 603 | The Emacs Lisp Reference Manual}), a common technique for performing |
| 556 | parallel processing in Emacs. | 604 | parallel processing in Emacs. |
| 557 | 605 | ||
| @@ -569,39 +617,39 @@ Binding,,, elisp, The Emacs Lisp Reference Manual}) to be active. | |||
| 569 | (unless (executable-find | 617 | (unless (executable-find |
| 570 | "ruby") (error "Cannot find a suitable ruby")) | 618 | "ruby") (error "Cannot find a suitable ruby")) |
| 571 | ;; If a live process launched in an earlier check was found, that | 619 | ;; If a live process launched in an earlier check was found, that |
| 572 | ;; process is killed. When that process's sentinel eventually runs, | 620 | ;; process is killed. When that process's sentinel eventually runs, |
| 573 | ;; it will notice its obsoletion, since if have since reset | 621 | ;; it will notice its obsoletion, since it have since reset |
| 574 | ;; `ruby-flymake-proc' to a different value | 622 | ;; `ruby-flymake-proc' to a different value |
| 575 | ;; | 623 | ;; |
| 576 | (when (process-live-p ruby--flymake-proc) | 624 | (when (process-live-p ruby--flymake-proc) |
| 577 | (kill-process ruby--flymake-proc)) | 625 | (kill-process ruby--flymake-proc)) |
| 578 | 626 | ||
| 579 | ;; save the current buffer, the narrowing restrinction, remove any | 627 | ;; Save the current buffer, the narrowing restriction, remove any |
| 580 | ;; narrowing restriction | 628 | ;; narrowing restriction. |
| 581 | ;; | 629 | ;; |
| 582 | (let ((source (current-buffer))) | 630 | (let ((source (current-buffer))) |
| 583 | (save-restriction | 631 | (save-restriction |
| 584 | (widen) | 632 | (widen) |
| 585 | ;; reset the `ruby--flymake-proc' process to a new process | 633 | ;; Reset the `ruby--flymake-proc' process to a new process |
| 586 | ;; calling the ruby tool | 634 | ;; calling the ruby tool. |
| 587 | ;; | 635 | ;; |
| 588 | (setq | 636 | (setq |
| 589 | ruby--flymake-proc | 637 | ruby--flymake-proc |
| 590 | (make-process | 638 | (make-process |
| 591 | :name "ruby-flymake" :noquery t :connection-type 'pipe | 639 | :name "ruby-flymake" :noquery t :connection-type 'pipe |
| 592 | ;; make output goes to a temporary buffer | 640 | ;; Make output go to a temporary buffer. |
| 593 | ;; | 641 | ;; |
| 594 | :buffer (generate-new-buffer " *ruby-flymake*") | 642 | :buffer (generate-new-buffer " *ruby-flymake*") |
| 595 | :command '("ruby" "-w" "-c") | 643 | :command '("ruby" "-w" "-c") |
| 596 | :sentinel | 644 | :sentinel |
| 597 | (lambda (proc _event) | 645 | (lambda (proc _event) |
| 598 | ;; Check that the process as indeed exited, as it might | 646 | ;; Check that the process has indeed exited, as it might |
| 599 | ;; be simply suspended | 647 | ;; be simply suspended. |
| 600 | ;; | 648 | ;; |
| 601 | (when (eq 'exit (process-status proc)) | 649 | (when (eq 'exit (process-status proc)) |
| 602 | (unwind-protect | 650 | (unwind-protect |
| 603 | ;; Only proceed if `proc' is the same as | 651 | ;; Only proceed if `proc' is the same as |
| 604 | ;; `ruby--flymake-proc' which indicates that | 652 | ;; `ruby--flymake-proc', which indicates that |
| 605 | ;; `proc' is not an obsolete process. | 653 | ;; `proc' is not an obsolete process. |
| 606 | ;; | 654 | ;; |
| 607 | (if (eq proc ruby--flymake-proc) | 655 | (if (eq proc ruby--flymake-proc) |
| @@ -635,8 +683,8 @@ Binding,,, elisp, The Emacs Lisp Reference Manual}) to be active. | |||
| 635 | ;; check's output. | 683 | ;; check's output. |
| 636 | ;; | 684 | ;; |
| 637 | (kill-buffer (process-buffer proc))))))) | 685 | (kill-buffer (process-buffer proc))))))) |
| 638 | ;; send the buffer contents to the process's stdin, followed by | 686 | ;; Send the buffer contents to the process's stdin, followed by |
| 639 | ;; an EOF | 687 | ;; an EOF. |
| 640 | ;; | 688 | ;; |
| 641 | (process-send-region ruby--flymake-proc (point-min) (point-max)) | 689 | (process-send-region ruby--flymake-proc (point-min) (point-max)) |
| 642 | (process-send-eof ruby--flymake-proc)))) | 690 | (process-send-eof ruby--flymake-proc)))) |
| @@ -649,7 +697,7 @@ Binding,,, elisp, The Emacs Lisp Reference Manual}) to be active. | |||
| 649 | 697 | ||
| 650 | @node The legacy Proc backend | 698 | @node The legacy Proc backend |
| 651 | @chapter The legacy ``Proc'' backend | 699 | @chapter The legacy ``Proc'' backend |
| 652 | @cindex The legacy Proc backend | 700 | @cindex legacy proc backend |
| 653 | 701 | ||
| 654 | @menu | 702 | @menu |
| 655 | * Proc customization variables:: | 703 | * Proc customization variables:: |
| @@ -664,15 +712,16 @@ Binding,,, elisp, The Emacs Lisp Reference Manual}) to be active. | |||
| 664 | * Interaction with other modes:: | 712 | * Interaction with other modes:: |
| 665 | @end menu | 713 | @end menu |
| 666 | 714 | ||
| 715 | @findex flymake-proc-legacy-backend | ||
| 667 | The backend @code{flymake-proc-legacy-backend} was originally designed | 716 | The backend @code{flymake-proc-legacy-backend} was originally designed |
| 668 | to be extended for supporting new syntax check tools and error message | 717 | to be extended for supporting new syntax check tools and error message |
| 669 | patterns. It is also controlled by its own set of customization variables | 718 | patterns. It is also controlled by its own set of customization variables |
| 670 | 719 | ||
| 671 | @node Proc customization variables | 720 | @node Proc customization variables |
| 672 | @section Customization variables for the Proc backend | 721 | @section Customization variables for the Proc backend |
| 673 | @cindex Proc customization variables | 722 | @cindex proc backend customization variables |
| 674 | 723 | ||
| 675 | @table @code | 724 | @vtable @code |
| 676 | @item flymake-proc-allowed-file-name-masks | 725 | @item flymake-proc-allowed-file-name-masks |
| 677 | A list of @code{(filename-regexp, init-function, cleanup-function | 726 | A list of @code{(filename-regexp, init-function, cleanup-function |
| 678 | getfname-function)} for configuring syntax check tools. @xref{Adding | 727 | getfname-function)} for configuring syntax check tools. @xref{Adding |
| @@ -696,22 +745,22 @@ line-idx col-idx err-text-idx)}. @xref{Parsing the output}. | |||
| 696 | 745 | ||
| 697 | @item flymake-proc-diagnostic-type-pred | 746 | @item flymake-proc-diagnostic-type-pred |
| 698 | A function to classify a diagnostic text as particular type of | 747 | A function to classify a diagnostic text as particular type of |
| 699 | error. Should be a function taking an error text and returning one of | 748 | error. Should be a function taking an error text and returning one of |
| 700 | the symbols indexing @code{flymake-diagnostic-types-alist}. If non-nil | 749 | the symbols indexing @code{flymake-diagnostic-types-alist}. If non-nil |
| 701 | is returned but there is no such symbol in that table, a warning is | 750 | is returned but there is no such symbol in that table, a warning is |
| 702 | assumed. If nil is returned, an error is assumed. Can also be a | 751 | assumed. If nil is returned, an error is assumed. Can also be a |
| 703 | regular expression that should match only warnings. This variable | 752 | regular expression that should match only warnings. This variable |
| 704 | replaces the old @code{flymake-warning-re} and | 753 | replaces the old @code{flymake-warning-re} and |
| 705 | @code{flymake-warning-predicate}. | 754 | @code{flymake-warning-predicate}. |
| 706 | 755 | ||
| 707 | @item flymake-proc-compilation-prevents-syntax-check | 756 | @item flymake-proc-compilation-prevents-syntax-check |
| 708 | A flag indicating whether compilation and syntax check of the same | 757 | A flag indicating whether compilation and syntax check of the same |
| 709 | file cannot be run simultaneously. | 758 | file cannot be run simultaneously. @xref{Interaction with other modes}. |
| 710 | @end table | 759 | @end vtable |
| 711 | 760 | ||
| 712 | @node Adding support for a new syntax check tool | 761 | @node Adding support for a new syntax check tool |
| 713 | @section Adding support for a new syntax check tool | 762 | @section Adding support for a new syntax check tool |
| 714 | @cindex Adding support for a new syntax check tool | 763 | @cindex adding support for a new syntax check tool |
| 715 | 764 | ||
| 716 | @menu | 765 | @menu |
| 717 | * Example---Configuring a tool called directly:: | 766 | * Example---Configuring a tool called directly:: |
| @@ -753,10 +802,9 @@ will be different from the real ones, as actually the tool works with | |||
| 753 | the temporary copy. In most cases, the default implementation | 802 | the temporary copy. In most cases, the default implementation |
| 754 | provided by Flymake, @code{flymake-proc-get-real-file-name}, can be | 803 | provided by Flymake, @code{flymake-proc-get-real-file-name}, can be |
| 755 | used as @code{getfname-function}. | 804 | used as @code{getfname-function}. |
| 756 | |||
| 757 | @end table | 805 | @end table |
| 758 | 806 | ||
| 759 | To add support for a new syntax check tool, write corresponding | 807 | To add support for a new syntax check tool, write the corresponding |
| 760 | @code{init-function} and, optionally, @code{cleanup-function} and | 808 | @code{init-function} and, optionally, @code{cleanup-function} and |
| 761 | @code{getfname-function}. If the format of error messages reported by | 809 | @code{getfname-function}. If the format of error messages reported by |
| 762 | the new tool is not yet supported by Flymake, add a new entry to | 810 | the new tool is not yet supported by Flymake, add a new entry to |
| @@ -767,10 +815,10 @@ support for various syntax check tools. | |||
| 767 | 815 | ||
| 768 | @node Example---Configuring a tool called directly | 816 | @node Example---Configuring a tool called directly |
| 769 | @subsection Example---Configuring a tool called directly | 817 | @subsection Example---Configuring a tool called directly |
| 770 | @cindex Adding support for perl | 818 | @cindex adding support for perl |
| 771 | 819 | ||
| 772 | In this example, we will add support for @code{perl} as a syntax check | 820 | In this example, we will add support for @command{perl} as a syntax check |
| 773 | tool. @code{perl} supports the @code{-c} option which does syntax | 821 | tool. @command{perl} supports the @option{-c} option which does syntax |
| 774 | checking. | 822 | checking. |
| 775 | 823 | ||
| 776 | First, we write the @code{init-function}: | 824 | First, we write the @code{init-function}: |
| @@ -816,7 +864,7 @@ Finally, we add an entry to @code{flymake-proc-err-line-patterns}: | |||
| 816 | 864 | ||
| 817 | @node Example---Configuring a tool called via make | 865 | @node Example---Configuring a tool called via make |
| 818 | @subsection Example---Configuring a tool called via make | 866 | @subsection Example---Configuring a tool called via make |
| 819 | @cindex Adding support for C (gcc+make) | 867 | @cindex adding support for C (gcc+make) |
| 820 | 868 | ||
| 821 | In this example we will add support for C files syntax checked by | 869 | In this example we will add support for C files syntax checked by |
| 822 | @command{gcc} called via @command{make}. | 870 | @command{gcc} called via @command{make}. |
| @@ -846,9 +894,10 @@ command line: | |||
| 846 | "check-syntax")) | 894 | "check-syntax")) |
| 847 | @end lisp | 895 | @end lisp |
| 848 | 896 | ||
| 849 | @code{base-dir} is a directory containing @code{Makefile}, see @ref{Locating the buildfile}. | 897 | @code{base-dir} is a directory containing the @file{Makefile}, see |
| 898 | @ref{Locating the buildfile}. | ||
| 850 | 899 | ||
| 851 | Thus, @code{Makefile} must contain the @code{check-syntax} target. In | 900 | Thus, @file{Makefile} must contain the @code{check-syntax} target. In |
| 852 | our case this target might look like this: | 901 | our case this target might look like this: |
| 853 | 902 | ||
| 854 | @verbatim | 903 | @verbatim |
| @@ -870,11 +919,11 @@ check-syntax: | |||
| 870 | 919 | ||
| 871 | @node Implementation overview | 920 | @node Implementation overview |
| 872 | @section Implementation overview | 921 | @section Implementation overview |
| 873 | @cindex Syntax check models | 922 | @cindex syntax check models |
| 874 | @cindex Master file | 923 | @cindex master file |
| 875 | 924 | ||
| 876 | @code{flymake-proc-legacy-backend} saves a copy of the buffer in a | 925 | @code{flymake-proc-legacy-backend} saves a copy of the buffer in a |
| 877 | temporary file in the buffer's directory (or in the system temp | 926 | temporary file in the buffer's directory (or in the system temporary |
| 878 | directory, for Java files), creates a syntax check command and | 927 | directory, for Java files), creates a syntax check command and |
| 879 | launches a process with this command. The output is parsed using a | 928 | launches a process with this command. The output is parsed using a |
| 880 | list of error message patterns, and error information (file name, line | 929 | list of error message patterns, and error information (file name, line |
| @@ -893,15 +942,15 @@ Two syntax check modes are distinguished: | |||
| 893 | @item | 942 | @item |
| 894 | Buffer can be syntax checked in a standalone fashion, that is, the | 943 | Buffer can be syntax checked in a standalone fashion, that is, the |
| 895 | file (its temporary copy, in fact) can be passed over to the compiler to | 944 | file (its temporary copy, in fact) can be passed over to the compiler to |
| 896 | do the syntax check. Examples are C/C++ (.c, .cpp) and Java (.java) | 945 | do the syntax check. Examples are C/C@t{++} sources (@file{.c}, |
| 897 | sources. | 946 | @file{.cpp}) and Java (@file{.java}). |
| 898 | 947 | ||
| 899 | @item | 948 | @item |
| 900 | Buffer can be syntax checked, but additional file, called master file, | 949 | Buffer can be syntax checked, but additional file, called master file, |
| 901 | is required to perform this operation. A master file is a file that | 950 | is required to perform this operation. A master file is a file that |
| 902 | includes the current file, so that running a syntax check tool on it | 951 | includes the current file, so that running a syntax check tool on it |
| 903 | will also check syntax in the current file. Examples are C/C++ (.h, | 952 | will also check syntax in the current file. Examples are C/C@t{++} |
| 904 | .hpp) headers. | 953 | headers (@file{.h}, @file{.hpp}). |
| 905 | 954 | ||
| 906 | @end enumerate | 955 | @end enumerate |
| 907 | 956 | ||
| @@ -916,8 +965,7 @@ tool-specific (routines for Make, Ant, etc.)@: code. | |||
| 916 | 965 | ||
| 917 | @node Making a temporary copy | 966 | @node Making a temporary copy |
| 918 | @section Making a temporary copy | 967 | @section Making a temporary copy |
| 919 | @cindex Temporary copy of the buffer | 968 | @cindex temporary copy of the buffer |
| 920 | @cindex Master file | ||
| 921 | 969 | ||
| 922 | After the possibility of the syntax check has been determined, a | 970 | After the possibility of the syntax check has been determined, a |
| 923 | temporary copy of the current buffer is made so that the most recent | 971 | temporary copy of the current buffer is made so that the most recent |
| @@ -929,9 +977,10 @@ Things get trickier, however, when master file is involved, as it | |||
| 929 | requires to | 977 | requires to |
| 930 | 978 | ||
| 931 | @itemize @bullet | 979 | @itemize @bullet |
| 932 | @item locate a master file | 980 | @item |
| 933 | @item patch it to include the current file using its new (temporary) | 981 | locate a master file |
| 934 | name. | 982 | @item |
| 983 | patch it to include the current file using its new (temporary) name. | ||
| 935 | @end itemize | 984 | @end itemize |
| 936 | 985 | ||
| 937 | Locating a master file is discussed in the following section. | 986 | Locating a master file is discussed in the following section. |
| @@ -947,37 +996,39 @@ the syntax check tool. | |||
| 947 | 996 | ||
| 948 | @node Locating a master file | 997 | @node Locating a master file |
| 949 | @section Locating a master file | 998 | @section Locating a master file |
| 950 | @cindex Master file | 999 | @cindex locating a master file |
| 1000 | @cindex master file, locating | ||
| 951 | 1001 | ||
| 952 | Master file is located in two steps. | 1002 | Master file is located in two steps. |
| 953 | 1003 | ||
| 954 | First, a list of possible master files is built. A simple name | 1004 | First, a list of possible master files is built. A simple name |
| 955 | matching is used to find the files. For a C++ header @code{file.h}, | 1005 | matching is used to find the files. For a C++ header @file{file.h}, |
| 956 | the Proc backend searches for all @code{.cpp} files in the directories | 1006 | the Proc backend searches for all @file{.cpp} files in the directories |
| 957 | whose relative paths are stored in a customizable variable | 1007 | whose relative paths are stored in a customizable variable |
| 958 | @code{flymake-proc-master-file-dirs}, which usually contains something | 1008 | @code{flymake-proc-master-file-dirs}, which usually contains something |
| 959 | like @code{("." "./src")}. No more than | 1009 | like @code{("." "./src")}. No more than |
| 960 | @code{flymake-proc-master-file-count-limit} entries is added to the | 1010 | @code{flymake-proc-master-file-count-limit} entries is added to the |
| 961 | master file list. The list is then sorted to move files with names | 1011 | master file list. The list is then sorted to move files with names |
| 962 | @code{file.cpp} to the top. | 1012 | @file{file.cpp} to the top. |
| 963 | 1013 | ||
| 964 | Next, each master file in a list is checked to contain the appropriate | 1014 | Next, each master file in a list is checked to contain the appropriate |
| 965 | include directives. No more than @code{flymake-proc-check-file-limit} of each | 1015 | include directives. No more than @code{flymake-proc-check-file-limit} of each |
| 966 | file are parsed. | 1016 | file are parsed. |
| 967 | 1017 | ||
| 968 | For @code{file.h}, the include directives to look for are | 1018 | For @file{file.h}, the include directives to look for are |
| 969 | @code{#include "file.h"}, @code{#include "../file.h"}, etc. Each | 1019 | @code{#include "file.h"}, @code{#include "../file.h"}, etc. Each |
| 970 | include is checked against a list of include directories | 1020 | include is checked against a list of include directories |
| 971 | (see @ref{Getting the include directories}) to be sure it points to the | 1021 | (see @ref{Getting the include directories}) to be sure it points to the |
| 972 | correct @code{file.h}. | 1022 | correct @file{file.h}. |
| 973 | 1023 | ||
| 974 | First matching master file found stops the search. The master file is then | 1024 | First matching master file found stops the search. The master file is then |
| 975 | patched and saved to disk. In case no master file is found, syntax check is | 1025 | patched and saved to disk. In case no master file is found, syntax check is |
| 976 | aborted, and corresponding status (!) is reported in the mode line. | 1026 | aborted, and corresponding status (@samp{!}) is reported in the mode line. |
| 1027 | @xref{Syntax check statuses}. | ||
| 977 | 1028 | ||
| 978 | @node Getting the include directories | 1029 | @node Getting the include directories |
| 979 | @section Getting the include directories | 1030 | @section Getting the include directories |
| 980 | @cindex Include directories (C/C++ specific) | 1031 | @cindex include directories (C/C++ specific) |
| 981 | 1032 | ||
| 982 | Two sets of include directories are distinguished: system include directories | 1033 | Two sets of include directories are distinguished: system include directories |
| 983 | and project include directories. The former is just the contents of the | 1034 | and project include directories. The former is just the contents of the |
| @@ -997,25 +1048,26 @@ of every syntax check attempt. | |||
| 997 | 1048 | ||
| 998 | @node Locating the buildfile | 1049 | @node Locating the buildfile |
| 999 | @section Locating the buildfile | 1050 | @section Locating the buildfile |
| 1000 | @cindex Locating the buildfile | 1051 | @cindex locating the buildfile |
| 1001 | @cindex buildfile, locating | 1052 | @cindex buildfile, locating |
| 1002 | @cindex Makefile, locating | 1053 | @cindex Makefile, locating |
| 1003 | 1054 | ||
| 1004 | The Proc backend can be configured to use different tools for | 1055 | The Proc backend can be configured to use different tools for |
| 1005 | performing syntax checks. For example, it can use direct compiler | 1056 | performing syntax checks. For example, it can use direct compiler |
| 1006 | call to syntax check a perl script or a call to @command{make} for a | 1057 | call to syntax check a perl script or a call to @command{make} for a |
| 1007 | more complicated case of a @code{C/C++} source. The general idea is | 1058 | more complicated case of a C/C@t{++} source. The general idea is |
| 1008 | that simple files, like perl scripts and html pages, can be checked by | 1059 | that simple files, like Perl scripts and @acronym{HTML} pages, can be checked by |
| 1009 | directly invoking a corresponding tool. Files that are usually more | 1060 | directly invoking a corresponding tool. Files that are usually more |
| 1010 | complex and generally used as part of larger projects, might require | 1061 | complex and generally used as part of larger projects, might require |
| 1011 | non-trivial options to be passed to the syntax check tool, like | 1062 | non-trivial options to be passed to the syntax check tool, like |
| 1012 | include directories for C++. The latter files are syntax checked | 1063 | include directories for C@t{++}. The latter files are syntax checked |
| 1013 | using some build tool, like Make or Ant. | 1064 | using some build tool, like Make or Ant. |
| 1014 | 1065 | ||
| 1015 | All Make configuration data is usually stored in a file called | 1066 | All Make configuration data is usually stored in a file called |
| 1016 | @code{Makefile}. To allow for future extensions, Flymake uses a notion of | 1067 | @file{Makefile}. To allow for future extensions, Flymake uses a notion of |
| 1017 | buildfile to reference the 'project configuration' file. | 1068 | buildfile to reference the @dfn{project configuration} file. |
| 1018 | 1069 | ||
| 1070 | @findex flymake-proc-find-buildfile | ||
| 1019 | Special function, @code{flymake-proc-find-buildfile} is provided for locating buildfiles. | 1071 | Special function, @code{flymake-proc-find-buildfile} is provided for locating buildfiles. |
| 1020 | Searching for a buildfile is done in a manner similar to that of searching | 1072 | Searching for a buildfile is done in a manner similar to that of searching |
| 1021 | for possible master files. | 1073 | for possible master files. |
| @@ -1024,13 +1076,13 @@ A customizable variable | |||
| 1024 | @code{flymake-proc-buildfile-dirs} holds a list of relative paths to the | 1076 | @code{flymake-proc-buildfile-dirs} holds a list of relative paths to the |
| 1025 | buildfile. They are checked sequentially until a buildfile is found. | 1077 | buildfile. They are checked sequentially until a buildfile is found. |
| 1026 | @end ignore | 1078 | @end ignore |
| 1027 | In case there's no build file, syntax check is aborted. | 1079 | In case there's no build file, the syntax check is aborted. |
| 1028 | 1080 | ||
| 1029 | Buildfile values are also cached. | 1081 | Buildfile values are also cached. |
| 1030 | 1082 | ||
| 1031 | @node Starting the syntax check process | 1083 | @node Starting the syntax check process |
| 1032 | @section Starting the syntax check process | 1084 | @section Starting the syntax check process |
| 1033 | @cindex Syntax check process | 1085 | @cindex syntax check process, legacy proc backend |
| 1034 | 1086 | ||
| 1035 | The command line (command name and the list of arguments) for | 1087 | The command line (command name and the list of arguments) for |
| 1036 | launching a process is returned by the initialization function. The | 1088 | launching a process is returned by the initialization function. The |
| @@ -1041,16 +1093,16 @@ be killed without prompting the user. | |||
| 1041 | 1093 | ||
| 1042 | @node Parsing the output | 1094 | @node Parsing the output |
| 1043 | @section Parsing the output | 1095 | @section Parsing the output |
| 1044 | @cindex Parsing the output | 1096 | @cindex parsing the output, legacy proc backend |
| 1045 | 1097 | ||
| 1046 | The output generated by the syntax check tool is parsed in the process | 1098 | The output generated by the syntax check tool is parsed in the process |
| 1047 | filter/sentinel using the error message patterns stored in the | 1099 | filter/sentinel using the error message patterns stored in the |
| 1048 | @code{flymake-proc-err-line-patterns} variable. This variable contains a | 1100 | @code{flymake-proc-err-line-patterns} variable. This variable contains a |
| 1049 | list of items of the form @code{(regexp file-idx line-idx | 1101 | list of items of the form @w{@code{(regexp file-idx line-idx |
| 1050 | err-text-idx)}, used to determine whether a particular line is an | 1102 | err-text-idx)}}, used to determine whether a particular line is an |
| 1051 | error message and extract file name, line number and error text, | 1103 | error message and extract file name, line number and error text, |
| 1052 | respectively. Error type (error/warning) is also guessed by matching | 1104 | respectively. Error type (error/warning) is also guessed by matching |
| 1053 | error text with the '@code{^[wW]arning}' pattern. Anything that was not | 1105 | error text with the @samp{^[wW]arning} pattern. Anything that was not |
| 1054 | classified as a warning is considered an error. Type is then used to | 1106 | classified as a warning is considered an error. Type is then used to |
| 1055 | sort error menu items, which shows error messages first. | 1107 | sort error menu items, which shows error messages first. |
| 1056 | 1108 | ||
| @@ -1058,7 +1110,7 @@ The Proc backend is also able to interpret error message patterns | |||
| 1058 | missing err-text-idx information. This is done by merely taking the | 1110 | missing err-text-idx information. This is done by merely taking the |
| 1059 | rest of the matched line (@code{(substring line (match-end 0))}) as | 1111 | rest of the matched line (@code{(substring line (match-end 0))}) as |
| 1060 | error text. This trick allows making use of a huge collection of | 1112 | error text. This trick allows making use of a huge collection of |
| 1061 | error message line patterns from @code{compile.el}. All these error | 1113 | error message line patterns from @file{compile.el}. All these error |
| 1062 | patterns are appended to the end of | 1114 | patterns are appended to the end of |
| 1063 | @code{flymake-proc-err-line-patterns}. | 1115 | @code{flymake-proc-err-line-patterns}. |
| 1064 | 1116 | ||
| @@ -1069,8 +1121,8 @@ after every process launch/exit. | |||
| 1069 | 1121 | ||
| 1070 | @node Interaction with other modes | 1122 | @node Interaction with other modes |
| 1071 | @section Interaction with other modes | 1123 | @section Interaction with other modes |
| 1072 | @cindex Interaction with other modes | 1124 | @cindex interaction with other modes, legacy proc backend |
| 1073 | @cindex Interaction with compile mode | 1125 | @cindex interaction with compile mode, legacy proc backend |
| 1074 | 1126 | ||
| 1075 | The only mode the Proc backend currently knows about is | 1127 | The only mode the Proc backend currently knows about is |
| 1076 | @code{compile}. | 1128 | @code{compile}. |
| @@ -1084,8 +1136,9 @@ though, was working around a locking problem with MS Visual C++ | |||
| 1084 | compiler. The variable in question is | 1136 | compiler. The variable in question is |
| 1085 | @code{flymake-proc-compilation-prevents-syntax-check}. | 1137 | @code{flymake-proc-compilation-prevents-syntax-check}. |
| 1086 | 1138 | ||
| 1139 | @findex flymake-proc-compile | ||
| 1087 | The Proc backend also provides an alternative command for starting | 1140 | The Proc backend also provides an alternative command for starting |
| 1088 | compilation, @code{flymake-proc-compile}. It just kills all the active | 1141 | compilation, @code{flymake-proc-compile}. It just kills all the active |
| 1089 | syntax check processes before calling @code{compile}. | 1142 | syntax check processes before calling @code{compile}. |
| 1090 | 1143 | ||
| 1091 | @node GNU Free Documentation License | 1144 | @node GNU Free Documentation License |