diff options
| author | Xue Fuqiao | 2013-05-25 09:26:12 +0800 |
|---|---|---|
| committer | Xue Fuqiao | 2013-05-25 09:26:12 +0800 |
| commit | 5d028165eaee1c5d0e59859199f8c6a51230eb97 (patch) | |
| tree | e9a4ea6772d628b7590faaf47f8728f896f5ea60 | |
| parent | 7a1d7ba7d22e9d82fdde0bc6e9fcc5152a7c9670 (diff) | |
| download | emacs-5d028165eaee1c5d0e59859199f8c6a51230eb97.tar.gz emacs-5d028165eaee1c5d0e59859199f8c6a51230eb97.zip | |
Refine the documentation of Flymake
* progmodes/flymake.el (flymake-save-buffer-in-file)
(flymake-makehash, flymake-posn-at-point-as-event, flymake-nop)
(flymake-selected-frame, flymake-log, flymake-ins-after)
(flymake-set-at, flymake-get-buildfile-from-cache)
(flymake-add-buildfile-to-cache, flymake-clear-buildfile-cache)
(flymake-find-possible-master-files, flymake-save-buffer-in-file):
Refine the doc string.
(flymake-get-file-name-mode-and-masks): Reformat.
(flymake-get-real-file-name-function): Fix a minor bug.
* flymake.texi: Changing from one space between sentences to two.
| -rw-r--r-- | doc/misc/ChangeLog | 4 | ||||
| -rw-r--r-- | doc/misc/flymake.texi | 163 | ||||
| -rw-r--r-- | lisp/ChangeLog | 12 | ||||
| -rw-r--r-- | lisp/progmodes/flymake.el | 61 |
4 files changed, 141 insertions, 99 deletions
diff --git a/doc/misc/ChangeLog b/doc/misc/ChangeLog index 74b08c04714..e74926ea25c 100644 --- a/doc/misc/ChangeLog +++ b/doc/misc/ChangeLog | |||
| @@ -1,3 +1,7 @@ | |||
| 1 | 2013-05-25 Xue Fuqiao <xfq.free@gmail.com> | ||
| 2 | |||
| 3 | * flymake.texi: Changing from one space between sentences to two. | ||
| 4 | |||
| 1 | 2013-05-04 Stefan Monnier <monnier@iro.umontreal.ca> | 5 | 2013-05-04 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 6 | ||
| 3 | * cl.texi (Obsolete Macros): Describe replacements for `flet' | 7 | * cl.texi (Obsolete Macros): Describe replacements for `flet' |
diff --git a/doc/misc/flymake.texi b/doc/misc/flymake.texi index 5dedda16ee1..f88bd95008c 100644 --- a/doc/misc/flymake.texi +++ b/doc/misc/flymake.texi | |||
| @@ -63,13 +63,13 @@ modify this GNU manual.'' | |||
| 63 | @cindex Overview of Flymake | 63 | @cindex Overview of Flymake |
| 64 | 64 | ||
| 65 | Flymake is a universal on-the-fly syntax checker implemented as an | 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 | 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 | 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 | 68 | background, passing it a temporary copy of the current buffer, and |
| 69 | parses the output for known error/warning message patterns. Flymake | 69 | parses the output for known error/warning message patterns. Flymake |
| 70 | then highlights erroneous lines (i.e., lines for which at least one | 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 | 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 | 72 | displays an overall buffer status in the mode line. Status information |
| 73 | displayed by Flymake contains total number of errors and warnings | 73 | displayed by Flymake contains total number of errors and warnings |
| 74 | reported for the buffer during the last syntax check. | 74 | reported for the buffer during the last syntax check. |
| 75 | 75 | ||
| @@ -79,14 +79,14 @@ line, respectively. | |||
| 79 | 79 | ||
| 80 | Calling @code{flymake-display-err-menu-for-current-line} will popup a | 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 | 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 | 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 | 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 | 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 | 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 | 86 | menu item will automatically open the file and jump to the line with |
| 87 | error. | 87 | error. |
| 88 | 88 | ||
| 89 | Syntax check is done 'on-the-fly'. It is started whenever | 89 | Syntax check is done 'on-the-fly'. It is started whenever |
| 90 | 90 | ||
| 91 | @itemize @bullet | 91 | @itemize @bullet |
| 92 | @item buffer is loaded | 92 | @item buffer is loaded |
| @@ -97,7 +97,7 @@ delay is configurable). | |||
| 97 | 97 | ||
| 98 | Flymake is a universal syntax checker in the sense that it's easily | 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 | 99 | extended to support new syntax check tools and error message |
| 100 | patterns. @xref{Configuring Flymake}. | 100 | patterns. @xref{Configuring Flymake}. |
| 101 | 101 | ||
| 102 | @node Installing Flymake | 102 | @node Installing Flymake |
| 103 | @chapter Installing | 103 | @chapter Installing |
| @@ -107,7 +107,7 @@ patterns. @xref{Configuring Flymake}. | |||
| 107 | Flymake is packaged in a single file, @code{flymake.el}. | 107 | Flymake is packaged in a single file, @code{flymake.el}. |
| 108 | 108 | ||
| 109 | To install/update Flymake, place @code{flymake.el} to a directory | 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 | 110 | somewhere on Emacs load path. You might also want to byte-compile |
| 111 | @code{flymake.el} to improve performance. | 111 | @code{flymake.el} to improve performance. |
| 112 | 112 | ||
| 113 | Also, place the following line in the @code{.emacs} file. | 113 | Also, place the following line in the @code{.emacs} file. |
| @@ -141,13 +141,13 @@ You might also map the most frequently used Flymake functions, such as | |||
| 141 | @section Flymake mode | 141 | @section Flymake mode |
| 142 | @cindex flymake-mode | 142 | @cindex flymake-mode |
| 143 | 143 | ||
| 144 | Flymake is an Emacs minor mode. To use Flymake, you | 144 | Flymake is an Emacs minor mode. To use Flymake, you |
| 145 | must first activate @code{flymake-mode} by using the | 145 | must first activate @code{flymake-mode} by using the |
| 146 | @code{flymake-mode} function. | 146 | @code{flymake-mode} function. |
| 147 | 147 | ||
| 148 | Instead of manually activating @code{flymake-mode}, you can configure | 148 | Instead of manually activating @code{flymake-mode}, you can configure |
| 149 | Flymake to automatically enable @code{flymake-mode} upon opening any | 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 | 150 | file for which syntax check is possible. To do so, place the following |
| 151 | line in @code{.emacs}: | 151 | line in @code{.emacs}: |
| 152 | 152 | ||
| 153 | @lisp | 153 | @lisp |
| @@ -159,9 +159,9 @@ line in @code{.emacs}: | |||
| 159 | @cindex Manually starting the syntax check | 159 | @cindex Manually starting the syntax check |
| 160 | 160 | ||
| 161 | When @code{flymake-mode} is active, syntax check is started | 161 | When @code{flymake-mode} is active, syntax check is started |
| 162 | automatically on any of the three conditions mentioned above. Syntax | 162 | automatically on any of the three conditions mentioned above. Syntax |
| 163 | check can also be started manually by using the | 163 | check can also be started manually by using the |
| 164 | @code{flymake-start-syntax-check-for-current-buffer} function. This | 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 | 165 | can be used, for example, when changes were made to some other buffer |
| 166 | affecting the current buffer. | 166 | affecting the current buffer. |
| 167 | 167 | ||
| @@ -171,7 +171,7 @@ affecting the current buffer. | |||
| 171 | 171 | ||
| 172 | After syntax check is completed, lines for which at least one error or | 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 | 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 | 174 | and warning is shown in the mode line. Use the following functions to |
| 175 | navigate the highlighted lines. | 175 | navigate the highlighted lines. |
| 176 | 176 | ||
| 177 | @multitable @columnfractions 0.25 0.75 | 177 | @multitable @columnfractions 0.25 0.75 |
| @@ -184,7 +184,7 @@ navigate the highlighted lines. | |||
| 184 | 184 | ||
| 185 | @end multitable | 185 | @end multitable |
| 186 | 186 | ||
| 187 | These functions treat erroneous lines as a linked list. Therefore, | 187 | These functions treat erroneous lines as a linked list. Therefore, |
| 188 | @code{flymake-goto-next-error} will go to the first erroneous line | 188 | @code{flymake-goto-next-error} will go to the first erroneous line |
| 189 | when invoked in the end of the buffer. | 189 | when invoked in the end of the buffer. |
| 190 | 190 | ||
| @@ -193,7 +193,7 @@ when invoked in the end of the buffer. | |||
| 193 | @cindex Viewing error messages | 193 | @cindex Viewing error messages |
| 194 | 194 | ||
| 195 | To view error messages belonging to the current line, use the | 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 | 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 | 197 | at least one error or warning reported for the current line, this |
| 198 | function will display a popup menu with error/warning texts. | 198 | function will display a popup menu with error/warning texts. |
| 199 | Selecting the menu item whose error belongs to another file brings | 199 | Selecting the menu item whose error belongs to another file brings |
| @@ -209,12 +209,12 @@ The following statuses are defined. | |||
| 209 | 209 | ||
| 210 | @multitable @columnfractions 0.25 0.75 | 210 | @multitable @columnfractions 0.25 0.75 |
| 211 | @item Flymake* or Flymake:E/W* | 211 | @item Flymake* or Flymake:E/W* |
| 212 | @tab Flymake is currently running. For the second case, E/W contains the | 212 | @tab Flymake is currently running. For the second case, E/W contains the |
| 213 | error and warning count for the previous run. | 213 | error and warning count for the previous run. |
| 214 | 214 | ||
| 215 | @item Flymake | 215 | @item Flymake |
| 216 | @tab Syntax check is not running. Usually this means syntax check was | 216 | @tab Syntax check is not running. Usually this means syntax check was |
| 217 | successfully passed (no errors, no warnings). Other possibilities are: | 217 | successfully passed (no errors, no warnings). Other possibilities are: |
| 218 | syntax check was killed as a result of executing | 218 | syntax check was killed as a result of executing |
| 219 | @code{flymake-compile}, or syntax check cannot start as compilation | 219 | @code{flymake-compile}, or syntax check cannot start as compilation |
| 220 | is currently in progress. | 220 | is currently in progress. |
| @@ -232,7 +232,7 @@ OFF for the buffer. | |||
| 232 | @multitable @columnfractions 0.25 0.75 | 232 | @multitable @columnfractions 0.25 0.75 |
| 233 | @item CFGERR | 233 | @item CFGERR |
| 234 | @tab Syntax check process returned nonzero exit code, but no | 234 | @tab Syntax check process returned nonzero exit code, but no |
| 235 | errors/warnings were reported. This indicates a possible configuration | 235 | errors/warnings were reported. This indicates a possible configuration |
| 236 | error (for example, no suitable error message patterns for the | 236 | error (for example, no suitable error message patterns for the |
| 237 | syntax check tool). | 237 | syntax check tool). |
| 238 | 238 | ||
| @@ -253,12 +253,12 @@ syntax check tool). | |||
| 253 | @cindex Troubleshooting | 253 | @cindex Troubleshooting |
| 254 | 254 | ||
| 255 | Flymake uses a simple logging facility for indicating important points | 255 | Flymake uses a simple logging facility for indicating important points |
| 256 | in the control flow. The logging facility sends logging messages to | 256 | in the control flow. The logging facility sends logging messages to |
| 257 | the @code{*Messages*} buffer. The information logged can be used for | 257 | the @code{*Messages*} buffer. The information logged can be used for |
| 258 | resolving various problems related to Flymake. | 258 | resolving various problems related to Flymake. |
| 259 | 259 | ||
| 260 | Logging output is controlled by the @code{flymake-log-level} | 260 | Logging output is controlled by the @code{flymake-log-level} |
| 261 | variable. @code{3} is the most verbose level, and @code{-1} switches | 261 | variable. @code{3} is the most verbose level, and @code{-1} switches |
| 262 | logging off. | 262 | logging off. |
| 263 | 263 | ||
| 264 | @node Configuring Flymake | 264 | @node Configuring Flymake |
| @@ -286,30 +286,30 @@ Controls logging output, see @ref{Troubleshooting}. | |||
| 286 | 286 | ||
| 287 | @item flymake-allowed-file-name-masks | 287 | @item flymake-allowed-file-name-masks |
| 288 | A list of @code{(filename-regexp, init-function, cleanup-function | 288 | A list of @code{(filename-regexp, init-function, cleanup-function |
| 289 | getfname-function)} for configuring syntax check tools. @xref{Adding | 289 | getfname-function)} for configuring syntax check tools. @xref{Adding |
| 290 | support for a new syntax check tool}. | 290 | support for a new syntax check tool}. |
| 291 | 291 | ||
| 292 | @ignore | 292 | @ignore |
| 293 | @item flymake-buildfile-dirs | 293 | @item flymake-buildfile-dirs |
| 294 | A list of directories (relative paths) for searching a | 294 | A list of directories (relative paths) for searching a |
| 295 | buildfile. @xref{Locating the buildfile}. | 295 | buildfile. @xref{Locating the buildfile}. |
| 296 | @end ignore | 296 | @end ignore |
| 297 | 297 | ||
| 298 | @item flymake-master-file-dirs | 298 | @item flymake-master-file-dirs |
| 299 | A list of directories for searching a master file. @xref{Locating a | 299 | A list of directories for searching a master file. @xref{Locating a |
| 300 | master file}. | 300 | master file}. |
| 301 | 301 | ||
| 302 | @item flymake-get-project-include-dirs-function | 302 | @item flymake-get-project-include-dirs-function |
| 303 | A function used for obtaining a list of project include dirs (C/C++ | 303 | A function used for obtaining a list of project include dirs (C/C++ |
| 304 | specific). @xref{Getting the include directories}. | 304 | specific). @xref{Getting the include directories}. |
| 305 | 305 | ||
| 306 | @item flymake-master-file-count-limit | 306 | @item flymake-master-file-count-limit |
| 307 | @itemx flymake-check-file-limit | 307 | @itemx flymake-check-file-limit |
| 308 | Used when looking for a master file. @xref{Locating a master file}. | 308 | Used when looking for a master file. @xref{Locating a master file}. |
| 309 | 309 | ||
| 310 | @item flymake-err-line-patterns | 310 | @item flymake-err-line-patterns |
| 311 | Patterns for error/warning messages in the form @code{(regexp file-idx | 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}. | 312 | line-idx col-idx err-text-idx)}. @xref{Parsing the output}. |
| 313 | 313 | ||
| 314 | @item flymake-compilation-prevents-syntax-check | 314 | @item flymake-compilation-prevents-syntax-check |
| 315 | A flag indicating whether compilation and syntax check of the same | 315 | A flag indicating whether compilation and syntax check of the same |
| @@ -321,7 +321,7 @@ started after @code{flymake-no-changes-timeout} seconds. | |||
| 321 | 321 | ||
| 322 | @item flymake-gui-warnings-enabled | 322 | @item flymake-gui-warnings-enabled |
| 323 | A boolean flag indicating whether Flymake will show message boxes for | 323 | A boolean flag indicating whether Flymake will show message boxes for |
| 324 | non-recoverable errors. If @code{flymake-gui-warnings-enabled} is | 324 | non-recoverable errors. If @code{flymake-gui-warnings-enabled} is |
| 325 | @code{nil}, these errors will only be logged to the @code{*Messages*} | 325 | @code{nil}, these errors will only be logged to the @code{*Messages*} |
| 326 | buffer. | 326 | buffer. |
| 327 | 327 | ||
| @@ -360,7 +360,7 @@ Which fringe (if any) should show the warning/error bitmaps. | |||
| 360 | @end menu | 360 | @end menu |
| 361 | 361 | ||
| 362 | Syntax check tools are configured using the | 362 | Syntax check tools are configured using the |
| 363 | @code{flymake-allowed-file-name-masks} list. Each item of this list | 363 | @code{flymake-allowed-file-name-masks} list. Each item of this list |
| 364 | has the following format: | 364 | has the following format: |
| 365 | 365 | ||
| 366 | @lisp | 366 | @lisp |
| @@ -371,14 +371,14 @@ has the following format: | |||
| 371 | @item filename-regexp | 371 | @item filename-regexp |
| 372 | This field is used as a key for locating init/cleanup/getfname | 372 | This field is used as a key for locating init/cleanup/getfname |
| 373 | functions for the buffer. Items in | 373 | functions for the buffer. Items in |
| 374 | @code{flymake-allowed-file-name-masks} are searched sequentially. The | 374 | @code{flymake-allowed-file-name-masks} are searched sequentially. The |
| 375 | first item with @code{filename-regexp} matching buffer filename is | 375 | first item with @code{filename-regexp} matching buffer filename is |
| 376 | selected. If no match is found, @code{flymake-mode} is switched off. | 376 | selected. If no match is found, @code{flymake-mode} is switched off. |
| 377 | 377 | ||
| 378 | @item init-function | 378 | @item init-function |
| 379 | @code{init-function} is required to initialize the syntax check, | 379 | @code{init-function} is required to initialize the syntax check, |
| 380 | usually by creating a temporary copy of the buffer contents. The | 380 | usually by creating a temporary copy of the buffer contents. The |
| 381 | function must return @code{(list cmd-name arg-list)}. If | 381 | function must return @code{(list cmd-name arg-list)}. If |
| 382 | @code{init-function} returns null, syntax check is aborted, by | 382 | @code{init-function} returns null, syntax check is aborted, by |
| 383 | @code{flymake-mode} is not switched off. | 383 | @code{flymake-mode} is not switched off. |
| 384 | 384 | ||
| @@ -389,7 +389,7 @@ usually deleting a temporary copy created by the @code{init-function}. | |||
| 389 | 389 | ||
| 390 | @item getfname-function | 390 | @item getfname-function |
| 391 | This function is used for translating filenames reported by the syntax | 391 | This function is used for translating filenames reported by the syntax |
| 392 | check tool into ``real'' filenames. Filenames reported by the tool | 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 | 393 | will be different from the real ones, as actually the tool works with |
| 394 | the temporary copy. In most cases, the default implementation | 394 | the temporary copy. In most cases, the default implementation |
| 395 | provided by Flymake, @code{flymake-get-real-file-name}, can be used as | 395 | provided by Flymake, @code{flymake-get-real-file-name}, can be used as |
| @@ -411,7 +411,7 @@ support for various syntax check tools. | |||
| 411 | @cindex Adding support for perl | 411 | @cindex Adding support for perl |
| 412 | 412 | ||
| 413 | In this example, we will add support for @code{perl} as a syntax check | 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 | 414 | tool. @code{perl} supports the @code{-c} option which does syntax |
| 415 | checking. | 415 | checking. |
| 416 | 416 | ||
| 417 | First, we write the @code{init-function}: | 417 | First, we write the @code{init-function}: |
| @@ -463,7 +463,7 @@ In this example we will add support for C files syntax checked by | |||
| 463 | @command{gcc} called via @command{make}. | 463 | @command{gcc} called via @command{make}. |
| 464 | 464 | ||
| 465 | We're not required to write any new functions, as Flymake already has | 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 | 466 | functions for @command{make}. We just add a new entry to the |
| 467 | @code{flymake-allowed-file-name-masks}: | 467 | @code{flymake-allowed-file-name-masks}: |
| 468 | 468 | ||
| 469 | @lisp | 469 | @lisp |
| @@ -489,7 +489,7 @@ command line: | |||
| 489 | 489 | ||
| 490 | @code{base-dir} is a directory containing @code{Makefile}, see @ref{Locating the buildfile}. | 490 | @code{base-dir} is a directory containing @code{Makefile}, see @ref{Locating the buildfile}. |
| 491 | 491 | ||
| 492 | Thus, @code{Makefile} must contain the @code{check-syntax} target. In | 492 | Thus, @code{Makefile} must contain the @code{check-syntax} target. In |
| 493 | our case this target might look like this: | 493 | our case this target might look like this: |
| 494 | 494 | ||
| 495 | @verbatim | 495 | @verbatim |
| @@ -527,12 +527,12 @@ check-syntax: | |||
| 527 | 527 | ||
| 528 | Syntax check is started by calling @code{flymake-start-syntax-check-for-current-buffer}. | 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 | 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 | 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 | 531 | buffer's directory (or in the system temp directory, for java |
| 532 | files), creates a syntax check command and launches a process with | 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, | 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 | 534 | and error information (file name, line number, type and text) is |
| 535 | saved. After the process has finished, Flymake highlights erroneous | 535 | saved. After the process has finished, Flymake highlights erroneous |
| 536 | lines in the buffer using the accumulated error information. | 536 | lines in the buffer using the accumulated error information. |
| 537 | 537 | ||
| 538 | @node Determining whether syntax check is possible | 538 | @node Determining whether syntax check is possible |
| @@ -551,14 +551,14 @@ Two syntax check modes are distinguished: | |||
| 551 | @item | 551 | @item |
| 552 | Buffer can be syntax checked in a standalone fashion, that is, the | 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 | 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) | 554 | do the syntax check. Examples are C/C++ (.c, .cpp) and Java (.java) |
| 555 | sources. | 555 | sources. |
| 556 | 556 | ||
| 557 | @item | 557 | @item |
| 558 | Buffer can be syntax checked, but additional file, called master file, | 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 | 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 | 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, | 561 | will also check syntax in the current file. Examples are C/C++ (.h, |
| 562 | .hpp) headers. | 562 | .hpp) headers. |
| 563 | 563 | ||
| 564 | @end enumerate | 564 | @end enumerate |
| @@ -579,7 +579,7 @@ copies, finding master files, etc.), as well as some tool-specific | |||
| 579 | 579 | ||
| 580 | After the possibility of the syntax check has been determined, a | 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 | 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 | 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 | 583 | is quite straightforward in a standalone case (mode @code{1}), as it's |
| 584 | just saving buffer contents to a temporary file. | 584 | just saving buffer contents to a temporary file. |
| 585 | 585 | ||
| @@ -595,11 +595,11 @@ name. | |||
| 595 | Locating a master file is discussed in the following section. | 595 | Locating a master file is discussed in the following section. |
| 596 | 596 | ||
| 597 | Patching just changes all appropriate lines of the master file so that they | 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 | 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 | 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 | 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 | 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 | 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 | 603 | is saved to @code{file_flymake_master.cpp}, and the last one is passed to |
| 604 | the syntax check tool. | 604 | the syntax check tool. |
| 605 | 605 | ||
| @@ -609,27 +609,27 @@ the syntax check tool. | |||
| 609 | 609 | ||
| 610 | Master file is located in two steps. | 610 | Master file is located in two steps. |
| 611 | 611 | ||
| 612 | First, a list of possible master files is built. A simple name | 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}, | 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 | 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 | 615 | stored in a customizable variable @code{flymake-master-file-dirs}, which |
| 616 | usually contains something like @code{("." "./src")}. No more than | 616 | usually contains something like @code{("." "./src")}. No more than |
| 617 | @code{flymake-master-file-count-limit} entries is added to the master file | 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 | 618 | list. The list is then sorted to move files with names @code{file.cpp} to |
| 619 | the top. | 619 | the top. |
| 620 | 620 | ||
| 621 | Next, each master file in a list is checked to contain the appropriate | 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 | 622 | include directives. No more than @code{flymake-check-file-limit} of each |
| 623 | file are parsed. | 623 | file are parsed. |
| 624 | 624 | ||
| 625 | For @code{file.h}, the include directives to look for are | 625 | For @code{file.h}, the include directives to look for are |
| 626 | @code{#include "file.h"}, @code{#include "../file.h"}, etc. Each | 626 | @code{#include "file.h"}, @code{#include "../file.h"}, etc. Each |
| 627 | include is checked against a list of include directories | 627 | include is checked against a list of include directories |
| 628 | (see @ref{Getting the include directories}) to be sure it points to the | 628 | (see @ref{Getting the include directories}) to be sure it points to the |
| 629 | correct @code{file.h}. | 629 | correct @code{file.h}. |
| 630 | 630 | ||
| 631 | First matching master file found stops the search. The master file is then | 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 | 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. | 633 | aborted, and corresponding status (!) is reported in the mode line. |
| 634 | 634 | ||
| 635 | @node Getting the include directories | 635 | @node Getting the include directories |
| @@ -637,19 +637,19 @@ aborted, and corresponding status (!) is reported in the mode line. | |||
| 637 | @cindex Include directories (C/C++ specific) | 637 | @cindex Include directories (C/C++ specific) |
| 638 | 638 | ||
| 639 | Two sets of include directories are distinguished: system include directories | 639 | Two sets of include directories are distinguished: system include directories |
| 640 | and project include directories. The former is just the contents of the | 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, | 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. | 642 | and the way it can be obtained can vary greatly for different projects. |
| 643 | Therefore, a customizable variable | 643 | Therefore, a customizable variable |
| 644 | @code{flymake-get-project-include-dirs-function} is used to provide the | 644 | @code{flymake-get-project-include-dirs-function} is used to provide the |
| 645 | way to implement the desired behavior. | 645 | way to implement the desired behavior. |
| 646 | 646 | ||
| 647 | The default implementation, @code{flymake-get-project-include-dirs-imp}, | 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 | 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. | 649 | directory containing a correct @file{Makefile}, to be determined. |
| 650 | 650 | ||
| 651 | As obtaining the project include directories might be a costly operation, its | 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 | 652 | return value is cached in the hash table. The cache is cleared in the beginning |
| 653 | of every syntax check attempt. | 653 | of every syntax check attempt. |
| 654 | 654 | ||
| 655 | @node Locating the buildfile | 655 | @node Locating the buildfile |
| @@ -659,18 +659,18 @@ of every syntax check attempt. | |||
| 659 | @cindex Makefile, locating | 659 | @cindex Makefile, locating |
| 660 | 660 | ||
| 661 | Flymake can be configured to use different tools for performing syntax | 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 | 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 | 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 | 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 | 665 | scripts and html pages, can be checked by directly invoking a |
| 666 | corresponding tool. Files that are usually more complex and generally | 666 | corresponding tool. Files that are usually more complex and generally |
| 667 | used as part of larger projects, might require non-trivial options to | 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 | 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 | 669 | C++. The latter files are syntax checked using some build tool, like |
| 670 | Make or Ant. | 670 | Make or Ant. |
| 671 | 671 | ||
| 672 | All Make configuration data is usually stored in a file called | 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 | 673 | @code{Makefile}. To allow for future extensions, flymake uses a notion of |
| 674 | buildfile to reference the 'project configuration' file. | 674 | buildfile to reference the 'project configuration' file. |
| 675 | 675 | ||
| 676 | Special function, @code{flymake-find-buildfile} is provided for locating buildfiles. | 676 | Special function, @code{flymake-find-buildfile} is provided for locating buildfiles. |
| @@ -679,7 +679,7 @@ for possible master files. | |||
| 679 | @ignore | 679 | @ignore |
| 680 | A customizable variable | 680 | A customizable variable |
| 681 | @code{flymake-buildfile-dirs} holds a list of relative paths to the | 681 | @code{flymake-buildfile-dirs} holds a list of relative paths to the |
| 682 | buildfile. They are checked sequentially until a buildfile is found. | 682 | buildfile. They are checked sequentially until a buildfile is found. |
| 683 | @end ignore | 683 | @end ignore |
| 684 | In case there's no build file, syntax check is aborted. | 684 | In case there's no build file, syntax check is aborted. |
| 685 | 685 | ||
| @@ -690,7 +690,7 @@ Buildfile values are also cached. | |||
| 690 | @cindex Syntax check process | 690 | @cindex Syntax check process |
| 691 | 691 | ||
| 692 | The command line (command name and the list of arguments) for launching a process is returned by the | 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} | 693 | initialization function. Flymake then just calls @code{start-process} |
| 694 | to start an asynchronous process and configures process filter and | 694 | to start an asynchronous process and configures process filter and |
| 695 | sentinel which is used for processing the output of the syntax check | 695 | sentinel which is used for processing the output of the syntax check |
| 696 | tool. | 696 | tool. |
| @@ -701,24 +701,24 @@ tool. | |||
| 701 | 701 | ||
| 702 | The output generated by the syntax check tool is parsed in the process | 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 | 703 | filter/sentinel using the error message patterns stored in the |
| 704 | @code{flymake-err-line-patterns} variable. This variable contains a | 704 | @code{flymake-err-line-patterns} variable. This variable contains a |
| 705 | list of items of the form @code{(regexp file-idx line-idx | 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 | 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, | 707 | error message and extract file name, line number and error text, |
| 708 | respectively. Error type (error/warning) is also guessed by matching | 708 | respectively. Error type (error/warning) is also guessed by matching |
| 709 | error text with the '@code{^[wW]arning}' pattern. Anything that was not | 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 | 710 | classified as a warning is considered an error. Type is then used to |
| 711 | sort error menu items, which shows error messages first. | 711 | sort error menu items, which shows error messages first. |
| 712 | 712 | ||
| 713 | Flymake is also able to interpret error message patterns missing err-text-idx | 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 | 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 | 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 | 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 | 717 | @code{compile.el}. All these error patterns are appended to |
| 718 | the end of @code{flymake-err-line-patterns}. | 718 | the end of @code{flymake-err-line-patterns}. |
| 719 | 719 | ||
| 720 | The error information obtained is saved in a buffer local | 720 | The error information obtained is saved in a buffer local |
| 721 | variable. The buffer for which the process output belongs is | 721 | variable. The buffer for which the process output belongs is |
| 722 | determined from the process-id@w{}->@w{}buffer mapping updated | 722 | determined from the process-id@w{}->@w{}buffer mapping updated |
| 723 | after every process launch/exit. | 723 | after every process launch/exit. |
| 724 | 724 | ||
| @@ -727,7 +727,7 @@ after every process launch/exit. | |||
| 727 | @cindex Erroneous lines, faces | 727 | @cindex Erroneous lines, faces |
| 728 | 728 | ||
| 729 | Highlighting is implemented with overlays and happens in the process | 729 | Highlighting is implemented with overlays and happens in the process |
| 730 | sentinel, after calling the cleanup function. Two customizable faces | 730 | sentinel, after calling the cleanup function. Two customizable faces |
| 731 | are used: @code{flymake-errline} and | 731 | are used: @code{flymake-errline} and |
| 732 | @code{flymake-warnline}. Errors belonging outside the current | 732 | @code{flymake-warnline}. Errors belonging outside the current |
| 733 | buffer are considered to belong to line 1 of the current buffer. | 733 | buffer are considered to belong to line 1 of the current buffer. |
| @@ -749,12 +749,13 @@ and @code{flymake-warning-bitmap}. | |||
| 749 | The only mode flymake currently knows about is @code{compile}. | 749 | The only mode flymake currently knows about is @code{compile}. |
| 750 | 750 | ||
| 751 | Flymake can be configured to not start syntax check if it thinks the | 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 | 752 | compilation is in progress. The check is made by the |
| 753 | @code{flymake-compilation-is-running}, which tests the | 753 | @code{flymake-compilation-is-running}, which tests the |
| 754 | @code{compilation-in-progress} variable. The reason why this might be | 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 | 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, | 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. | 757 | though, was working around a locking problem with MS Visual C++ |
| 758 | compiler. | ||
| 758 | 759 | ||
| 759 | Flymake also provides an alternative command for starting compilation, | 760 | Flymake also provides an alternative command for starting compilation, |
| 760 | @code{flymake-compile}: | 761 | @code{flymake-compile}: |
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index e12652e7cbd..3cb0535ce5e 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,15 @@ | |||
| 1 | 2013-05-25 Xue Fuqiao <xfq.free@gmail.com> | ||
| 2 | |||
| 3 | * progmodes/flymake.el (flymake-save-buffer-in-file) | ||
| 4 | (flymake-makehash, flymake-posn-at-point-as-event, flymake-nop) | ||
| 5 | (flymake-selected-frame, flymake-log, flymake-ins-after) | ||
| 6 | (flymake-set-at, flymake-get-buildfile-from-cache) | ||
| 7 | (flymake-add-buildfile-to-cache, flymake-clear-buildfile-cache) | ||
| 8 | (flymake-find-possible-master-files, flymake-save-buffer-in-file): | ||
| 9 | Refine the doc string. | ||
| 10 | (flymake-get-file-name-mode-and-masks): Reformat. | ||
| 11 | (flymake-get-real-file-name-function): Fix a minor bug. | ||
| 12 | |||
| 1 | 2013-05-24 Juri Linkov <juri@jurta.org> | 13 | 2013-05-24 Juri Linkov <juri@jurta.org> |
| 2 | 14 | ||
| 3 | * progmodes/grep.el (grep-mode-font-lock-keywords): | 15 | * progmodes/grep.el (grep-mode-font-lock-keywords): |
diff --git a/lisp/progmodes/flymake.el b/lisp/progmodes/flymake.el index 79bccd138ee..aed62b27450 100644 --- a/lisp/progmodes/flymake.el +++ b/lisp/progmodes/flymake.el | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | ;;; flymake.el -- a universal on-the-fly syntax checker | 1 | ;;; flymake.el --- a universal on-the-fly syntax checker |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 2003-2013 Free Software Foundation, Inc. | 3 | ;; Copyright (C) 2003-2013 Free Software Foundation, Inc. |
| 4 | 4 | ||
| @@ -68,6 +68,9 @@ | |||
| 68 | 68 | ||
| 69 | ;;;; [[ cross-emacs compatibility routines | 69 | ;;;; [[ cross-emacs compatibility routines |
| 70 | (defsubst flymake-makehash (&optional test) | 70 | (defsubst flymake-makehash (&optional test) |
| 71 | "Create and return a new hash table using TEST to compare keys. | ||
| 72 | It uses the function `make-hash-table' to make a hash-table if | ||
| 73 | you use GNU Emacs, otherwise it uses `makehash'." | ||
| 71 | (if (fboundp 'make-hash-table) | 74 | (if (fboundp 'make-hash-table) |
| 72 | (if test (make-hash-table :test test) (make-hash-table)) | 75 | (if test (make-hash-table :test test) (make-hash-table)) |
| 73 | (with-no-warnings | 76 | (with-no-warnings |
| @@ -106,10 +109,12 @@ Zero-length substrings at the beginning and end of the list are omitted." | |||
| 106 | (lambda () temporary-file-directory))) | 109 | (lambda () temporary-file-directory))) |
| 107 | 110 | ||
| 108 | (defun flymake-posn-at-point-as-event (&optional position window dx dy) | 111 | (defun flymake-posn-at-point-as-event (&optional position window dx dy) |
| 109 | "Return pixel position of top left corner of glyph at POSITION, | 112 | "Return pixel position of top left corner of glyph at POSITION. |
| 110 | relative to top left corner of WINDOW, as a mouse-1 click | 113 | |
| 111 | event (identical to the event that would be triggered by clicking | 114 | The position is relative to top left corner of WINDOW, as a |
| 112 | mouse button 1 at the top left corner of the glyph). | 115 | mouse-1 click event (identical to the event that would be |
| 116 | triggered by clicking mouse button 1 at the top left corner of | ||
| 117 | the glyph). | ||
| 113 | 118 | ||
| 114 | POSITION and WINDOW default to the position of point in the | 119 | POSITION and WINDOW default to the position of point in the |
| 115 | selected window. | 120 | selected window. |
| @@ -164,7 +169,8 @@ See `x-popup-menu' for the menu specifier format." | |||
| 164 | 169 | ||
| 165 | (if (featurep 'xemacs) (progn | 170 | (if (featurep 'xemacs) (progn |
| 166 | 171 | ||
| 167 | (defun flymake-nop ()) | 172 | (defun flymake-nop () |
| 173 | "Do nothing.") | ||
| 168 | 174 | ||
| 169 | (defun flymake-make-xemacs-menu (menu-data) | 175 | (defun flymake-make-xemacs-menu (menu-data) |
| 170 | "Return a menu specifier using MENU-DATA." | 176 | "Return a menu specifier using MENU-DATA." |
| @@ -187,6 +193,7 @@ See `x-popup-menu' for the menu specifier format." | |||
| 187 | (count-lines (window-start) (point)))) | 193 | (count-lines (window-start) (point)))) |
| 188 | 194 | ||
| 189 | (defun flymake-selected-frame () | 195 | (defun flymake-selected-frame () |
| 196 | "Return the frame that is now selected." | ||
| 190 | (if (fboundp 'window-edges) | 197 | (if (fboundp 'window-edges) |
| 191 | (selected-frame) | 198 | (selected-frame) |
| 192 | (selected-window))) | 199 | (selected-window))) |
| @@ -217,31 +224,42 @@ See `x-popup-menu' for the menu specifier format." | |||
| 217 | :group 'flymake | 224 | :group 'flymake |
| 218 | :type 'integer) | 225 | :type 'integer) |
| 219 | 226 | ||
| 227 | |||
| 228 | ;; (defcustom flymake-log-file-name "~/flymake.log" | ||
| 229 | ;; "Where to put the flymake log if logging is enabled. | ||
| 230 | ;; | ||
| 231 | ;; See `flymake-log-level' if you want to control what is logged." | ||
| 232 | ;; :group 'flymake | ||
| 233 | ;; :type 'string) | ||
| 234 | |||
| 220 | (defun flymake-log (level text &rest args) | 235 | (defun flymake-log (level text &rest args) |
| 221 | "Log a message at level LEVEL. | 236 | "Log a message at level LEVEL. |
| 222 | If LEVEL is higher than `flymake-log-level', the message is | 237 | If LEVEL is higher than `flymake-log-level', the message is |
| 223 | ignored. Otherwise, it is printed using `message'. | 238 | ignored. Otherwise, it is printed using `message'. |
| 224 | TEXT is a format control string, and the remaining arguments ARGS | 239 | TEXT is a format control string, and the remaining arguments ARGS |
| 225 | are the string substitutions (see `format')." | 240 | are the string substitutions (see the function `format')." |
| 226 | (if (<= level flymake-log-level) | 241 | (if (<= level flymake-log-level) |
| 227 | (let* ((msg (apply 'format text args))) | 242 | (let* ((msg (apply 'format text args))) |
| 228 | (message "%s" msg) | 243 | (message "%s" msg) |
| 229 | ;;(with-temp-buffer | 244 | ;;(with-temp-buffer |
| 230 | ;; (insert msg) | 245 | ;; (insert msg) |
| 231 | ;; (insert "\n") | 246 | ;; (insert "\n") |
| 232 | ;; (flymake-save-buffer-in-file "d:/flymake.log" t) ; make log file name customizable | 247 | ;; (flymake-save-buffer-in-file "~/flymake.log") ; make log file name customizable |
| 233 | ;;) | 248 | ;;) |
| 234 | ))) | 249 | ))) |
| 235 | 250 | ||
| 236 | (defun flymake-ins-after (list pos val) | 251 | (defun flymake-ins-after (list pos val) |
| 237 | "Insert VAL into LIST after position POS." | 252 | "Insert VAL into LIST after position POS. |
| 238 | (let ((tmp (copy-sequence list))) ; (???) | 253 | POS counts from zero." |
| 254 | (let ((tmp (copy-sequence list))) ; Bind `tmp' to a copy of LIST | ||
| 239 | (setcdr (nthcdr pos tmp) (cons val (nthcdr (1+ pos) tmp))) | 255 | (setcdr (nthcdr pos tmp) (cons val (nthcdr (1+ pos) tmp))) |
| 240 | tmp)) | 256 | tmp)) |
| 241 | 257 | ||
| 242 | (defun flymake-set-at (list pos val) | 258 | (defun flymake-set-at (list pos val) |
| 243 | "Set VAL at position POS in LIST." | 259 | ) |
| 244 | (let ((tmp (copy-sequence list))) ; (???) | 260 | "Set VAL at position POS in LIST. |
| 261 | POS counts from zero." | ||
| 262 | (let ((tmp (copy-sequence list))) ; Bind `tmp' to a copy of LIST | ||
| 245 | (setcar (nthcdr pos tmp) val) | 263 | (setcar (nthcdr pos tmp) val) |
| 246 | tmp)) | 264 | tmp)) |
| 247 | 265 | ||
| @@ -249,7 +267,6 @@ are the string substitutions (see `format')." | |||
| 249 | "List of currently active flymake processes.") | 267 | "List of currently active flymake processes.") |
| 250 | 268 | ||
| 251 | (defvar flymake-output-residual nil) | 269 | (defvar flymake-output-residual nil) |
| 252 | |||
| 253 | (make-variable-buffer-local 'flymake-output-residual) | 270 | (make-variable-buffer-local 'flymake-output-residual) |
| 254 | 271 | ||
| 255 | (defgroup flymake nil | 272 | (defgroup flymake nil |
| @@ -310,7 +327,7 @@ NAME is the file name function to use, default `flymake-get-real-file-name'." | |||
| 310 | (unless (stringp file-name) | 327 | (unless (stringp file-name) |
| 311 | (error "Invalid file-name")) | 328 | (error "Invalid file-name")) |
| 312 | (let ((fnm flymake-allowed-file-name-masks) | 329 | (let ((fnm flymake-allowed-file-name-masks) |
| 313 | (mode-and-masks nil)) | 330 | (mode-and-masks nil)) |
| 314 | (while (and (not mode-and-masks) fnm) | 331 | (while (and (not mode-and-masks) fnm) |
| 315 | (if (string-match (car (car fnm)) file-name) | 332 | (if (string-match (car (car fnm)) file-name) |
| 316 | (setq mode-and-masks (cdr (car fnm)))) | 333 | (setq mode-and-masks (cdr (car fnm)))) |
| @@ -336,18 +353,22 @@ Return nil if we cannot, non-nil if we can." | |||
| 336 | 'flymake-simple-cleanup)) | 353 | 'flymake-simple-cleanup)) |
| 337 | 354 | ||
| 338 | (defun flymake-get-real-file-name-function (file-name) | 355 | (defun flymake-get-real-file-name-function (file-name) |
| 339 | (or (nth 2 (flymake-get-file-name-mode-and-masks file-name)) | 356 | (or (nth 4 (flymake-get-file-name-mode-and-masks file-name)) |
| 340 | 'flymake-get-real-file-name)) | 357 | 'flymake-get-real-file-name)) |
| 341 | 358 | ||
| 342 | (defvar flymake-find-buildfile-cache (flymake-makehash 'equal)) | 359 | (defvar flymake-find-buildfile-cache (flymake-makehash 'equal)) |
| 343 | 360 | ||
| 344 | (defun flymake-get-buildfile-from-cache (dir-name) | 361 | (defun flymake-get-buildfile-from-cache (dir-name) |
| 362 | "Look up DIR-NAME in cache and return its associated value. | ||
| 363 | If DIR-NAME is not found, return nil." | ||
| 345 | (gethash dir-name flymake-find-buildfile-cache)) | 364 | (gethash dir-name flymake-find-buildfile-cache)) |
| 346 | 365 | ||
| 347 | (defun flymake-add-buildfile-to-cache (dir-name buildfile) | 366 | (defun flymake-add-buildfile-to-cache (dir-name buildfile) |
| 367 | "Associate DIR-NAME with BUILDFILE in the buildfile cache." | ||
| 348 | (puthash dir-name buildfile flymake-find-buildfile-cache)) | 368 | (puthash dir-name buildfile flymake-find-buildfile-cache)) |
| 349 | 369 | ||
| 350 | (defun flymake-clear-buildfile-cache () | 370 | (defun flymake-clear-buildfile-cache () |
| 371 | "Clear the buildfile cache." | ||
| 351 | (clrhash flymake-find-buildfile-cache)) | 372 | (clrhash flymake-find-buildfile-cache)) |
| 352 | 373 | ||
| 353 | (defun flymake-find-buildfile (buildfile-name source-dir-name) | 374 | (defun flymake-find-buildfile (buildfile-name source-dir-name) |
| @@ -394,9 +415,11 @@ Return t if so, nil if not." | |||
| 394 | 415 | ||
| 395 | (defun flymake-find-possible-master-files (file-name master-file-dirs masks) | 416 | (defun flymake-find-possible-master-files (file-name master-file-dirs masks) |
| 396 | "Find (by name and location) all possible master files. | 417 | "Find (by name and location) all possible master files. |
| 397 | Master files include .cpp and .c for .h. Files are searched for | 418 | |
| 398 | starting from the .h directory and max max-level parent dirs. | 419 | Name is specified by FILE-NAME and location is specified by |
| 399 | File contents are not checked." | 420 | MASTER-FILE-DIRS. Master files include .cpp and .c for .h. |
| 421 | Files are searched for starting from the .h directory and max | ||
| 422 | max-level parent dirs. File contents are not checked." | ||
| 400 | (let* ((dirs master-file-dirs) | 423 | (let* ((dirs master-file-dirs) |
| 401 | (files nil) | 424 | (files nil) |
| 402 | (done nil)) | 425 | (done nil)) |
| @@ -593,6 +616,8 @@ Find master file, patch and save it." | |||
| 593 | nil)))) | 616 | nil)))) |
| 594 | 617 | ||
| 595 | (defun flymake-save-buffer-in-file (file-name) | 618 | (defun flymake-save-buffer-in-file (file-name) |
| 619 | "Save the entire buffer contents into file FILE-NAME. | ||
| 620 | Create parent directories as needed." | ||
| 596 | (make-directory (file-name-directory file-name) 1) | 621 | (make-directory (file-name-directory file-name) 1) |
| 597 | (write-region nil nil file-name nil 566) | 622 | (write-region nil nil file-name nil 566) |
| 598 | (flymake-log 3 "saved buffer %s in file %s" (buffer-name) file-name)) | 623 | (flymake-log 3 "saved buffer %s in file %s" (buffer-name) file-name)) |