]> code.delx.au - gnu-emacs/blob - lisp/progmodes/flymake.el
Update copyright year to 2016
[gnu-emacs] / lisp / progmodes / flymake.el
1 ;;; flymake.el --- a universal on-the-fly syntax checker -*- lexical-binding: t; -*-
2
3 ;; Copyright (C) 2003-2016 Free Software Foundation, Inc.
4
5 ;; Author: Pavel Kobyakov <pk_at_work@yahoo.com>
6 ;; Maintainer: Leo Liu <sdl.web@gmail.com>
7 ;; Version: 0.3
8 ;; Keywords: c languages tools
9
10 ;; This file is part of GNU Emacs.
11
12 ;; GNU Emacs is free software: you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation, either version 3 of the License, or
15 ;; (at your option) any later version.
16
17 ;; GNU Emacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
21
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
24
25 ;;; Commentary:
26 ;;
27 ;; Flymake is a minor Emacs mode performing on-the-fly syntax checks
28 ;; using the external syntax check tool (for C/C++ this is usually the
29 ;; compiler).
30
31 ;;; Bugs/todo:
32
33 ;; - Only uses "Makefile", not "makefile" or "GNUmakefile"
34 ;; (from http://bugs.debian.org/337339).
35
36 ;;; Code:
37
38 (eval-when-compile (require 'cl-lib))
39
40 (defgroup flymake nil
41 "Universal on-the-fly syntax checker."
42 :version "23.1"
43 :link '(custom-manual "(flymake) Top")
44 :group 'tools)
45
46 (defcustom flymake-error-bitmap '(exclamation-mark error)
47 "Bitmap (a symbol) used in the fringe for indicating errors.
48 The value may also be a list of two elements where the second
49 element specifies the face for the bitmap. For possible bitmap
50 symbols, see `fringe-bitmaps'. See also `flymake-warning-bitmap'.
51
52 The option `flymake-fringe-indicator-position' controls how and where
53 this is used."
54 :group 'flymake
55 :version "24.3"
56 :type '(choice (symbol :tag "Bitmap")
57 (list :tag "Bitmap and face"
58 (symbol :tag "Bitmap")
59 (face :tag "Face"))))
60
61 (defcustom flymake-warning-bitmap 'question-mark
62 "Bitmap (a symbol) used in the fringe for indicating warnings.
63 The value may also be a list of two elements where the second
64 element specifies the face for the bitmap. For possible bitmap
65 symbols, see `fringe-bitmaps'. See also `flymake-error-bitmap'.
66
67 The option `flymake-fringe-indicator-position' controls how and where
68 this is used."
69 :group 'flymake
70 :version "24.3"
71 :type '(choice (symbol :tag "Bitmap")
72 (list :tag "Bitmap and face"
73 (symbol :tag "Bitmap")
74 (face :tag "Face"))))
75
76 (defcustom flymake-fringe-indicator-position 'left-fringe
77 "The position to put flymake fringe indicator.
78 The value can be nil (do not use indicators), `left-fringe' or `right-fringe'.
79 See `flymake-error-bitmap' and `flymake-warning-bitmap'."
80 :group 'flymake
81 :version "24.3"
82 :type '(choice (const left-fringe)
83 (const right-fringe)
84 (const :tag "No fringe indicators" nil)))
85
86 (defcustom flymake-compilation-prevents-syntax-check t
87 "If non-nil, don't start syntax check if compilation is running."
88 :group 'flymake
89 :type 'boolean)
90
91 (defcustom flymake-start-syntax-check-on-newline t
92 "Start syntax check if newline char was added/removed from the buffer."
93 :group 'flymake
94 :type 'boolean)
95
96 (defcustom flymake-no-changes-timeout 0.5
97 "Time to wait after last change before starting compilation."
98 :group 'flymake
99 :type 'number)
100
101 (defcustom flymake-gui-warnings-enabled t
102 "Enables/disables GUI warnings."
103 :group 'flymake
104 :type 'boolean)
105
106 (defcustom flymake-start-syntax-check-on-find-file t
107 "Start syntax check on find file."
108 :group 'flymake
109 :type 'boolean)
110
111 (defcustom flymake-log-level -1
112 "Logging level, only messages with level lower or equal will be logged.
113 -1 = NONE, 0 = ERROR, 1 = WARNING, 2 = INFO, 3 = DEBUG"
114 :group 'flymake
115 :type 'integer)
116
117 (defcustom flymake-xml-program
118 (if (executable-find "xmlstarlet") "xmlstarlet" "xml")
119 "Program to use for XML validation."
120 :type 'file
121 :group 'flymake
122 :version "24.4")
123
124 (defcustom flymake-master-file-dirs '("." "./src" "./UnitTest")
125 "Dirs where to look for master files."
126 :group 'flymake
127 :type '(repeat (string)))
128
129 (defcustom flymake-master-file-count-limit 32
130 "Max number of master files to check."
131 :group 'flymake
132 :type 'integer)
133
134 (defcustom flymake-allowed-file-name-masks
135 '(("\\.\\(?:c\\(?:pp\\|xx\\|\\+\\+\\)?\\|CC\\)\\'" flymake-simple-make-init)
136 ("\\.xml\\'" flymake-xml-init)
137 ("\\.html?\\'" flymake-xml-init)
138 ("\\.cs\\'" flymake-simple-make-init)
139 ("\\.p[ml]\\'" flymake-perl-init)
140 ("\\.php[345]?\\'" flymake-php-init)
141 ("\\.h\\'" flymake-master-make-header-init flymake-master-cleanup)
142 ("\\.java\\'" flymake-simple-make-java-init flymake-simple-java-cleanup)
143 ("[0-9]+\\.tex\\'" flymake-master-tex-init flymake-master-cleanup)
144 ("\\.tex\\'" flymake-simple-tex-init)
145 ("\\.idl\\'" flymake-simple-make-init)
146 ;; ("\\.cpp\\'" 1)
147 ;; ("\\.java\\'" 3)
148 ;; ("\\.h\\'" 2 ("\\.cpp\\'" "\\.c\\'")
149 ;; ("[ \t]*#[ \t]*include[ \t]*\"\\([\w0-9/\\_\.]*[/\\]*\\)\\(%s\\)\"" 1 2))
150 ;; ("\\.idl\\'" 1)
151 ;; ("\\.odl\\'" 1)
152 ;; ("[0-9]+\\.tex\\'" 2 ("\\.tex\\'")
153 ;; ("[ \t]*\\input[ \t]*{\\(.*\\)\\(%s\\)}" 1 2 ))
154 ;; ("\\.tex\\'" 1)
155 )
156 "Files syntax checking is allowed for.
157 This is an alist with elements of the form:
158 REGEXP INIT [CLEANUP [NAME]]
159 REGEXP is a regular expression that matches a file name.
160 INIT is the init function to use.
161 CLEANUP is the cleanup function to use, default `flymake-simple-cleanup'.
162 NAME is the file name function to use, default `flymake-get-real-file-name'."
163 :group 'flymake
164 :type '(alist :key-type (regexp :tag "File regexp")
165 :value-type
166 (list :tag "Handler functions"
167 (function :tag "Init function")
168 (choice :tag "Cleanup function"
169 (const :tag "flymake-simple-cleanup" nil)
170 function)
171 (choice :tag "Name function"
172 (const :tag "flymake-get-real-file-name" nil)
173 function))))
174
175 (defvar-local flymake-is-running nil
176 "If t, flymake syntax check process is running for the current buffer.")
177
178 (defvar-local flymake-timer nil
179 "Timer for starting syntax check.")
180
181 (defvar-local flymake-last-change-time nil
182 "Time of last buffer change.")
183
184 (defvar-local flymake-check-start-time nil
185 "Time at which syntax check was started.")
186
187 (defvar-local flymake-check-was-interrupted nil
188 "Non-nil if syntax check was killed by `flymake-compile'.")
189
190 (defvar-local flymake-err-info nil
191 "Sorted list of line numbers and lists of err info in the form (file, err-text).")
192
193 (defvar-local flymake-new-err-info nil
194 "Same as `flymake-err-info', effective when a syntax check is in progress.")
195
196 (defun flymake-log (level text &rest args)
197 "Log a message at level LEVEL.
198 If LEVEL is higher than `flymake-log-level', the message is
199 ignored. Otherwise, it is printed using `message'.
200 TEXT is a format control string, and the remaining arguments ARGS
201 are the string substitutions (see the function `format')."
202 (if (<= level flymake-log-level)
203 (let* ((msg (apply #'format-message text args)))
204 (message "%s" msg))))
205
206 (defun flymake-ins-after (list pos val)
207 "Insert VAL into LIST after position POS.
208 POS counts from zero."
209 (let ((tmp (copy-sequence list)))
210 (setcdr (nthcdr pos tmp) (cons val (nthcdr (1+ pos) tmp)))
211 tmp))
212
213 (defun flymake-set-at (list pos val)
214 "Set VAL at position POS in LIST.
215 POS counts from zero."
216 (let ((tmp (copy-sequence list)))
217 (setcar (nthcdr pos tmp) val)
218 tmp))
219
220 (defvar flymake-processes nil
221 "List of currently active flymake processes.")
222
223 (defvar-local flymake-output-residual nil)
224
225 (defun flymake-get-file-name-mode-and-masks (file-name)
226 "Return the corresponding entry from `flymake-allowed-file-name-masks'."
227 (unless (stringp file-name)
228 (error "Invalid file-name"))
229 (let ((fnm flymake-allowed-file-name-masks)
230 (mode-and-masks nil))
231 (while (and (not mode-and-masks) fnm)
232 (if (string-match (car (car fnm)) file-name)
233 (setq mode-and-masks (cdr (car fnm))))
234 (setq fnm (cdr fnm)))
235 (flymake-log 3 "file %s, init=%s" file-name (car mode-and-masks))
236 mode-and-masks))
237
238 (defun flymake-can-syntax-check-file (file-name)
239 "Determine whether we can syntax check FILE-NAME.
240 Return nil if we cannot, non-nil if we can."
241 (if (flymake-get-init-function file-name) t nil))
242
243 (defun flymake-get-init-function (file-name)
244 "Return init function to be used for the file."
245 (let* ((init-f (nth 0 (flymake-get-file-name-mode-and-masks file-name))))
246 ;;(flymake-log 0 "calling %s" init-f)
247 ;;(funcall init-f (current-buffer))
248 init-f))
249
250 (defun flymake-get-cleanup-function (file-name)
251 "Return cleanup function to be used for the file."
252 (or (nth 1 (flymake-get-file-name-mode-and-masks file-name))
253 'flymake-simple-cleanup))
254
255 (defun flymake-get-real-file-name-function (file-name)
256 (or (nth 2 (flymake-get-file-name-mode-and-masks file-name))
257 'flymake-get-real-file-name))
258
259 (defvar flymake-find-buildfile-cache (make-hash-table :test #'equal))
260
261 (defun flymake-get-buildfile-from-cache (dir-name)
262 "Look up DIR-NAME in cache and return its associated value.
263 If DIR-NAME is not found, return nil."
264 (gethash dir-name flymake-find-buildfile-cache))
265
266 (defun flymake-add-buildfile-to-cache (dir-name buildfile)
267 "Associate DIR-NAME with BUILDFILE in the buildfile cache."
268 (puthash dir-name buildfile flymake-find-buildfile-cache))
269
270 (defun flymake-clear-buildfile-cache ()
271 "Clear the buildfile cache."
272 (clrhash flymake-find-buildfile-cache))
273
274 (defun flymake-find-buildfile (buildfile-name source-dir-name)
275 "Find buildfile starting from current directory.
276 Buildfile includes Makefile, build.xml etc.
277 Return its file name if found, or nil if not found."
278 (or (flymake-get-buildfile-from-cache source-dir-name)
279 (let* ((file (locate-dominating-file source-dir-name buildfile-name)))
280 (if file
281 (progn
282 (flymake-log 3 "found buildfile at %s" file)
283 (flymake-add-buildfile-to-cache source-dir-name file)
284 file)
285 (progn
286 (flymake-log 3 "buildfile for %s not found" source-dir-name)
287 nil)))))
288
289 (defun flymake-fix-file-name (name)
290 "Replace all occurrences of `\\' with `/'."
291 (when name
292 (setq name (expand-file-name name))
293 (setq name (abbreviate-file-name name))
294 (setq name (directory-file-name name))
295 name))
296
297 (defun flymake-same-files (file-name-one file-name-two)
298 "Check if FILE-NAME-ONE and FILE-NAME-TWO point to same file.
299 Return t if so, nil if not."
300 (equal (flymake-fix-file-name file-name-one)
301 (flymake-fix-file-name file-name-two)))
302
303 ;; This is bound dynamically to pass a parameter to a sort predicate below
304 (defvar flymake-included-file-name)
305
306 (defun flymake-find-possible-master-files (file-name master-file-dirs masks)
307 "Find (by name and location) all possible master files.
308
309 Name is specified by FILE-NAME and location is specified by
310 MASTER-FILE-DIRS. Master files include .cpp and .c for .h.
311 Files are searched for starting from the .h directory and max
312 max-level parent dirs. File contents are not checked."
313 (let* ((dirs master-file-dirs)
314 (files nil)
315 (done nil))
316
317 (while (and (not done) dirs)
318 (let* ((dir (expand-file-name (car dirs) (file-name-directory file-name)))
319 (masks masks))
320 (while (and (file-exists-p dir) (not done) masks)
321 (let* ((mask (car masks))
322 (dir-files (directory-files dir t mask)))
323
324 (flymake-log 3 "dir %s, %d file(s) for mask %s"
325 dir (length dir-files) mask)
326 (while (and (not done) dir-files)
327 (when (not (file-directory-p (car dir-files)))
328 (setq files (cons (car dir-files) files))
329 (when (>= (length files) flymake-master-file-count-limit)
330 (flymake-log 3 "master file count limit (%d) reached" flymake-master-file-count-limit)
331 (setq done t)))
332 (setq dir-files (cdr dir-files))))
333 (setq masks (cdr masks))))
334 (setq dirs (cdr dirs)))
335 (when files
336 (let ((flymake-included-file-name (file-name-nondirectory file-name)))
337 (setq files (sort files 'flymake-master-file-compare))))
338 (flymake-log 3 "found %d possible master file(s)" (length files))
339 files))
340
341 (defun flymake-master-file-compare (file-one file-two)
342 "Compare two files specified by FILE-ONE and FILE-TWO.
343 This function is used in sort to move most possible file names
344 to the beginning of the list (File.h -> File.cpp moved to top)."
345 (and (equal (file-name-sans-extension flymake-included-file-name)
346 (file-name-base file-one))
347 (not (equal file-one file-two))))
348
349 (defvar flymake-check-file-limit 8192
350 "Maximum number of chars to look at when checking possible master file.
351 Nil means search the entire file.")
352
353 (defun flymake-check-patch-master-file-buffer
354 (master-file-temp-buffer
355 master-file-name patched-master-file-name
356 source-file-name patched-source-file-name
357 include-dirs regexp)
358 "Check if MASTER-FILE-NAME is a master file for SOURCE-FILE-NAME.
359 If yes, patch a copy of MASTER-FILE-NAME to include PATCHED-SOURCE-FILE-NAME
360 instead of SOURCE-FILE-NAME.
361
362 For example, foo.cpp is a master file if it includes foo.h.
363
364 Whether a buffer for MATER-FILE-NAME exists, use it as a source
365 instead of reading master file from disk."
366 (let* ((source-file-nondir (file-name-nondirectory source-file-name))
367 (source-file-extension (file-name-extension source-file-nondir))
368 (source-file-nonext (file-name-sans-extension source-file-nondir))
369 (found nil)
370 (inc-name nil)
371 (search-limit flymake-check-file-limit))
372 (setq regexp
373 (format regexp ; "[ \t]*#[ \t]*include[ \t]*\"\\(.*%s\\)\""
374 ;; Hack for tex files, where \include often excludes .tex.
375 ;; Maybe this is safe generally.
376 (if (and (> (length source-file-extension) 1)
377 (string-equal source-file-extension "tex"))
378 (format "%s\\(?:\\.%s\\)?"
379 (regexp-quote source-file-nonext)
380 (regexp-quote source-file-extension))
381 (regexp-quote source-file-nondir))))
382 (unwind-protect
383 (with-current-buffer master-file-temp-buffer
384 (if (or (not search-limit)
385 (> search-limit (point-max)))
386 (setq search-limit (point-max)))
387 (flymake-log 3 "checking %s against regexp %s"
388 master-file-name regexp)
389 (goto-char (point-min))
390 (while (and (< (point) search-limit)
391 (re-search-forward regexp search-limit t))
392 (let ((match-beg (match-beginning 1))
393 (match-end (match-end 1)))
394
395 (flymake-log 3 "found possible match for %s" source-file-nondir)
396 (setq inc-name (match-string 1))
397 (and (> (length source-file-extension) 1)
398 (string-equal source-file-extension "tex")
399 (not (string-match (format "\\.%s\\'" source-file-extension)
400 inc-name))
401 (setq inc-name (concat inc-name "." source-file-extension)))
402 (when (eq t (compare-strings
403 source-file-nondir nil nil
404 inc-name (- (length inc-name)
405 (length source-file-nondir)) nil))
406 (flymake-log 3 "inc-name=%s" inc-name)
407 (when (flymake-check-include source-file-name inc-name
408 include-dirs)
409 (setq found t)
410 ;; replace-match is not used here as it fails in
411 ;; XEmacs with 'last match not a buffer' error as
412 ;; check-includes calls replace-in-string
413 (flymake-replace-region
414 match-beg match-end
415 (file-name-nondirectory patched-source-file-name))))
416 (forward-line 1)))
417 (when found
418 (flymake-save-buffer-in-file patched-master-file-name)))
419 ;;+(flymake-log 3 "killing buffer %s"
420 ;; (buffer-name master-file-temp-buffer))
421 (kill-buffer master-file-temp-buffer))
422 ;;+(flymake-log 3 "check-patch master file %s: %s" master-file-name found)
423 (when found
424 (flymake-log 2 "found master file %s" master-file-name))
425 found))
426
427 ;;; XXX: remove
428 (defun flymake-replace-region (beg end rep)
429 "Replace text in BUFFER in region (BEG END) with REP."
430 (save-excursion
431 (goto-char end)
432 ;; Insert before deleting, so as to better preserve markers's positions.
433 (insert rep)
434 (delete-region beg end)))
435
436 (defun flymake-read-file-to-temp-buffer (file-name)
437 "Insert contents of FILE-NAME into newly created temp buffer."
438 (let* ((temp-buffer (get-buffer-create (generate-new-buffer-name (concat "flymake:" (file-name-nondirectory file-name))))))
439 (with-current-buffer temp-buffer
440 (insert-file-contents file-name))
441 temp-buffer))
442
443 (defun flymake-copy-buffer-to-temp-buffer (buffer)
444 "Copy contents of BUFFER into newly created temp buffer."
445 (with-current-buffer
446 (get-buffer-create (generate-new-buffer-name
447 (concat "flymake:" (buffer-name buffer))))
448 (insert-buffer-substring buffer)
449 (current-buffer)))
450
451 (defun flymake-check-include (source-file-name inc-name include-dirs)
452 "Check if SOURCE-FILE-NAME can be found in include path.
453 Return t if it can be found via include path using INC-NAME."
454 (if (file-name-absolute-p inc-name)
455 (flymake-same-files source-file-name inc-name)
456 (while (and include-dirs
457 (not (flymake-same-files
458 source-file-name
459 (concat (file-name-directory source-file-name)
460 "/" (car include-dirs)
461 "/" inc-name))))
462 (setq include-dirs (cdr include-dirs)))
463 include-dirs))
464
465 (defun flymake-find-buffer-for-file (file-name)
466 "Check if there exists a buffer visiting FILE-NAME.
467 Return t if so, nil if not."
468 (let ((buffer-name (get-file-buffer file-name)))
469 (if buffer-name
470 (get-buffer buffer-name))))
471
472 (defun flymake-create-master-file (source-file-name patched-source-file-name get-incl-dirs-f create-temp-f masks include-regexp)
473 "Save SOURCE-FILE-NAME with a different name.
474 Find master file, patch and save it."
475 (let* ((possible-master-files (flymake-find-possible-master-files source-file-name flymake-master-file-dirs masks))
476 (master-file-count (length possible-master-files))
477 (idx 0)
478 (temp-buffer nil)
479 (master-file-name nil)
480 (patched-master-file-name nil)
481 (found nil))
482
483 (while (and (not found) (< idx master-file-count))
484 (setq master-file-name (nth idx possible-master-files))
485 (setq patched-master-file-name (funcall create-temp-f master-file-name "flymake_master"))
486 (if (flymake-find-buffer-for-file master-file-name)
487 (setq temp-buffer (flymake-copy-buffer-to-temp-buffer (flymake-find-buffer-for-file master-file-name)))
488 (setq temp-buffer (flymake-read-file-to-temp-buffer master-file-name)))
489 (setq found
490 (flymake-check-patch-master-file-buffer
491 temp-buffer
492 master-file-name
493 patched-master-file-name
494 source-file-name
495 patched-source-file-name
496 (funcall get-incl-dirs-f (file-name-directory master-file-name))
497 include-regexp))
498 (setq idx (1+ idx)))
499 (if found
500 (list master-file-name patched-master-file-name)
501 (progn
502 (flymake-log 3 "none of %d master file(s) checked includes %s" master-file-count
503 (file-name-nondirectory source-file-name))
504 nil))))
505
506 (defun flymake-save-buffer-in-file (file-name)
507 "Save the entire buffer contents into file FILE-NAME.
508 Create parent directories as needed."
509 (make-directory (file-name-directory file-name) 1)
510 (write-region nil nil file-name nil 566)
511 (flymake-log 3 "saved buffer %s in file %s" (buffer-name) file-name))
512
513 (defun flymake-process-filter (process output)
514 "Parse OUTPUT and highlight error lines.
515 It's flymake process filter."
516 (let ((source-buffer (process-buffer process)))
517
518 (flymake-log 3 "received %d byte(s) of output from process %d"
519 (length output) (process-id process))
520 (when (buffer-live-p source-buffer)
521 (with-current-buffer source-buffer
522 (flymake-parse-output-and-residual output)))))
523
524 (defun flymake-process-sentinel (process _event)
525 "Sentinel for syntax check buffers."
526 (when (memq (process-status process) '(signal exit))
527 (let* ((exit-status (process-exit-status process))
528 (command (process-command process))
529 (source-buffer (process-buffer process))
530 (cleanup-f (flymake-get-cleanup-function (buffer-file-name source-buffer))))
531
532 (flymake-log 2 "process %d exited with code %d"
533 (process-id process) exit-status)
534 (condition-case err
535 (progn
536 (flymake-log 3 "cleaning up using %s" cleanup-f)
537 (when (buffer-live-p source-buffer)
538 (with-current-buffer source-buffer
539 (funcall cleanup-f)))
540
541 (delete-process process)
542 (setq flymake-processes (delq process flymake-processes))
543
544 (when (buffer-live-p source-buffer)
545 (with-current-buffer source-buffer
546
547 (flymake-parse-residual)
548 (flymake-post-syntax-check exit-status command)
549 (setq flymake-is-running nil))))
550 (error
551 (let ((err-str (format "Error in process sentinel for buffer %s: %s"
552 source-buffer (error-message-string err))))
553 (flymake-log 0 err-str)
554 (with-current-buffer source-buffer
555 (setq flymake-is-running nil))))))))
556
557 (defun flymake-post-syntax-check (exit-status command)
558 (save-restriction
559 (widen)
560 (setq flymake-err-info flymake-new-err-info)
561 (setq flymake-new-err-info nil)
562 (setq flymake-err-info
563 (flymake-fix-line-numbers
564 flymake-err-info 1 (count-lines (point-min) (point-max))))
565 (flymake-delete-own-overlays)
566 (flymake-highlight-err-lines flymake-err-info)
567 (let (err-count warn-count)
568 (setq err-count (flymake-get-err-count flymake-err-info "e"))
569 (setq warn-count (flymake-get-err-count flymake-err-info "w"))
570 (flymake-log 2 "%s: %d error(s), %d warning(s) in %.2f second(s)"
571 (buffer-name) err-count warn-count
572 (- (float-time) flymake-check-start-time))
573 (setq flymake-check-start-time nil)
574
575 (if (and (equal 0 err-count) (equal 0 warn-count))
576 (if (equal 0 exit-status)
577 (flymake-report-status "" "") ; PASSED
578 (if (not flymake-check-was-interrupted)
579 (flymake-report-fatal-status "CFGERR"
580 (format "Configuration error has occurred while running %s" command))
581 (flymake-report-status nil ""))) ; "STOPPED"
582 (flymake-report-status (format "%d/%d" err-count warn-count) "")))))
583
584 (defun flymake-parse-output-and-residual (output)
585 "Split OUTPUT into lines, merge in residual if necessary."
586 (let* ((buffer-residual flymake-output-residual)
587 (total-output (if buffer-residual (concat buffer-residual output) output))
588 (lines-and-residual (flymake-split-output total-output))
589 (lines (nth 0 lines-and-residual))
590 (new-residual (nth 1 lines-and-residual)))
591 (setq flymake-output-residual new-residual)
592 (setq flymake-new-err-info
593 (flymake-parse-err-lines
594 flymake-new-err-info lines))))
595
596 (defun flymake-parse-residual ()
597 "Parse residual if it's non empty."
598 (when flymake-output-residual
599 (setq flymake-new-err-info
600 (flymake-parse-err-lines
601 flymake-new-err-info
602 (list flymake-output-residual)))
603 (setq flymake-output-residual nil)))
604
605 (defun flymake-er-make-er (line-no line-err-info-list)
606 (list line-no line-err-info-list))
607
608 (defun flymake-er-get-line (err-info)
609 (nth 0 err-info))
610
611 (defun flymake-er-get-line-err-info-list (err-info)
612 (nth 1 err-info))
613
614 (cl-defstruct (flymake-ler
615 (:constructor nil)
616 (:constructor flymake-ler-make-ler (file line type text &optional full-file)))
617 file line type text full-file)
618
619 (defun flymake-ler-set-file (line-err-info file)
620 (flymake-ler-make-ler file
621 (flymake-ler-line line-err-info)
622 (flymake-ler-type line-err-info)
623 (flymake-ler-text line-err-info)
624 (flymake-ler-full-file line-err-info)))
625
626 (defun flymake-ler-set-full-file (line-err-info full-file)
627 (flymake-ler-make-ler (flymake-ler-file line-err-info)
628 (flymake-ler-line line-err-info)
629 (flymake-ler-type line-err-info)
630 (flymake-ler-text line-err-info)
631 full-file))
632
633 (defun flymake-ler-set-line (line-err-info line)
634 (flymake-ler-make-ler (flymake-ler-file line-err-info)
635 line
636 (flymake-ler-type line-err-info)
637 (flymake-ler-text line-err-info)
638 (flymake-ler-full-file line-err-info)))
639
640 (defun flymake-get-line-err-count (line-err-info-list type)
641 "Return number of errors of specified TYPE.
642 Value of TYPE is either \"e\" or \"w\"."
643 (let* ((idx 0)
644 (count (length line-err-info-list))
645 (err-count 0))
646
647 (while (< idx count)
648 (when (equal type (flymake-ler-type (nth idx line-err-info-list)))
649 (setq err-count (1+ err-count)))
650 (setq idx (1+ idx)))
651 err-count))
652
653 (defun flymake-get-err-count (err-info-list type)
654 "Return number of errors of specified TYPE for ERR-INFO-LIST."
655 (let* ((idx 0)
656 (count (length err-info-list))
657 (err-count 0))
658 (while (< idx count)
659 (setq err-count (+ err-count (flymake-get-line-err-count (nth 1 (nth idx err-info-list)) type)))
660 (setq idx (1+ idx)))
661 err-count))
662
663 (defun flymake-fix-line-numbers (err-info-list min-line max-line)
664 "Replace line numbers with fixed value.
665 If line-numbers is less than MIN-LINE, set line numbers to MIN-LINE.
666 If line numbers is greater than MAX-LINE, set line numbers to MAX-LINE.
667 The reason for this fix is because some compilers might report
668 line number outside the file being compiled."
669 (let* ((count (length err-info-list))
670 (err-info nil)
671 (line 0))
672 (while (> count 0)
673 (setq err-info (nth (1- count) err-info-list))
674 (setq line (flymake-er-get-line err-info))
675 (when (or (< line min-line) (> line max-line))
676 (setq line (if (< line min-line) min-line max-line))
677 (setq err-info-list (flymake-set-at err-info-list (1- count)
678 (flymake-er-make-er line
679 (flymake-er-get-line-err-info-list err-info)))))
680 (setq count (1- count))))
681 err-info-list)
682
683 (defun flymake-highlight-err-lines (err-info-list)
684 "Highlight error lines in BUFFER using info from ERR-INFO-LIST."
685 (save-excursion
686 (dolist (err err-info-list)
687 (flymake-highlight-line (car err) (nth 1 err)))))
688
689 (defun flymake-overlay-p (ov)
690 "Determine whether overlay OV was created by flymake."
691 (and (overlayp ov) (overlay-get ov 'flymake-overlay)))
692
693 (defun flymake-make-overlay (beg end tooltip-text face bitmap)
694 "Allocate a flymake overlay in range BEG and END."
695 (when (not (flymake-region-has-flymake-overlays beg end))
696 (let ((ov (make-overlay beg end nil t))
697 (fringe (and flymake-fringe-indicator-position
698 (propertize "!" 'display
699 (cons flymake-fringe-indicator-position
700 (if (listp bitmap)
701 bitmap
702 (list bitmap)))))))
703 (overlay-put ov 'face face)
704 (overlay-put ov 'help-echo tooltip-text)
705 (overlay-put ov 'flymake-overlay t)
706 (overlay-put ov 'priority 100)
707 (overlay-put ov 'evaporate t)
708 (overlay-put ov 'before-string fringe)
709 ;;+(flymake-log 3 "created overlay %s" ov)
710 ov)
711 (flymake-log 3 "created an overlay at (%d-%d)" beg end)))
712
713 (defun flymake-delete-own-overlays ()
714 "Delete all flymake overlays in BUFFER."
715 (dolist (ol (overlays-in (point-min) (point-max)))
716 (when (flymake-overlay-p ol)
717 (delete-overlay ol)
718 ;;+(flymake-log 3 "deleted overlay %s" ol)
719 )))
720
721 (defun flymake-region-has-flymake-overlays (beg end)
722 "Check if region specified by BEG and END has overlay.
723 Return t if it has at least one flymake overlay, nil if no overlay."
724 (let ((ov (overlays-in beg end))
725 (has-flymake-overlays nil))
726 (while (consp ov)
727 (when (flymake-overlay-p (car ov))
728 (setq has-flymake-overlays t))
729 (setq ov (cdr ov)))
730 has-flymake-overlays))
731
732 (defface flymake-errline
733 '((((supports :underline (:style wave)))
734 :underline (:style wave :color "Red1"))
735 (t
736 :inherit error))
737 "Face used for marking error lines."
738 :version "24.4"
739 :group 'flymake)
740
741 (defface flymake-warnline
742 '((((supports :underline (:style wave)))
743 :underline (:style wave :color "DarkOrange"))
744 (t
745 :inherit warning))
746 "Face used for marking warning lines."
747 :version "24.4"
748 :group 'flymake)
749
750 (defun flymake-highlight-line (line-no line-err-info-list)
751 "Highlight line LINE-NO in current buffer.
752 Perhaps use text from LINE-ERR-INFO-LIST to enhance highlighting."
753 (goto-char (point-min))
754 (forward-line (1- line-no))
755 (pcase-let* ((beg (progn (back-to-indentation) (point)))
756 (end (progn
757 (end-of-line)
758 (skip-chars-backward " \t\f\t\n" beg)
759 (if (eq (point) beg)
760 (line-beginning-position 2)
761 (point))))
762 (tooltip-text (mapconcat #'flymake-ler-text line-err-info-list "\n"))
763 (`(,face ,bitmap)
764 (if (> (flymake-get-line-err-count line-err-info-list "e") 0)
765 (list 'flymake-errline flymake-error-bitmap)
766 (list 'flymake-warnline flymake-warning-bitmap))))
767 (flymake-make-overlay beg end tooltip-text face bitmap)))
768
769 (defun flymake-parse-err-lines (err-info-list lines)
770 "Parse err LINES, store info in ERR-INFO-LIST."
771 (let* ((count (length lines))
772 (idx 0)
773 (line-err-info nil)
774 (real-file-name nil)
775 (source-file-name buffer-file-name)
776 (get-real-file-name-f (flymake-get-real-file-name-function source-file-name)))
777
778 (while (< idx count)
779 (setq line-err-info (flymake-parse-line (nth idx lines)))
780 (when line-err-info
781 (setq real-file-name (funcall get-real-file-name-f
782 (flymake-ler-file line-err-info)))
783 (setq line-err-info (flymake-ler-set-full-file line-err-info real-file-name))
784
785 (when (flymake-same-files real-file-name source-file-name)
786 (setq line-err-info (flymake-ler-set-file line-err-info nil))
787 (setq err-info-list (flymake-add-err-info err-info-list line-err-info))))
788 (flymake-log 3 "parsed `%s', %s line-err-info" (nth idx lines) (if line-err-info "got" "no"))
789 (setq idx (1+ idx)))
790 err-info-list))
791
792 (defun flymake-split-output (output)
793 "Split OUTPUT into lines.
794 Return last one as residual if it does not end with newline char.
795 Returns ((LINES) RESIDUAL)."
796 (when (and output (> (length output) 0))
797 (let* ((lines (split-string output "[\n\r]+" t))
798 (complete (equal "\n" (char-to-string (aref output (1- (length output))))))
799 (residual nil))
800 (when (not complete)
801 (setq residual (car (last lines)))
802 (setq lines (butlast lines)))
803 (list lines residual))))
804
805 (defun flymake-reformat-err-line-patterns-from-compile-el (original-list)
806 "Grab error line patterns from ORIGINAL-LIST in compile.el format.
807 Convert it to flymake internal format."
808 (let* ((converted-list '()))
809 (dolist (item original-list)
810 (setq item (cdr item))
811 (let ((regexp (nth 0 item))
812 (file (nth 1 item))
813 (line (nth 2 item))
814 (col (nth 3 item)))
815 (if (consp file) (setq file (car file)))
816 (if (consp line) (setq line (car line)))
817 (if (consp col) (setq col (car col)))
818
819 (when (not (functionp line))
820 (setq converted-list (cons (list regexp file line col) converted-list)))))
821 converted-list))
822
823 (require 'compile)
824
825 (defvar flymake-err-line-patterns ; regexp file-idx line-idx col-idx (optional) text-idx(optional), match-end to end of string is error text
826 (append
827 '(
828 ;; MS Visual C++ 6.0
829 ("\\(\\([a-zA-Z]:\\)?[^:(\t\n]+\\)(\\([0-9]+\\)) : \\(\\(error\\|warning\\|fatal error\\) \\(C[0-9]+\\):[ \t\n]*\\(.+\\)\\)"
830 1 3 nil 4)
831 ;; jikes
832 ("\\(\\([a-zA-Z]:\\)?[^:(\t\n]+\\):\\([0-9]+\\):[0-9]+:[0-9]+:[0-9]+: \\(\\(Error\\|Warning\\|Caution\\|Semantic Error\\):[ \t\n]*\\(.+\\)\\)"
833 1 3 nil 4)
834 ;; MS midl
835 ("midl[ ]*:[ ]*\\(command line error .*\\)"
836 nil nil nil 1)
837 ;; MS C#
838 ("\\(\\([a-zA-Z]:\\)?[^:(\t\n]+\\)(\\([0-9]+\\),[0-9]+): \\(\\(error\\|warning\\|fatal error\\) \\(CS[0-9]+\\):[ \t\n]*\\(.+\\)\\)"
839 1 3 nil 4)
840 ;; perl
841 ("\\(.*\\) at \\([^ \n]+\\) line \\([0-9]+\\)[,.\n]" 2 3 nil 1)
842 ;; PHP
843 ("\\(?:Parse\\|Fatal\\) error: \\(.*\\) in \\(.*\\) on line \\([0-9]+\\)" 2 3 nil 1)
844 ;; LaTeX warnings (fileless) ("\\(LaTeX \\(Warning\\|Error\\): .*\\) on input line \\([0-9]+\\)" 20 3 nil 1)
845 ;; ant/javac. Note this also matches gcc warnings!
846 (" *\\(\\[javac\\] *\\)?\\(\\([a-zA-Z]:\\)?[^:(\t\n]+\\):\\([0-9]+\\)\\(?::[0-9]+\\)?:[ \t\n]*\\(.+\\)"
847 2 4 nil 5))
848 ;; compilation-error-regexp-alist)
849 (flymake-reformat-err-line-patterns-from-compile-el compilation-error-regexp-alist-alist))
850 "Patterns for matching error/warning lines. Each pattern has the form
851 \(REGEXP FILE-IDX LINE-IDX COL-IDX ERR-TEXT-IDX).
852 Use `flymake-reformat-err-line-patterns-from-compile-el' to add patterns
853 from compile.el")
854
855 (define-obsolete-variable-alias 'flymake-warning-re 'flymake-warning-predicate "24.4")
856 (defvar flymake-warning-predicate "^[wW]arning"
857 "Predicate matching against error text to detect a warning.
858 Takes a single argument, the error's text and should return non-nil
859 if it's a warning.
860 Instead of a function, it can also be a regular expression.")
861
862 (defun flymake-parse-line (line)
863 "Parse LINE to see if it is an error or warning.
864 Return its components if so, nil otherwise."
865 (let ((raw-file-name nil)
866 (line-no 0)
867 (err-type "e")
868 (err-text nil)
869 (patterns flymake-err-line-patterns)
870 (matched nil))
871 (while (and patterns (not matched))
872 (when (string-match (car (car patterns)) line)
873 (let* ((file-idx (nth 1 (car patterns)))
874 (line-idx (nth 2 (car patterns))))
875
876 (setq raw-file-name (if file-idx (match-string file-idx line) nil))
877 (setq line-no (if line-idx (string-to-number
878 (match-string line-idx line)) 0))
879 (setq err-text (if (> (length (car patterns)) 4)
880 (match-string (nth 4 (car patterns)) line)
881 (flymake-patch-err-text
882 (substring line (match-end 0)))))
883 (if (null err-text)
884 (setq err-text "<no error text>")
885 (when (cond ((stringp flymake-warning-predicate)
886 (string-match flymake-warning-predicate err-text))
887 ((functionp flymake-warning-predicate)
888 (funcall flymake-warning-predicate err-text)))
889 (setq err-type "w")))
890 (flymake-log
891 3 "parse line: file-idx=%s line-idx=%s file=%s line=%s text=%s"
892 file-idx line-idx raw-file-name line-no err-text)
893 (setq matched t)))
894 (setq patterns (cdr patterns)))
895 (if matched
896 (flymake-ler-make-ler raw-file-name line-no err-type err-text)
897 ())))
898
899 (defun flymake-find-err-info (err-info-list line-no)
900 "Find (line-err-info-list pos) for specified LINE-NO."
901 (if err-info-list
902 (let* ((line-err-info-list nil)
903 (pos 0)
904 (count (length err-info-list)))
905
906 (while (and (< pos count) (< (car (nth pos err-info-list)) line-no))
907 (setq pos (1+ pos)))
908 (when (and (< pos count) (equal (car (nth pos err-info-list)) line-no))
909 (setq line-err-info-list (flymake-er-get-line-err-info-list (nth pos err-info-list))))
910 (list line-err-info-list pos))
911 '(nil 0)))
912
913 (defun flymake-line-err-info-is-less-or-equal (line-one line-two)
914 (or (string< (flymake-ler-type line-one) (flymake-ler-type line-two))
915 (and (string= (flymake-ler-type line-one) (flymake-ler-type line-two))
916 (not (flymake-ler-file line-one)) (flymake-ler-file line-two))
917 (and (string= (flymake-ler-type line-one) (flymake-ler-type line-two))
918 (or (and (flymake-ler-file line-one) (flymake-ler-file line-two))
919 (and (not (flymake-ler-file line-one)) (not (flymake-ler-file line-two)))))))
920
921 (defun flymake-add-line-err-info (line-err-info-list line-err-info)
922 "Update LINE-ERR-INFO-LIST with the error LINE-ERR-INFO.
923 For the format of LINE-ERR-INFO, see `flymake-ler-make-ler'.
924 The new element is inserted in the proper position, according to
925 the predicate `flymake-line-err-info-is-less-or-equal'.
926 The updated value of LINE-ERR-INFO-LIST is returned."
927 (if (not line-err-info-list)
928 (list line-err-info)
929 (let* ((count (length line-err-info-list))
930 (idx 0))
931 (while (and (< idx count) (flymake-line-err-info-is-less-or-equal (nth idx line-err-info-list) line-err-info))
932 (setq idx (1+ idx)))
933 (cond ((equal 0 idx) (setq line-err-info-list (cons line-err-info line-err-info-list)))
934 (t (setq line-err-info-list (flymake-ins-after line-err-info-list (1- idx) line-err-info))))
935 line-err-info-list)))
936
937 (defun flymake-add-err-info (err-info-list line-err-info)
938 "Update ERR-INFO-LIST with the error LINE-ERR-INFO, preserving sort order.
939 Returns the updated value of ERR-INFO-LIST.
940 For the format of ERR-INFO-LIST, see `flymake-err-info'.
941 For the format of LINE-ERR-INFO, see `flymake-ler-make-ler'."
942 (let* ((line-no (if (flymake-ler-file line-err-info) 1 (flymake-ler-line line-err-info)))
943 (info-and-pos (flymake-find-err-info err-info-list line-no))
944 (exists (car info-and-pos))
945 (pos (nth 1 info-and-pos))
946 (line-err-info-list nil)
947 (err-info nil))
948
949 (if exists
950 (setq line-err-info-list (flymake-er-get-line-err-info-list (car (nthcdr pos err-info-list)))))
951 (setq line-err-info-list (flymake-add-line-err-info line-err-info-list line-err-info))
952
953 (setq err-info (flymake-er-make-er line-no line-err-info-list))
954 (cond (exists (setq err-info-list (flymake-set-at err-info-list pos err-info)))
955 ((equal 0 pos) (setq err-info-list (cons err-info err-info-list)))
956 (t (setq err-info-list (flymake-ins-after err-info-list (1- pos) err-info))))
957 err-info-list))
958
959 (defun flymake-get-project-include-dirs-imp (basedir)
960 "Include dirs for the project current file belongs to."
961 (if (flymake-get-project-include-dirs-from-cache basedir)
962 (progn
963 (flymake-get-project-include-dirs-from-cache basedir))
964 ;;else
965 (let* ((command-line (concat "make -C "
966 (shell-quote-argument basedir)
967 " DUMPVARS=INCLUDE_DIRS dumpvars"))
968 (output (shell-command-to-string command-line))
969 (lines (split-string output "\n" t))
970 (count (length lines))
971 (idx 0)
972 (inc-dirs nil))
973 (while (and (< idx count) (not (string-match "^INCLUDE_DIRS=.*" (nth idx lines))))
974 (setq idx (1+ idx)))
975 (when (< idx count)
976 (let* ((inc-lines (split-string (nth idx lines) " *-I" t))
977 (inc-count (length inc-lines)))
978 (while (> inc-count 0)
979 (when (not (string-match "^INCLUDE_DIRS=.*" (nth (1- inc-count) inc-lines)))
980 (push (replace-regexp-in-string "\"" "" (nth (1- inc-count) inc-lines)) inc-dirs))
981 (setq inc-count (1- inc-count)))))
982 (flymake-add-project-include-dirs-to-cache basedir inc-dirs)
983 inc-dirs)))
984
985 (defvar flymake-get-project-include-dirs-function #'flymake-get-project-include-dirs-imp
986 "Function used to get project include dirs, one parameter: basedir name.")
987
988 (defun flymake-get-project-include-dirs (basedir)
989 (funcall flymake-get-project-include-dirs-function basedir))
990
991 (defun flymake-get-system-include-dirs ()
992 "System include dirs - from the `INCLUDE' env setting."
993 (let* ((includes (getenv "INCLUDE")))
994 (if includes (split-string includes path-separator t) nil)))
995
996 (defvar flymake-project-include-dirs-cache (make-hash-table :test #'equal))
997
998 (defun flymake-get-project-include-dirs-from-cache (base-dir)
999 (gethash base-dir flymake-project-include-dirs-cache))
1000
1001 (defun flymake-add-project-include-dirs-to-cache (base-dir include-dirs)
1002 (puthash base-dir include-dirs flymake-project-include-dirs-cache))
1003
1004 (defun flymake-clear-project-include-dirs-cache ()
1005 (clrhash flymake-project-include-dirs-cache))
1006
1007 (defun flymake-get-include-dirs (base-dir)
1008 "Get dirs to use when resolving local file names."
1009 (let* ((include-dirs (append '(".") (flymake-get-project-include-dirs base-dir) (flymake-get-system-include-dirs))))
1010 include-dirs))
1011
1012 ;; (defun flymake-restore-formatting ()
1013 ;; "Remove any formatting made by flymake."
1014 ;; )
1015
1016 ;; (defun flymake-get-program-dir (buffer)
1017 ;; "Get dir to start program in."
1018 ;; (unless (bufferp buffer)
1019 ;; (error "Invalid buffer"))
1020 ;; (with-current-buffer buffer
1021 ;; default-directory))
1022
1023 (defun flymake-safe-delete-file (file-name)
1024 (when (and file-name (file-exists-p file-name))
1025 (delete-file file-name)
1026 (flymake-log 1 "deleted file %s" file-name)))
1027
1028 (defun flymake-safe-delete-directory (dir-name)
1029 (condition-case nil
1030 (progn
1031 (delete-directory dir-name)
1032 (flymake-log 1 "deleted dir %s" dir-name))
1033 (error
1034 (flymake-log 1 "Failed to delete dir %s, error ignored" dir-name))))
1035
1036 (defun flymake-start-syntax-check ()
1037 "Start syntax checking for current buffer."
1038 (interactive)
1039 (flymake-log 3 "flymake is running: %s" flymake-is-running)
1040 (when (and (not flymake-is-running)
1041 (flymake-can-syntax-check-file buffer-file-name))
1042 (when (or (not flymake-compilation-prevents-syntax-check)
1043 (not (flymake-compilation-is-running))) ;+ (flymake-rep-ort-status buffer "COMP")
1044 (flymake-clear-buildfile-cache)
1045 (flymake-clear-project-include-dirs-cache)
1046
1047 (setq flymake-check-was-interrupted nil)
1048
1049 (let* ((source-file-name buffer-file-name)
1050 (init-f (flymake-get-init-function source-file-name))
1051 (cleanup-f (flymake-get-cleanup-function source-file-name))
1052 (cmd-and-args (funcall init-f))
1053 (cmd (nth 0 cmd-and-args))
1054 (args (nth 1 cmd-and-args))
1055 (dir (nth 2 cmd-and-args)))
1056 (if (not cmd-and-args)
1057 (progn
1058 (flymake-log 0 "init function %s for %s failed, cleaning up" init-f source-file-name)
1059 (funcall cleanup-f))
1060 (progn
1061 (setq flymake-last-change-time nil)
1062 (flymake-start-syntax-check-process cmd args dir)))))))
1063
1064 (defun flymake-start-syntax-check-process (cmd args dir)
1065 "Start syntax check process."
1066 (condition-case err
1067 (let* ((process
1068 (let ((default-directory (or dir default-directory)))
1069 (when dir
1070 (flymake-log 3 "starting process on dir %s" dir))
1071 (apply 'start-file-process
1072 "flymake-proc" (current-buffer) cmd args))))
1073 (set-process-sentinel process 'flymake-process-sentinel)
1074 (set-process-filter process 'flymake-process-filter)
1075 (push process flymake-processes)
1076
1077 (setq flymake-is-running t)
1078 (setq flymake-last-change-time nil)
1079 (setq flymake-check-start-time (float-time))
1080
1081 (flymake-report-status nil "*")
1082 (flymake-log 2 "started process %d, command=%s, dir=%s"
1083 (process-id process) (process-command process)
1084 default-directory)
1085 process)
1086 (error
1087 (let* ((err-str
1088 (format-message
1089 "Failed to launch syntax check process `%s' with args %s: %s"
1090 cmd args (error-message-string err)))
1091 (source-file-name buffer-file-name)
1092 (cleanup-f (flymake-get-cleanup-function source-file-name)))
1093 (flymake-log 0 err-str)
1094 (funcall cleanup-f)
1095 (flymake-report-fatal-status "PROCERR" err-str)))))
1096
1097 (defun flymake-kill-process (proc)
1098 "Kill process PROC."
1099 (kill-process proc)
1100 (let* ((buf (process-buffer proc)))
1101 (when (buffer-live-p buf)
1102 (with-current-buffer buf
1103 (setq flymake-check-was-interrupted t))))
1104 (flymake-log 1 "killed process %d" (process-id proc)))
1105
1106 (defun flymake-stop-all-syntax-checks ()
1107 "Kill all syntax check processes."
1108 (interactive)
1109 (while flymake-processes
1110 (flymake-kill-process (pop flymake-processes))))
1111
1112 (defun flymake-compilation-is-running ()
1113 (and (boundp 'compilation-in-progress)
1114 compilation-in-progress))
1115
1116 (defun flymake-compile ()
1117 "Kill all flymake syntax checks, start compilation."
1118 (interactive)
1119 (flymake-stop-all-syntax-checks)
1120 (call-interactively 'compile))
1121
1122 (defun flymake-on-timer-event (buffer)
1123 "Start a syntax check for buffer BUFFER if necessary."
1124 (when (buffer-live-p buffer)
1125 (with-current-buffer buffer
1126 (when (and (not flymake-is-running)
1127 flymake-last-change-time
1128 (> (- (float-time) flymake-last-change-time)
1129 flymake-no-changes-timeout))
1130
1131 (setq flymake-last-change-time nil)
1132 (flymake-log 3 "starting syntax check as more than 1 second passed since last change")
1133 (flymake-start-syntax-check)))))
1134
1135 (define-obsolete-function-alias 'flymake-display-err-menu-for-current-line
1136 'flymake-popup-current-error-menu "24.4")
1137
1138 (defun flymake-popup-current-error-menu (&optional event)
1139 "Pop up a menu with errors/warnings for current line."
1140 (interactive (list last-nonmenu-event))
1141 (let* ((line-no (line-number-at-pos))
1142 (errors (or (car (flymake-find-err-info flymake-err-info line-no))
1143 (user-error "No errors for current line")))
1144 (menu (mapcar (lambda (x)
1145 (if (flymake-ler-file x)
1146 (cons (format "%s - %s(%d)"
1147 (flymake-ler-text x)
1148 (flymake-ler-file x)
1149 (flymake-ler-line x))
1150 x)
1151 (list (flymake-ler-text x))))
1152 errors))
1153 (event (if (mouse-event-p event)
1154 event
1155 (list 'mouse-1 (posn-at-point))))
1156 (title (format "Line %d: %d error(s), %d warning(s)"
1157 line-no
1158 (flymake-get-line-err-count errors "e")
1159 (flymake-get-line-err-count errors "w")))
1160 (choice (x-popup-menu event (list title (cons "" menu)))))
1161 (flymake-log 3 "choice=%s" choice)
1162 (when choice
1163 (flymake-goto-file-and-line (flymake-ler-full-file choice)
1164 (flymake-ler-line choice)))))
1165
1166 (defun flymake-goto-file-and-line (file line)
1167 "Try to get buffer for FILE and goto line LINE in it."
1168 (if (not (file-exists-p file))
1169 (flymake-log 1 "File %s does not exist" file)
1170 (find-file file)
1171 (goto-char (point-min))
1172 (forward-line (1- line))))
1173
1174 ;; flymake minor mode declarations
1175 (defvar-local flymake-mode-line nil)
1176 (defvar-local flymake-mode-line-e-w nil)
1177 (defvar-local flymake-mode-line-status nil)
1178
1179 (defun flymake-report-status (e-w &optional status)
1180 "Show status in mode line."
1181 (when e-w
1182 (setq flymake-mode-line-e-w e-w))
1183 (when status
1184 (setq flymake-mode-line-status status))
1185 (let* ((mode-line " Flymake"))
1186 (when (> (length flymake-mode-line-e-w) 0)
1187 (setq mode-line (concat mode-line ":" flymake-mode-line-e-w)))
1188 (setq mode-line (concat mode-line flymake-mode-line-status))
1189 (setq flymake-mode-line mode-line)
1190 (force-mode-line-update)))
1191
1192 (defun flymake-display-warning (warning)
1193 "Display a warning to user."
1194 (message-box warning))
1195
1196 (defun flymake-report-fatal-status (status warning)
1197 "Display a warning and switch flymake mode off."
1198 (when flymake-gui-warnings-enabled
1199 (flymake-display-warning (format "Flymake: %s. Flymake will be switched OFF" warning))
1200 )
1201 (flymake-mode 0)
1202 (flymake-log 0 "switched OFF Flymake mode for buffer %s due to fatal status %s, warning %s"
1203 (buffer-name) status warning))
1204
1205 ;;;###autoload
1206 (define-minor-mode flymake-mode nil
1207 :group 'flymake :lighter flymake-mode-line
1208 (cond
1209
1210 ;; Turning the mode ON.
1211 (flymake-mode
1212 (cond
1213 ((not buffer-file-name)
1214 (message "Flymake unable to run without a buffer file name"))
1215 ((not (flymake-can-syntax-check-file buffer-file-name))
1216 (flymake-log 2 "flymake cannot check syntax in buffer %s" (buffer-name)))
1217 (t
1218 (add-hook 'after-change-functions 'flymake-after-change-function nil t)
1219 (add-hook 'after-save-hook 'flymake-after-save-hook nil t)
1220 (add-hook 'kill-buffer-hook 'flymake-kill-buffer-hook nil t)
1221 ;;+(add-hook 'find-file-hook 'flymake-find-file-hook)
1222
1223 (flymake-report-status "" "")
1224
1225 (setq flymake-timer
1226 (run-at-time nil 1 'flymake-on-timer-event (current-buffer)))
1227
1228 (when (and flymake-start-syntax-check-on-find-file
1229 ;; Since we write temp files in current dir, there's no point
1230 ;; trying if the directory is read-only (bug#8954).
1231 (file-writable-p (file-name-directory buffer-file-name)))
1232 (with-demoted-errors
1233 (flymake-start-syntax-check))))))
1234
1235 ;; Turning the mode OFF.
1236 (t
1237 (remove-hook 'after-change-functions 'flymake-after-change-function t)
1238 (remove-hook 'after-save-hook 'flymake-after-save-hook t)
1239 (remove-hook 'kill-buffer-hook 'flymake-kill-buffer-hook t)
1240 ;;+(remove-hook 'find-file-hook (function flymake-find-file-hook) t)
1241
1242 (flymake-delete-own-overlays)
1243
1244 (when flymake-timer
1245 (cancel-timer flymake-timer)
1246 (setq flymake-timer nil))
1247
1248 (setq flymake-is-running nil))))
1249
1250 ;;;###autoload
1251 (defun flymake-mode-on ()
1252 "Turn flymake mode on."
1253 (flymake-mode 1)
1254 (flymake-log 1 "flymake mode turned ON for buffer %s" (buffer-name)))
1255
1256 ;;;###autoload
1257 (defun flymake-mode-off ()
1258 "Turn flymake mode off."
1259 (flymake-mode 0)
1260 (flymake-log 1 "flymake mode turned OFF for buffer %s" (buffer-name)))
1261
1262 (defun flymake-after-change-function (start stop _len)
1263 "Start syntax check for current buffer if it isn't already running."
1264 ;;+(flymake-log 0 "setting change time to %s" (float-time))
1265 (let((new-text (buffer-substring start stop)))
1266 (when (and flymake-start-syntax-check-on-newline (equal new-text "\n"))
1267 (flymake-log 3 "starting syntax check as new-line has been seen")
1268 (flymake-start-syntax-check))
1269 (setq flymake-last-change-time (float-time))))
1270
1271 (defun flymake-after-save-hook ()
1272 (if (local-variable-p 'flymake-mode (current-buffer)) ; (???) other way to determine whether flymake is active in buffer being saved?
1273 (progn
1274 (flymake-log 3 "starting syntax check as buffer was saved")
1275 (flymake-start-syntax-check)))) ; no more mode 3. cannot start check if mode 3 (to temp copies) is active - (???)
1276
1277 (defun flymake-kill-buffer-hook ()
1278 (when flymake-timer
1279 (cancel-timer flymake-timer)
1280 (setq flymake-timer nil)))
1281
1282 ;;;###autoload
1283 (defun flymake-find-file-hook ()
1284 ;;+(when flymake-start-syntax-check-on-find-file
1285 ;;+ (flymake-log 3 "starting syntax check on file open")
1286 ;;+ (flymake-start-syntax-check)
1287 ;;+)
1288 (when (and (not (local-variable-p 'flymake-mode (current-buffer)))
1289 (flymake-can-syntax-check-file buffer-file-name))
1290 (flymake-mode)
1291 (flymake-log 3 "automatically turned ON flymake mode")))
1292
1293 (defun flymake-get-first-err-line-no (err-info-list)
1294 "Return first line with error."
1295 (when err-info-list
1296 (flymake-er-get-line (car err-info-list))))
1297
1298 (defun flymake-get-last-err-line-no (err-info-list)
1299 "Return last line with error."
1300 (when err-info-list
1301 (flymake-er-get-line (nth (1- (length err-info-list)) err-info-list))))
1302
1303 (defun flymake-get-next-err-line-no (err-info-list line-no)
1304 "Return next line with error."
1305 (when err-info-list
1306 (let* ((count (length err-info-list))
1307 (idx 0))
1308 (while (and (< idx count) (>= line-no (flymake-er-get-line (nth idx err-info-list))))
1309 (setq idx (1+ idx)))
1310 (if (< idx count)
1311 (flymake-er-get-line (nth idx err-info-list))))))
1312
1313 (defun flymake-get-prev-err-line-no (err-info-list line-no)
1314 "Return previous line with error."
1315 (when err-info-list
1316 (let* ((count (length err-info-list)))
1317 (while (and (> count 0) (<= line-no (flymake-er-get-line (nth (1- count) err-info-list))))
1318 (setq count (1- count)))
1319 (if (> count 0)
1320 (flymake-er-get-line (nth (1- count) err-info-list))))))
1321
1322 (defun flymake-skip-whitespace ()
1323 "Move forward until non-whitespace is reached."
1324 (while (looking-at "[ \t]")
1325 (forward-char)))
1326
1327 (defun flymake-goto-line (line-no)
1328 "Go to line LINE-NO, then skip whitespace."
1329 (goto-char (point-min))
1330 (forward-line (1- line-no))
1331 (flymake-skip-whitespace))
1332
1333 (defun flymake-goto-next-error ()
1334 "Go to next error in err ring."
1335 (interactive)
1336 (let ((line-no (flymake-get-next-err-line-no flymake-err-info (line-number-at-pos))))
1337 (when (not line-no)
1338 (setq line-no (flymake-get-first-err-line-no flymake-err-info))
1339 (flymake-log 1 "passed end of file"))
1340 (if line-no
1341 (flymake-goto-line line-no)
1342 (flymake-log 1 "no errors in current buffer"))))
1343
1344 (defun flymake-goto-prev-error ()
1345 "Go to previous error in err ring."
1346 (interactive)
1347 (let ((line-no (flymake-get-prev-err-line-no flymake-err-info (line-number-at-pos))))
1348 (when (not line-no)
1349 (setq line-no (flymake-get-last-err-line-no flymake-err-info))
1350 (flymake-log 1 "passed beginning of file"))
1351 (if line-no
1352 (flymake-goto-line line-no)
1353 (flymake-log 1 "no errors in current buffer"))))
1354
1355 (defun flymake-patch-err-text (string)
1356 (if (string-match "^[\n\t :0-9]*\\(.*\\)$" string)
1357 (match-string 1 string)
1358 string))
1359
1360 ;;;; general init-cleanup and helper routines
1361 (defun flymake-create-temp-inplace (file-name prefix)
1362 (unless (stringp file-name)
1363 (error "Invalid file-name"))
1364 (or prefix
1365 (setq prefix "flymake"))
1366 (let* ((ext (file-name-extension file-name))
1367 (temp-name (file-truename
1368 (concat (file-name-sans-extension file-name)
1369 "_" prefix
1370 (and ext (concat "." ext))))))
1371 (flymake-log 3 "create-temp-inplace: file=%s temp=%s" file-name temp-name)
1372 temp-name))
1373
1374 (defun flymake-create-temp-with-folder-structure (file-name _prefix)
1375 (unless (stringp file-name)
1376 (error "Invalid file-name"))
1377
1378 (let* ((dir (file-name-directory file-name))
1379 ;; Not sure what this slash-pos is all about, but I guess it's just
1380 ;; trying to remove the leading / of absolute file names.
1381 (slash-pos (string-match "/" dir))
1382 (temp-dir (expand-file-name (substring dir (1+ slash-pos))
1383 temporary-file-directory)))
1384
1385 (file-truename (expand-file-name (file-name-nondirectory file-name)
1386 temp-dir))))
1387
1388 (defun flymake-delete-temp-directory (dir-name)
1389 "Attempt to delete temp dir created by `flymake-create-temp-with-folder-structure', do not fail on error."
1390 (let* ((temp-dir temporary-file-directory)
1391 (suffix (substring dir-name (1+ (length temp-dir)))))
1392
1393 (while (> (length suffix) 0)
1394 (setq suffix (directory-file-name suffix))
1395 ;;+(flymake-log 0 "suffix=%s" suffix)
1396 (flymake-safe-delete-directory
1397 (file-truename (expand-file-name suffix temp-dir)))
1398 (setq suffix (file-name-directory suffix)))))
1399
1400 (defvar-local flymake-temp-source-file-name nil)
1401 (defvar-local flymake-master-file-name nil)
1402 (defvar-local flymake-temp-master-file-name nil)
1403 (defvar-local flymake-base-dir nil)
1404
1405 (defun flymake-init-create-temp-buffer-copy (create-temp-f)
1406 "Make a temporary copy of the current buffer, save its name in buffer data and return the name."
1407 (let* ((source-file-name buffer-file-name)
1408 (temp-source-file-name (funcall create-temp-f source-file-name "flymake")))
1409
1410 (flymake-save-buffer-in-file temp-source-file-name)
1411 (setq flymake-temp-source-file-name temp-source-file-name)
1412 temp-source-file-name))
1413
1414 (defun flymake-simple-cleanup ()
1415 "Do cleanup after `flymake-init-create-temp-buffer-copy'.
1416 Delete temp file."
1417 (flymake-safe-delete-file flymake-temp-source-file-name)
1418 (setq flymake-last-change-time nil))
1419
1420 (defun flymake-get-real-file-name (file-name-from-err-msg)
1421 "Translate file name from error message to \"real\" file name.
1422 Return full-name. Names are real, not patched."
1423 (let* ((real-name nil)
1424 (source-file-name buffer-file-name)
1425 (master-file-name flymake-master-file-name)
1426 (temp-source-file-name flymake-temp-source-file-name)
1427 (temp-master-file-name flymake-temp-master-file-name)
1428 (base-dirs
1429 (list flymake-base-dir
1430 (file-name-directory source-file-name)
1431 (if master-file-name (file-name-directory master-file-name))))
1432 (files (list (list source-file-name source-file-name)
1433 (list temp-source-file-name source-file-name)
1434 (list master-file-name master-file-name)
1435 (list temp-master-file-name master-file-name))))
1436
1437 (when (equal 0 (length file-name-from-err-msg))
1438 (setq file-name-from-err-msg source-file-name))
1439
1440 (setq real-name (flymake-get-full-patched-file-name file-name-from-err-msg base-dirs files))
1441 ;; if real-name is nil, than file name from err msg is none of the files we've patched
1442 (if (not real-name)
1443 (setq real-name (flymake-get-full-nonpatched-file-name file-name-from-err-msg base-dirs)))
1444 (if (not real-name)
1445 (setq real-name file-name-from-err-msg))
1446 (setq real-name (flymake-fix-file-name real-name))
1447 (flymake-log 3 "get-real-file-name: file-name=%s real-name=%s" file-name-from-err-msg real-name)
1448 real-name))
1449
1450 (defun flymake-get-full-patched-file-name (file-name-from-err-msg base-dirs files)
1451 (let* ((base-dirs-count (length base-dirs))
1452 (file-count (length files))
1453 (real-name nil))
1454
1455 (while (and (not real-name) (> base-dirs-count 0))
1456 (setq file-count (length files))
1457 (while (and (not real-name) (> file-count 0))
1458 (let* ((this-dir (nth (1- base-dirs-count) base-dirs))
1459 (this-file (nth 0 (nth (1- file-count) files)))
1460 (this-real-name (nth 1 (nth (1- file-count) files))))
1461 ;;+(flymake-log 0 "this-dir=%s this-file=%s this-real=%s msg-file=%s" this-dir this-file this-real-name file-name-from-err-msg)
1462 (when (and this-dir this-file (flymake-same-files
1463 (expand-file-name file-name-from-err-msg this-dir)
1464 this-file))
1465 (setq real-name this-real-name)))
1466 (setq file-count (1- file-count)))
1467 (setq base-dirs-count (1- base-dirs-count)))
1468 real-name))
1469
1470 (defun flymake-get-full-nonpatched-file-name (file-name-from-err-msg base-dirs)
1471 (let* ((real-name nil))
1472 (if (file-name-absolute-p file-name-from-err-msg)
1473 (setq real-name file-name-from-err-msg)
1474 (let* ((base-dirs-count (length base-dirs)))
1475 (while (and (not real-name) (> base-dirs-count 0))
1476 (let* ((full-name (expand-file-name file-name-from-err-msg
1477 (nth (1- base-dirs-count) base-dirs))))
1478 (if (file-exists-p full-name)
1479 (setq real-name full-name))
1480 (setq base-dirs-count (1- base-dirs-count))))))
1481 real-name))
1482
1483 (defun flymake-init-find-buildfile-dir (source-file-name buildfile-name)
1484 "Find buildfile, store its dir in buffer data and return its dir, if found."
1485 (let* ((buildfile-dir
1486 (flymake-find-buildfile buildfile-name
1487 (file-name-directory source-file-name))))
1488 (if buildfile-dir
1489 (setq flymake-base-dir buildfile-dir)
1490 (flymake-log 1 "no buildfile (%s) for %s" buildfile-name source-file-name)
1491 (flymake-report-fatal-status
1492 "NOMK" (format "No buildfile (%s) found for %s"
1493 buildfile-name source-file-name)))))
1494
1495 (defun flymake-init-create-temp-source-and-master-buffer-copy (get-incl-dirs-f create-temp-f master-file-masks include-regexp)
1496 "Find master file (or buffer), create its copy along with a copy of the source file."
1497 (let* ((source-file-name buffer-file-name)
1498 (temp-source-file-name (flymake-init-create-temp-buffer-copy create-temp-f))
1499 (master-and-temp-master (flymake-create-master-file
1500 source-file-name temp-source-file-name
1501 get-incl-dirs-f create-temp-f
1502 master-file-masks include-regexp)))
1503
1504 (if (not master-and-temp-master)
1505 (progn
1506 (flymake-log 1 "cannot find master file for %s" source-file-name)
1507 (flymake-report-status "!" "") ; NOMASTER
1508 nil)
1509 (setq flymake-master-file-name (nth 0 master-and-temp-master))
1510 (setq flymake-temp-master-file-name (nth 1 master-and-temp-master)))))
1511
1512 (defun flymake-master-cleanup ()
1513 (flymake-simple-cleanup)
1514 (flymake-safe-delete-file flymake-temp-master-file-name))
1515
1516 ;;;; make-specific init-cleanup routines
1517 (defun flymake-get-syntax-check-program-args (source-file-name base-dir use-relative-base-dir use-relative-source get-cmd-line-f)
1518 "Create a command line for syntax check using GET-CMD-LINE-F."
1519 (funcall get-cmd-line-f
1520 (if use-relative-source
1521 (file-relative-name source-file-name base-dir)
1522 source-file-name)
1523 (if use-relative-base-dir
1524 (file-relative-name base-dir
1525 (file-name-directory source-file-name))
1526 base-dir)))
1527
1528 (defun flymake-get-make-cmdline (source base-dir)
1529 (list "make"
1530 (list "-s"
1531 "-C"
1532 base-dir
1533 (concat "CHK_SOURCES=" source)
1534 "SYNTAX_CHECK_MODE=1"
1535 "check-syntax")))
1536
1537 (defun flymake-get-ant-cmdline (source base-dir)
1538 (list "ant"
1539 (list "-buildfile"
1540 (concat base-dir "/" "build.xml")
1541 (concat "-DCHK_SOURCES=" source)
1542 "check-syntax")))
1543
1544 (defun flymake-simple-make-init-impl (create-temp-f use-relative-base-dir use-relative-source build-file-name get-cmdline-f)
1545 "Create syntax check command line for a directly checked source file.
1546 Use CREATE-TEMP-F for creating temp copy."
1547 (let* ((args nil)
1548 (source-file-name buffer-file-name)
1549 (buildfile-dir (flymake-init-find-buildfile-dir source-file-name build-file-name)))
1550 (if buildfile-dir
1551 (let* ((temp-source-file-name (flymake-init-create-temp-buffer-copy create-temp-f)))
1552 (setq args (flymake-get-syntax-check-program-args temp-source-file-name buildfile-dir
1553 use-relative-base-dir use-relative-source
1554 get-cmdline-f))))
1555 args))
1556
1557 (defun flymake-simple-make-init ()
1558 (flymake-simple-make-init-impl 'flymake-create-temp-inplace t t "Makefile" 'flymake-get-make-cmdline))
1559
1560 (defun flymake-master-make-init (get-incl-dirs-f master-file-masks include-regexp)
1561 "Create make command line for a source file checked via master file compilation."
1562 (let* ((make-args nil)
1563 (temp-master-file-name (flymake-init-create-temp-source-and-master-buffer-copy
1564 get-incl-dirs-f 'flymake-create-temp-inplace
1565 master-file-masks include-regexp)))
1566 (when temp-master-file-name
1567 (let* ((buildfile-dir (flymake-init-find-buildfile-dir temp-master-file-name "Makefile")))
1568 (if buildfile-dir
1569 (setq make-args (flymake-get-syntax-check-program-args
1570 temp-master-file-name buildfile-dir nil nil 'flymake-get-make-cmdline)))))
1571 make-args))
1572
1573 (defun flymake-find-make-buildfile (source-dir)
1574 (flymake-find-buildfile "Makefile" source-dir))
1575
1576 ;;;; .h/make specific
1577 (defun flymake-master-make-header-init ()
1578 (flymake-master-make-init
1579 'flymake-get-include-dirs
1580 '("\\.\\(?:c\\(?:pp\\|xx\\|\\+\\+\\)?\\|CC\\)\\'")
1581 "[ \t]*#[ \t]*include[ \t]*\"\\([[:word:]0-9/\\_.]*%s\\)\""))
1582
1583 ;;;; .java/make specific
1584 (defun flymake-simple-make-java-init ()
1585 (flymake-simple-make-init-impl 'flymake-create-temp-with-folder-structure nil nil "Makefile" 'flymake-get-make-cmdline))
1586
1587 (defun flymake-simple-ant-java-init ()
1588 (flymake-simple-make-init-impl 'flymake-create-temp-with-folder-structure nil nil "build.xml" 'flymake-get-ant-cmdline))
1589
1590 (defun flymake-simple-java-cleanup ()
1591 "Cleanup after `flymake-simple-make-java-init' -- delete temp file and dirs."
1592 (flymake-safe-delete-file flymake-temp-source-file-name)
1593 (when flymake-temp-source-file-name
1594 (flymake-delete-temp-directory
1595 (file-name-directory flymake-temp-source-file-name))))
1596
1597 ;;;; perl-specific init-cleanup routines
1598 (defun flymake-perl-init ()
1599 (let* ((temp-file (flymake-init-create-temp-buffer-copy
1600 'flymake-create-temp-inplace))
1601 (local-file (file-relative-name
1602 temp-file
1603 (file-name-directory buffer-file-name))))
1604 (list "perl" (list "-wc " local-file))))
1605
1606 ;;;; php-specific init-cleanup routines
1607 (defun flymake-php-init ()
1608 (let* ((temp-file (flymake-init-create-temp-buffer-copy
1609 'flymake-create-temp-inplace))
1610 (local-file (file-relative-name
1611 temp-file
1612 (file-name-directory buffer-file-name))))
1613 (list "php" (list "-f" local-file "-l"))))
1614
1615 ;;;; tex-specific init-cleanup routines
1616 (defun flymake-get-tex-args (file-name)
1617 ;;(list "latex" (list "-c-style-errors" file-name))
1618 (list "texify" (list "--pdf" "--tex-option=-c-style-errors" file-name)))
1619
1620 (defun flymake-simple-tex-init ()
1621 (flymake-get-tex-args (flymake-init-create-temp-buffer-copy 'flymake-create-temp-inplace)))
1622
1623 ;; Perhaps there should be a buffer-local variable flymake-master-file
1624 ;; that people can set to override this stuff. Could inherit from
1625 ;; the similar AUCTeX variable.
1626 (defun flymake-master-tex-init ()
1627 (let* ((temp-master-file-name (flymake-init-create-temp-source-and-master-buffer-copy
1628 'flymake-get-include-dirs-dot 'flymake-create-temp-inplace
1629 '("\\.tex\\'")
1630 "[ \t]*\\in\\(?:put\\|clude\\)[ \t]*{\\(.*%s\\)}")))
1631 (when temp-master-file-name
1632 (flymake-get-tex-args temp-master-file-name))))
1633
1634 (defun flymake-get-include-dirs-dot (_base-dir)
1635 '("."))
1636
1637 ;;;; xml-specific init-cleanup routines
1638 (defun flymake-xml-init ()
1639 (list flymake-xml-program
1640 (list "val" (flymake-init-create-temp-buffer-copy
1641 'flymake-create-temp-inplace))))
1642
1643 (provide 'flymake)
1644 ;;; flymake.el ends here