aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/progmodes
diff options
context:
space:
mode:
authorKaroly Lorentey2006-01-06 16:13:05 +0000
committerKaroly Lorentey2006-01-06 16:13:05 +0000
commita8bf7299ee74781dd485c33c5eac20aee0f0ebef (patch)
treed2bc1c0d3d7a64a19945b5bb5d175cae37088bca /lisp/progmodes
parente079ecf45241cc5d2904db7ede9592f9861bb9aa (diff)
parent600bc46cd52fbdedf592158c6b03ccfca88dbade (diff)
downloademacs-a8bf7299ee74781dd485c33c5eac20aee0f0ebef.tar.gz
emacs-a8bf7299ee74781dd485c33c5eac20aee0f0ebef.zip
Merged from miles@gnu.org--gnu-2005 (patch 683-684)
Patches applied: * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-683 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-684 Update from CVS git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-493
Diffstat (limited to 'lisp/progmodes')
-rw-r--r--lisp/progmodes/flymake.el586
1 files changed, 268 insertions, 318 deletions
diff --git a/lisp/progmodes/flymake.el b/lisp/progmodes/flymake.el
index 6f5d0855e19..4b14d321a46 100644
--- a/lisp/progmodes/flymake.el
+++ b/lisp/progmodes/flymake.el
@@ -1,6 +1,6 @@
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, 2004, 2005 Free Software Foundation 3;; Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation
4 4
5;; Author: Pavel Kobiakov <pk_at_work@yahoo.com> 5;; Author: Pavel Kobiakov <pk_at_work@yahoo.com>
6;; Maintainer: Pavel Kobiakov <pk_at_work@yahoo.com> 6;; Maintainer: Pavel Kobiakov <pk_at_work@yahoo.com>
@@ -32,16 +32,33 @@
32 32
33;;; Code: 33;;; Code:
34 34
35;;;; [[ Silence the byte-compiler 35(defvar flymake-is-running nil
36 "If t, flymake syntax check process is running for the current buffer.")
37(make-variable-buffer-local 'flymake-is-running)
36 38
37(defvar flymake-check-start-time) 39(defvar flymake-timer nil
38(defvar flymake-check-was-interrupted) 40 "Timer for starting syntax check.")
39(defvar flymake-err-info) 41(make-variable-buffer-local 'flymake-timer)
40(defvar flymake-is-running)
41(defvar flymake-last-change-time)
42(defvar flymake-new-err-info)
43 42
44;;;; ]] 43(defvar flymake-last-change-time nil
44 "Time of last buffer change.")
45(make-variable-buffer-local 'flymake-last-change-time)
46
47(defvar flymake-check-start-time nil
48 "Time at which syntax check was started.")
49(make-variable-buffer-local 'flymake-check-start-time)
50
51(defvar flymake-check-was-interrupted nil
52 "Non-nil if syntax check was killed by `flymake-compile'.")
53(make-variable-buffer-local 'flymake-check-was-interrupted)
54
55(defvar flymake-err-info nil
56 "Sorted list of line numbers and lists of err info in the form (file, err-text).")
57(make-variable-buffer-local 'flymake-err-info)
58
59(defvar flymake-new-err-info nil
60 "Same as `flymake-err-info', effective when a syntax check is in progress.")
61(make-variable-buffer-local 'flymake-new-err-info)
45 62
46;;;; [[ Xemacs overlay compatibility 63;;;; [[ Xemacs overlay compatibility
47(if (featurep 'xemacs) (progn 64(if (featurep 'xemacs) (progn
@@ -69,25 +86,30 @@
69 (multiple-value-bind (s0 s1 s2) (current-time) 86 (multiple-value-bind (s0 s1 s2) (current-time)
70 (+ (* (float (ash 1 16)) s0) (float s1) (* 0.0000001 s2))))))) 87 (+ (* (float (ash 1 16)) s0) (float s1) (* 0.0000001 s2)))))))
71 88
72(defsubst flymake-replace-regexp-in-string (regexp rep str) 89(defalias 'flymake-replace-regexp-in-string
73 (if (fboundp 'replace-in-string) 90 (if (eval-when-compile (fboundp 'replace-regexp-in-string))
74 (replace-in-string str regexp rep) 91 'replace-regexp-in-string
75 (replace-regexp-in-string regexp rep str))) 92 (lambda (regexp rep str)
76 93 (replace-in-string str regexp rep))))
77(defun flymake-split-string (str pattern) 94
78 "Split STR into a list of substrings bounded by PATTERN. 95(defalias 'flymake-split-string
96 (if (condition-case nil (equal (split-string " bc " " " t) '("bc"))
97 (error nil))
98 (lambda (str pattern) (split-string str pattern t))
99 (lambda (str pattern)
100 "Split STR into a list of substrings bounded by PATTERN.
79Zero-length substrings at the beginning and end of the list are omitted." 101Zero-length substrings at the beginning and end of the list are omitted."
80 (let* ((splitted (split-string str pattern))) 102 (let ((split (split-string str pattern)))
81 (if (and (> (length splitted) 0) (= 0 (length (elt splitted 0)))) 103 (if (and (> (length split) 0) (= 0 (length (elt split 0))))
82 (setq splitted (cdr splitted))) 104 (setq split (cdr split)))
83 (if (and (> (length splitted) 0) (= 0 (length (elt splitted (1- (length splitted)))))) 105 (if (and (> (length split) 0) (= 0 (length (elt split (1- (length split))))))
84 (setq splitted (reverse (cdr (reverse splitted))))) 106 (setq split (nreverse (cdr (nreverse split)))))
85 splitted)) 107 split))))
86 108
87(defsubst flymake-get-temp-dir () 109(defalias 'flymake-get-temp-dir
88 (if (fboundp 'temp-directory) 110 (if (fboundp 'temp-directory)
89 (temp-directory) 111 'temp-directory
90 temporary-file-directory)) 112 (lambda () temporary-file-directory)))
91 113
92(defalias 'flymake-line-beginning-position 114(defalias 'flymake-line-beginning-position
93 (if (fboundp 'line-beginning-position) 115 (if (fboundp 'line-beginning-position)
@@ -99,20 +121,26 @@ Zero-length substrings at the beginning and end of the list are omitted."
99 'line-end-position 121 'line-end-position
100 (lambda (&optional arg) (save-excursion (end-of-line arg) (point))))) 122 (lambda (&optional arg) (save-excursion (end-of-line arg) (point)))))
101 123
102(defun flymake-popup-menu (pos menu-data) 124
103 "Pop up the flymake menu at position POS, using the data MENU-DATA. 125(defun flymake-popup-menu (menu-data)
126 "Pop up the flymake menu at point, using the data MENU-DATA.
104POS is a list of the form ((X Y) WINDOW), where X and Y are 127POS is a list of the form ((X Y) WINDOW), where X and Y are
105pixels positions from the top left corner of WINDOW's frame. 128pixels positions from the top left corner of WINDOW's frame.
106MENU-DATA is a list of error and warning messages returned by 129MENU-DATA is a list of error and warning messages returned by
107`flymake-make-err-menu-data'." 130`flymake-make-err-menu-data'."
108 (if (featurep 'xemacs) 131 (if (featurep 'xemacs)
109 (let* ((x-pos (nth 0 (nth 0 pos))) 132 (let* ((pos (flymake-get-point-pixel-pos))
110 (y-pos (nth 1 (nth 0 pos))) 133 (x-pos (nth 0 pos))
134 (y-pos (nth 1 pos))
111 (fake-event-props '(button 1 x 1 y 1))) 135 (fake-event-props '(button 1 x 1 y 1)))
112 (setq fake-event-props (plist-put fake-event-props 'x x-pos)) 136 (setq fake-event-props (plist-put fake-event-props 'x x-pos))
113 (setq fake-event-props (plist-put fake-event-props 'y y-pos)) 137 (setq fake-event-props (plist-put fake-event-props 'y y-pos))
114 (popup-menu (flymake-make-xemacs-menu menu-data) (make-event 'button-press fake-event-props))) 138 (popup-menu (flymake-make-xemacs-menu menu-data)
115 (x-popup-menu pos (flymake-make-emacs-menu menu-data)))) 139 (make-event 'button-press fake-event-props)))
140 (x-popup-menu (if (eval-when-compile (fboundp 'posn-at-point))
141 (posn-at-point)
142 (list (flymake-get-point-pixel-pos) (selected-window)))
143 (flymake-make-emacs-menu menu-data))))
116 144
117(defun flymake-make-emacs-menu (menu-data) 145(defun flymake-make-emacs-menu (menu-data)
118 "Return a menu specifier using MENU-DATA. 146 "Return a menu specifier using MENU-DATA.
@@ -121,10 +149,9 @@ MENU-DATA is a list of error and warning messages returned by
121See `x-popup-menu' for the menu specifier format." 149See `x-popup-menu' for the menu specifier format."
122 (let* ((menu-title (nth 0 menu-data)) 150 (let* ((menu-title (nth 0 menu-data))
123 (menu-items (nth 1 menu-data)) 151 (menu-items (nth 1 menu-data))
124 (menu-commands nil)) 152 (menu-commands (mapcar (lambda (foo)
125 (setq menu-commands (mapcar (lambda (foo) 153 (cons (nth 0 foo) (nth 1 foo)))
126 (cons (nth 0 foo) (nth 1 foo))) 154 menu-items)))
127 menu-items))
128 (list menu-title (cons "" menu-commands)))) 155 (list menu-title (cons "" menu-commands))))
129 156
130(if (featurep 'xemacs) (progn 157(if (featurep 'xemacs) (progn
@@ -141,21 +168,10 @@ See `x-popup-menu' for the menu specifier format."
141 menu-items)) 168 menu-items))
142 (cons menu-title menu-commands))) 169 (cons menu-title menu-commands)))
143 170
144(defun flymake-xemacs-window-edges (&optional window)
145 (let ((edges (window-pixel-edges window))
146 tmp)
147 (setq tmp edges)
148 (setcar tmp (/ (car tmp) (face-width 'default)))
149 (setq tmp (cdr tmp))
150 (setcar tmp (/ (car tmp) (face-height 'default)))
151 (setq tmp (cdr tmp))
152 (setcar tmp (/ (car tmp) (face-width 'default)))
153 (setq tmp (cdr tmp))
154 (setcar tmp (/ (car tmp) (face-height 'default)))
155 edges))
156
157)) ;; xemacs 171)) ;; xemacs
158 172
173(unless (eval-when-compile (fboundp 'posn-at-point))
174
159(defun flymake-current-row () 175(defun flymake-current-row ()
160 "Return current row number in current frame." 176 "Return current row number in current frame."
161 (if (fboundp 'window-edges) 177 (if (fboundp 'window-edges)
@@ -167,6 +183,24 @@ See `x-popup-menu' for the menu specifier format."
167 (selected-frame) 183 (selected-frame)
168 (selected-window))) 184 (selected-window)))
169 185
186(defun flymake-get-point-pixel-pos ()
187 "Return point position in pixels: (x, y)."
188 (let ((mouse-pos (mouse-position))
189 (pixel-pos nil)
190 (ret nil))
191 (if (car (cdr mouse-pos))
192 (progn
193 (set-mouse-position (flymake-selected-frame) (current-column) (flymake-current-row))
194 (setq pixel-pos (mouse-pixel-position))
195 (set-mouse-position (car mouse-pos) (car (cdr mouse-pos)) (cdr (cdr mouse-pos)))
196 (setq ret (list (car (cdr pixel-pos)) (cdr (cdr pixel-pos)))))
197 (progn
198 (setq ret '(0 0))))
199 (flymake-log 3 "mouse pos is %s" ret)
200 ret))
201
202) ;; End of (unless (fboundp 'posn-at-point)
203
170;;;; ]] 204;;;; ]]
171 205
172(defcustom flymake-log-level -1 206(defcustom flymake-log-level -1
@@ -187,7 +221,7 @@ are the string substitutions (see `format')."
187 ;;(with-temp-buffer 221 ;;(with-temp-buffer
188 ;; (insert msg) 222 ;; (insert msg)
189 ;; (insert "\n") 223 ;; (insert "\n")
190 ;; (flymake-save-buffer-in-file (current-buffer) "d:/flymake.log" t) ; make log file name customizable 224 ;; (flymake-save-buffer-in-file "d:/flymake.log" t) ; make log file name customizable
191 ;;) 225 ;;)
192 ))) 226 )))
193 227
@@ -203,59 +237,34 @@ are the string substitutions (see `format')."
203 (setcar (nthcdr pos tmp) val) 237 (setcar (nthcdr pos tmp) val)
204 tmp)) 238 tmp))
205 239
206(defvar flymake-pid-to-names (flymake-makehash) 240(defvar flymake-processes nil
207 "Hash table mapping PIDs to source buffer names and output files.") 241 "List of currently active flymake processes.")
208
209(defun flymake-reg-names (pid source-buffer-name)
210 "Associate PID with SOURCE-BUFFER-NAME in `flymake-pid-to-names'."
211 (unless (stringp source-buffer-name)
212 (error "Invalid buffer name"))
213 (puthash pid (list source-buffer-name) flymake-pid-to-names))
214
215(defun flymake-get-source-buffer-name (pid)
216 "Return buffer name associated with PID in `flymake-pid-to-names'."
217 (nth 0 (gethash pid flymake-pid-to-names)))
218
219(defun flymake-unreg-names (pid)
220 "Remove the entry associated with PID from `flymake-pid-to-names'."
221 (remhash pid flymake-pid-to-names))
222
223(defvar flymake-buffer-data (flymake-makehash)
224 "Data specific to syntax check tool, in name-value pairs.")
225
226(make-variable-buffer-local 'flymake-buffer-data)
227
228(defun flymake-get-buffer-value (buffer name)
229 (gethash name (with-current-buffer buffer flymake-buffer-data)))
230
231(defun flymake-set-buffer-value (buffer name value)
232 (puthash name value (with-current-buffer buffer flymake-buffer-data)))
233 242
234(defvar flymake-output-residual nil) 243(defvar flymake-output-residual nil)
235 244
236(make-variable-buffer-local 'flymake-output-residual) 245(make-variable-buffer-local 'flymake-output-residual)
237 246
238(defcustom flymake-allowed-file-name-masks 247(defcustom flymake-allowed-file-name-masks
239 '((".+\\.c$" flymake-simple-make-init flymake-simple-cleanup flymake-get-real-file-name) 248 '(("\\.c\\'" flymake-simple-make-init)
240 (".+\\.cpp$" flymake-simple-make-init flymake-simple-cleanup flymake-get-real-file-name) 249 ("\\.cpp\\'" flymake-simple-make-init)
241 (".+\\.xml$" flymake-xml-init flymake-simple-cleanup flymake-get-real-file-name) 250 ("\\.xml\\'" flymake-xml-init)
242 (".+\\.html?$" flymake-xml-init flymake-simple-cleanup flymake-get-real-file-name) 251 ("\\.html?\\'" flymake-xml-init)
243 (".+\\.cs$" flymake-simple-make-init flymake-simple-cleanup flymake-get-real-file-name) 252 ("\\.cs\\'" flymake-simple-make-init)
244 (".+\\.pl$" flymake-perl-init flymake-simple-cleanup flymake-get-real-file-name) 253 ("\\.pl\\'" flymake-perl-init)
245 (".+\\.h$" flymake-master-make-header-init flymake-master-cleanup flymake-get-real-file-name) 254 ("\\.h\\'" flymake-master-make-header-init flymake-master-cleanup)
246 (".+\\.java$" flymake-simple-make-java-init flymake-simple-java-cleanup flymake-get-real-file-name) 255 ("\\.java\\'" flymake-simple-make-java-init flymake-simple-java-cleanup)
247 (".+[0-9]+\\.tex$" flymake-master-tex-init flymake-master-cleanup flymake-get-real-file-name) 256 ("[0-9]+\\.tex\\'" flymake-master-tex-init flymake-master-cleanup)
248 (".+\\.tex$" flymake-simple-tex-init flymake-simple-cleanup flymake-get-real-file-name) 257 ("\\.tex\\'" flymake-simple-tex-init)
249 (".+\\.idl$" flymake-simple-make-init flymake-simple-cleanup flymake-get-real-file-name) 258 ("\\.idl\\'" flymake-simple-make-init)
250 ;; (".+\\.cpp$" 1) 259 ;; ("\\.cpp\\'" 1)
251 ;; (".+\\.java$" 3) 260 ;; ("\\.java\\'" 3)
252 ;; (".+\\.h$" 2 (".+\\.cpp$" ".+\\.c$") 261 ;; ("\\.h\\'" 2 ("\\.cpp\\'" "\\.c\\'")
253 ;; ("[ \t]*#[ \t]*include[ \t]*\"\\([\w0-9/\\_\.]*[/\\]*\\)\\(%s\\)\"" 1 2)) 262 ;; ("[ \t]*#[ \t]*include[ \t]*\"\\([\w0-9/\\_\.]*[/\\]*\\)\\(%s\\)\"" 1 2))
254 ;; (".+\\.idl$" 1) 263 ;; ("\\.idl\\'" 1)
255 ;; (".+\\.odl$" 1) 264 ;; ("\\.odl\\'" 1)
256 ;; (".+[0-9]+\\.tex$" 2 (".+\\.tex$") 265 ;; ("[0-9]+\\.tex\\'" 2 ("\\.tex\\'")
257 ;; ("[ \t]*\\input[ \t]*{\\(.*\\)\\(%s\\)}" 1 2 )) 266 ;; ("[ \t]*\\input[ \t]*{\\(.*\\)\\(%s\\)}" 1 2 ))
258 ;; (".+\\.tex$" 1) 267 ;; ("\\.tex\\'" 1)
259 ) 268 )
260 "*Files syntax checking is allowed for." 269 "*Files syntax checking is allowed for."
261 :group 'flymake 270 :group 'flymake
@@ -288,10 +297,12 @@ Return nil if we cannot, non-nil if we can."
288 297
289(defun flymake-get-cleanup-function (file-name) 298(defun flymake-get-cleanup-function (file-name)
290 "Return cleanup function to be used for the file." 299 "Return cleanup function to be used for the file."
291 (nth 1 (flymake-get-file-name-mode-and-masks file-name))) 300 (or (nth 1 (flymake-get-file-name-mode-and-masks file-name))
301 'flymake-simple-cleanup))
292 302
293(defun flymake-get-real-file-name-function (file-name) 303(defun flymake-get-real-file-name-function (file-name)
294 (or (nth 2 (flymake-get-file-name-mode-and-masks file-name)) 'flymake-get-real-file-name)) 304 (or (nth 2 (flymake-get-file-name-mode-and-masks file-name))
305 'flymake-get-real-file-name))
295 306
296(defcustom flymake-buildfile-dirs '("." ".." "../.." "../../.." "../../../.." "../../../../.." "../../../../../.." "../../../../../../.." "../../../../../../../.." "../../../../../../../../.." "../../../../../../../../../.." "../../../../../../../../../../..") 307(defcustom flymake-buildfile-dirs '("." ".." "../.." "../../.." "../../../.." "../../../../.." "../../../../../.." "../../../../../../.." "../../../../../../../.." "../../../../../../../../.." "../../../../../../../../../.." "../../../../../../../../../../..")
297 "Dirs to look for buildfile." 308 "Dirs to look for buildfile."
@@ -491,7 +502,7 @@ instead of reading master file from disk."
491 (file-name-nondirectory patched-source-file-name)))) 502 (file-name-nondirectory patched-source-file-name))))
492 (forward-line 1))) 503 (forward-line 1)))
493 (when found 504 (when found
494 (flymake-save-buffer-in-file (current-buffer) patched-master-file-name))) 505 (flymake-save-buffer-in-file patched-master-file-name)))
495 ;;+(flymake-log 3 "killing buffer %s" (buffer-name master-file-temp-buffer)) 506 ;;+(flymake-log 3 "killing buffer %s" (buffer-name master-file-temp-buffer))
496 (kill-buffer master-file-temp-buffer))) 507 (kill-buffer master-file-temp-buffer)))
497 ;;+(flymake-log 3 "check-patch master file %s: %s" master-file-name found) 508 ;;+(flymake-log 3 "check-patch master file %s: %s" master-file-name found)
@@ -581,15 +592,12 @@ Find master file, patch and save it."
581 (file-name-nondirectory source-file-name)) 592 (file-name-nondirectory source-file-name))
582 nil)))) 593 nil))))
583 594
584(defun flymake-save-buffer-in-file (buffer file-name) 595(defun flymake-save-buffer-in-file (file-name)
585 (or buffer 596 (save-restriction
586 (error "Invalid buffer")) 597 (widen)
587 (with-current-buffer buffer 598 (make-directory (file-name-directory file-name) 1)
588 (save-restriction 599 (write-region (point-min) (point-max) file-name nil 566))
589 (widen) 600 (flymake-log 3 "saved buffer %s in file %s" (buffer-name) file-name))
590 (make-directory (file-name-directory file-name) 1)
591 (write-region (point-min) (point-max) file-name nil 566)))
592 (flymake-log 3 "saved buffer %s in file %s" (buffer-name buffer) file-name))
593 601
594(defun flymake-save-string-to-file (file-name data) 602(defun flymake-save-string-to-file (file-name data)
595 "Save string DATA to file FILE-NAME." 603 "Save string DATA to file FILE-NAME."
@@ -604,44 +612,46 @@ Find master file, patch and save it."
604(defun flymake-process-filter (process output) 612(defun flymake-process-filter (process output)
605 "Parse OUTPUT and highlight error lines. 613 "Parse OUTPUT and highlight error lines.
606It's flymake process filter." 614It's flymake process filter."
607 (let* ((pid (process-id process)) 615 (let ((source-buffer (process-buffer process)))
608 (source-buffer (get-buffer (flymake-get-source-buffer-name pid))))
609 616
610 (flymake-log 3 "received %d byte(s) of output from process %d" (length output) pid) 617 (flymake-log 3 "received %d byte(s) of output from process %d"
618 (length output) (process-id process))
611 (when source-buffer 619 (when source-buffer
612 (with-current-buffer source-buffer 620 (with-current-buffer source-buffer
613 (flymake-parse-output-and-residual output))))) 621 (flymake-parse-output-and-residual output)))))
614 622
615(defun flymake-process-sentinel (process event) 623(defun flymake-process-sentinel (process event)
616 "Sentinel for syntax check buffers." 624 "Sentinel for syntax check buffers."
617 (if (memq (process-status process) '(signal exit)) 625 (when (memq (process-status process) '(signal exit))
618 (let*((exit-status (process-exit-status process)) 626 (let* ((exit-status (process-exit-status process))
619 (command (process-command process)) 627 (command (process-command process))
620 (pid (process-id process)) 628 (source-buffer (process-buffer process))
621 (source-buffer (get-buffer (flymake-get-source-buffer-name pid))) 629 (cleanup-f (flymake-get-cleanup-function (buffer-file-name source-buffer))))
622 (cleanup-f (flymake-get-cleanup-function (buffer-file-name source-buffer)))) 630
623 631 (flymake-log 2 "process %d exited with code %d"
624 (flymake-log 2 "process %d exited with code %d" pid exit-status) 632 (process-id process) exit-status)
625 (condition-case err 633 (condition-case err
626 (progn 634 (progn
627 (flymake-log 3 "cleaning up using %s" cleanup-f) 635 (flymake-log 3 "cleaning up using %s" cleanup-f)
628 (funcall cleanup-f source-buffer) 636 (when (buffer-live-p source-buffer)
629 637 (with-current-buffer source-buffer
630 (flymake-unreg-names pid) 638 (funcall cleanup-f)))
631 (delete-process process) 639
632 640 (delete-process process)
633 (when source-buffer 641 (setq flymake-processes (delq process flymake-processes))
634 (with-current-buffer source-buffer 642
635 643 (when (buffer-live-p source-buffer)
636 (flymake-parse-residual) 644 (with-current-buffer source-buffer
637 (flymake-post-syntax-check exit-status command) 645
638 (setq flymake-is-running nil)))) 646 (flymake-parse-residual)
639 (error 647 (flymake-post-syntax-check exit-status command)
640 (let ((err-str (format "Error in process sentinel for buffer %s: %s" 648 (setq flymake-is-running nil))))
641 source-buffer (error-message-string err)))) 649 (error
642 (flymake-log 0 err-str) 650 (let ((err-str (format "Error in process sentinel for buffer %s: %s"
643 (with-current-buffer source-buffer 651 source-buffer (error-message-string err))))
644 (setq flymake-is-running nil)))))))) 652 (flymake-log 0 err-str)
653 (with-current-buffer source-buffer
654 (setq flymake-is-running nil))))))))
645 655
646(defun flymake-post-syntax-check (exit-status command) 656(defun flymake-post-syntax-check (exit-status command)
647 (setq flymake-err-info flymake-new-err-info) 657 (setq flymake-err-info flymake-new-err-info)
@@ -689,11 +699,6 @@ It's flymake process filter."
689 (list flymake-output-residual))) 699 (list flymake-output-residual)))
690 (setq flymake-output-residual nil))) 700 (setq flymake-output-residual nil)))
691 701
692(defvar flymake-err-info nil
693 "Sorted list of line numbers and lists of err info in the form (file, err-text).")
694
695(make-variable-buffer-local 'flymake-err-info)
696
697(defun flymake-er-make-er (line-no line-err-info-list) 702(defun flymake-er-make-er (line-no line-err-info-list)
698 (list line-no line-err-info-list)) 703 (list line-no line-err-info-list))
699 704
@@ -703,11 +708,6 @@ It's flymake process filter."
703(defun flymake-er-get-line-err-info-list (err-info) 708(defun flymake-er-get-line-err-info-list (err-info)
704 (nth 1 err-info)) 709 (nth 1 err-info))
705 710
706(defvar flymake-new-err-info nil
707 "Same as `flymake-err-info', effective when a syntax check is in progress.")
708
709(make-variable-buffer-local 'flymake-new-err-info)
710
711;; getters/setters for line-err-info: (file, line, type, text). 711;; getters/setters for line-err-info: (file, line, type, text).
712(defun flymake-ler-make-ler (file line type text &optional full-file) 712(defun flymake-ler-make-ler (file line type text &optional full-file)
713 (list file line type text full-file)) 713 (list file line type text full-file))
@@ -897,7 +897,8 @@ Perhaps use text from LINE-ERR-INFO-LIST to enhance highlighting."
897 (while (< idx count) 897 (while (< idx count)
898 (setq line-err-info (flymake-parse-line (nth idx lines))) 898 (setq line-err-info (flymake-parse-line (nth idx lines)))
899 (when line-err-info 899 (when line-err-info
900 (setq real-file-name (funcall get-real-file-name-f (current-buffer) (flymake-ler-get-file line-err-info))) 900 (setq real-file-name (funcall get-real-file-name-f
901 (flymake-ler-get-file line-err-info)))
901 (setq line-err-info (flymake-ler-set-full-file line-err-info real-file-name)) 902 (setq line-err-info (flymake-ler-set-full-file line-err-info real-file-name))
902 903
903 (if (flymake-same-files real-file-name source-file-name) 904 (if (flymake-same-files real-file-name source-file-name)
@@ -1131,12 +1132,12 @@ For the format of LINE-ERR-INFO, see `flymake-ler-make-ler'."
1131;; "Remove any formatting made by flymake." 1132;; "Remove any formatting made by flymake."
1132;; ) 1133;; )
1133 1134
1134(defun flymake-get-program-dir (buffer) 1135;; (defun flymake-get-program-dir (buffer)
1135 "Get dir to start program in." 1136;; "Get dir to start program in."
1136 (unless (bufferp buffer) 1137;; (unless (bufferp buffer)
1137 (error "Invalid buffer")) 1138;; (error "Invalid buffer"))
1138 (with-current-buffer buffer 1139;; (with-current-buffer buffer
1139 default-directory)) 1140;; default-directory))
1140 1141
1141(defun flymake-safe-delete-file (file-name) 1142(defun flymake-safe-delete-file (file-name)
1142 (when (and file-name (file-exists-p file-name)) 1143 (when (and file-name (file-exists-p file-name))
@@ -1168,19 +1169,18 @@ For the format of LINE-ERR-INFO, see `flymake-ler-make-ler'."
1168 (flymake-clear-project-include-dirs-cache) 1169 (flymake-clear-project-include-dirs-cache)
1169 1170
1170 (setq flymake-check-was-interrupted nil) 1171 (setq flymake-check-was-interrupted nil)
1171 (setq flymake-buffer-data (flymake-makehash 'equal))
1172 1172
1173 (let* ((source-file-name buffer-file-name) 1173 (let* ((source-file-name buffer-file-name)
1174 (init-f (flymake-get-init-function source-file-name)) 1174 (init-f (flymake-get-init-function source-file-name))
1175 (cleanup-f (flymake-get-cleanup-function source-file-name)) 1175 (cleanup-f (flymake-get-cleanup-function source-file-name))
1176 (cmd-and-args (funcall init-f (current-buffer))) 1176 (cmd-and-args (funcall init-f))
1177 (cmd (nth 0 cmd-and-args)) 1177 (cmd (nth 0 cmd-and-args))
1178 (args (nth 1 cmd-and-args)) 1178 (args (nth 1 cmd-and-args))
1179 (dir (nth 2 cmd-and-args))) 1179 (dir (nth 2 cmd-and-args)))
1180 (if (not cmd-and-args) 1180 (if (not cmd-and-args)
1181 (progn 1181 (progn
1182 (flymake-log 0 "init function %s for %s failed, cleaning up" init-f source-file-name) 1182 (flymake-log 0 "init function %s for %s failed, cleaning up" init-f source-file-name)
1183 (funcall cleanup-f (current-buffer))) 1183 (funcall cleanup-f))
1184 (progn 1184 (progn
1185 (setq flymake-last-change-time nil) 1185 (setq flymake-last-change-time nil)
1186 (flymake-start-syntax-check-process cmd args dir))))))) 1186 (flymake-start-syntax-check-process cmd args dir)))))))
@@ -1193,11 +1193,10 @@ For the format of LINE-ERR-INFO, see `flymake-ler-make-ler'."
1193 (when dir 1193 (when dir
1194 (let ((default-directory dir)) 1194 (let ((default-directory dir))
1195 (flymake-log 3 "starting process on dir %s" default-directory))) 1195 (flymake-log 3 "starting process on dir %s" default-directory)))
1196 (setq process (get-process (apply 'start-process "flymake-proc" nil cmd args))) 1196 (setq process (apply 'start-process "flymake-proc" (current-buffer) cmd args))
1197 (set-process-sentinel process 'flymake-process-sentinel) 1197 (set-process-sentinel process 'flymake-process-sentinel)
1198 (set-process-filter process 'flymake-process-filter) 1198 (set-process-filter process 'flymake-process-filter)
1199 1199 (push process flymake-processes)
1200 (flymake-reg-names (process-id process) (buffer-name))
1201 1200
1202 (setq flymake-is-running t) 1201 (setq flymake-is-running t)
1203 (setq flymake-last-change-time nil) 1202 (setq flymake-last-change-time nil)
@@ -1205,7 +1204,8 @@ For the format of LINE-ERR-INFO, see `flymake-ler-make-ler'."
1205 1204
1206 (flymake-report-status nil "*") 1205 (flymake-report-status nil "*")
1207 (flymake-log 2 "started process %d, command=%s, dir=%s" 1206 (flymake-log 2 "started process %d, command=%s, dir=%s"
1208 (process-id process) (process-command process) default-directory) 1207 (process-id process) (process-command process)
1208 default-directory)
1209 process) 1209 process)
1210 (error 1210 (error
1211 (let* ((err-str (format "Failed to launch syntax check process '%s' with args %s: %s" 1211 (let* ((err-str (format "Failed to launch syntax check process '%s' with args %s: %s"
@@ -1213,23 +1213,23 @@ For the format of LINE-ERR-INFO, see `flymake-ler-make-ler'."
1213 (source-file-name buffer-file-name) 1213 (source-file-name buffer-file-name)
1214 (cleanup-f (flymake-get-cleanup-function source-file-name))) 1214 (cleanup-f (flymake-get-cleanup-function source-file-name)))
1215 (flymake-log 0 err-str) 1215 (flymake-log 0 err-str)
1216 (funcall cleanup-f (current-buffer)) 1216 (funcall cleanup-f)
1217 (flymake-report-fatal-status "PROCERR" err-str)))))) 1217 (flymake-report-fatal-status "PROCERR" err-str))))))
1218 1218
1219(defun flymake-kill-process (pid &optional rest) 1219(defun flymake-kill-process (proc)
1220 "Kill process PID." 1220 "Kill process PROC."
1221 (signal-process pid 9) 1221 (kill-process proc)
1222 (let* ((buffer-name (flymake-get-source-buffer-name pid))) 1222 (let* ((buf (process-buffer proc)))
1223 (when (and buffer-name (get-buffer buffer-name)) 1223 (when (buffer-live-p buf)
1224 (with-current-buffer (get-buffer buffer-name) 1224 (with-current-buffer buf
1225 (setq flymake-check-was-interrupted t)))) 1225 (setq flymake-check-was-interrupted t))))
1226 (flymake-log 1 "killed process %d" pid)) 1226 (flymake-log 1 "killed process %d" (process-id proc)))
1227 1227
1228(defun flymake-stop-all-syntax-checks () 1228(defun flymake-stop-all-syntax-checks ()
1229 "Kill all syntax check processes." 1229 "Kill all syntax check processes."
1230 (interactive) 1230 (interactive)
1231 (let ((pids (copy-hash-table flymake-pid-to-names))) 1231 (while flymake-processes
1232 (maphash 'flymake-kill-process pids))) 1232 (flymake-kill-process (pop flymake-processes))))
1233 1233
1234(defun flymake-compilation-is-running () 1234(defun flymake-compilation-is-running ()
1235 (and (boundp 'compilation-in-progress) 1235 (and (boundp 'compilation-in-progress)
@@ -1241,31 +1241,6 @@ For the format of LINE-ERR-INFO, see `flymake-ler-make-ler'."
1241 (flymake-stop-all-syntax-checks) 1241 (flymake-stop-all-syntax-checks)
1242 (call-interactively 'compile)) 1242 (call-interactively 'compile))
1243 1243
1244(defvar flymake-is-running nil
1245 "If t, flymake syntax check process is running for the current buffer.")
1246
1247(make-variable-buffer-local 'flymake-is-running)
1248
1249(defvar flymake-timer nil
1250 "Timer for starting syntax check.")
1251
1252(make-variable-buffer-local 'flymake-timer)
1253
1254(defvar flymake-last-change-time nil
1255 "Time of last buffer change.")
1256
1257(make-variable-buffer-local 'flymake-last-change-time)
1258
1259(defvar flymake-check-start-time nil
1260 "Time at which syntax check was started.")
1261
1262(make-variable-buffer-local 'flymake-check-start-time)
1263
1264(defvar flymake-check-was-interrupted nil
1265 "Non-nil if syntax check was killed by `flymake-compile'.")
1266
1267(make-variable-buffer-local 'flymake-check-was-interrupted)
1268
1269(defcustom flymake-no-changes-timeout 0.5 1244(defcustom flymake-no-changes-timeout 0.5
1270 "Time to wait after last change before starting compilation." 1245 "Time to wait after last change before starting compilation."
1271 :group 'flymake 1246 :group 'flymake
@@ -1294,33 +1269,16 @@ For the format of LINE-ERR-INFO, see `flymake-ler-make-ler'."
1294 "Return number of lines in buffer BUFFER." 1269 "Return number of lines in buffer BUFFER."
1295 (count-lines (point-min) (point-max))) 1270 (count-lines (point-min) (point-max)))
1296 1271
1297(defun flymake-get-point-pixel-pos ()
1298 "Return point position in pixels: (x, y)."
1299 (let ((mouse-pos (mouse-position))
1300 (pixel-pos nil)
1301 (ret nil))
1302 (if (car (cdr mouse-pos))
1303 (progn
1304 (set-mouse-position (flymake-selected-frame) (current-column) (flymake-current-row))
1305 (setq pixel-pos (mouse-pixel-position))
1306 (set-mouse-position (car mouse-pos) (car (cdr mouse-pos)) (cdr (cdr mouse-pos)))
1307 (setq ret (list (car (cdr pixel-pos)) (cdr (cdr pixel-pos)))))
1308 (progn
1309 (setq ret '(0 0))))
1310 (flymake-log 3 "mouse pos is %s" ret)
1311 ret))
1312
1313(defun flymake-display-err-menu-for-current-line () 1272(defun flymake-display-err-menu-for-current-line ()
1314 "Display a menu with errors/warnings for current line if it has errors and/or warnings." 1273 "Display a menu with errors/warnings for current line if it has errors and/or warnings."
1315 (interactive) 1274 (interactive)
1316 (let* ((line-no (flymake-current-line-no)) 1275 (let* ((line-no (flymake-current-line-no))
1317 (line-err-info-list (nth 0 (flymake-find-err-info flymake-err-info line-no))) 1276 (line-err-info-list (nth 0 (flymake-find-err-info flymake-err-info line-no)))
1318 (menu-data (flymake-make-err-menu-data line-no line-err-info-list)) 1277 (menu-data (flymake-make-err-menu-data line-no line-err-info-list))
1319 (choice nil) 1278 (choice nil))
1320 (menu-pos (list (flymake-get-point-pixel-pos) (selected-window))))
1321 (if menu-data 1279 (if menu-data
1322 (progn 1280 (progn
1323 (setq choice (flymake-popup-menu menu-pos menu-data)) 1281 (setq choice (flymake-popup-menu menu-data))
1324 (flymake-log 3 "choice=%s" choice) 1282 (flymake-log 3 "choice=%s" choice)
1325 (when choice 1283 (when choice
1326 (eval choice))) 1284 (eval choice)))
@@ -1579,20 +1537,14 @@ With arg, turn Flymake mode on if and only if arg is positive."
1579 (error "Invalid file-name")) 1537 (error "Invalid file-name"))
1580 1538
1581 (let* ((dir (file-name-directory file-name)) 1539 (let* ((dir (file-name-directory file-name))
1540 ;; Not sure what this slash-pos is all about, but I guess it's just
1541 ;; trying to remove the leading / of absolute file names.
1582 (slash-pos (string-match "/" dir)) 1542 (slash-pos (string-match "/" dir))
1583 (temp-dir (concat (file-name-as-directory (flymake-get-temp-dir)) (substring dir (1+ slash-pos))))) 1543 (temp-dir (expand-file-name (substring dir (1+ slash-pos))
1544 (flymake-get-temp-dir))))
1584 1545
1585 (file-truename (concat (file-name-as-directory temp-dir) 1546 (file-truename (expand-file-name (file-name-nondirectory file-name)
1586 (file-name-nondirectory file-name))))) 1547 temp-dir))))
1587
1588(defun flymake-strrchr (str ch)
1589 (let* ((count (length str))
1590 (pos nil))
1591 (while (and (not pos) (> count 0))
1592 (if (= ch (elt str (1- count)))
1593 (setq pos (1- count)))
1594 (setq count (1- count)))
1595 pos))
1596 1548
1597(defun flymake-delete-temp-directory (dir-name) 1549(defun flymake-delete-temp-directory (dir-name)
1598 "Attempt to delete temp dir created by `flymake-create-temp-with-folder-structure', do not fail on error." 1550 "Attempt to delete temp dir created by `flymake-create-temp-with-folder-structure', do not fail on error."
@@ -1601,45 +1553,55 @@ With arg, turn Flymake mode on if and only if arg is positive."
1601 (slash-pos nil)) 1553 (slash-pos nil))
1602 1554
1603 (while (> (length suffix) 0) 1555 (while (> (length suffix) 0)
1556 (setq suffix (directory-file-name suffix))
1604 ;;+(flymake-log 0 "suffix=%s" suffix) 1557 ;;+(flymake-log 0 "suffix=%s" suffix)
1605 (flymake-safe-delete-directory (file-truename (concat (file-name-as-directory temp-dir) suffix))) 1558 (flymake-safe-delete-directory
1606 (setq slash-pos (flymake-strrchr suffix (string-to-char "/"))) 1559 (file-truename (expand-file-name suffix temp-dir)))
1607 (if slash-pos 1560 (setq suffix (file-name-directory suffix)))))
1608 (setq suffix (substring suffix 0 slash-pos)) 1561
1609 (setq suffix ""))))) 1562(defvar flymake-temp-source-file-name nil)
1563(make-variable-buffer-local 'flymake-temp-source-file-name)
1564
1565(defvar flymake-master-file-name nil)
1566(make-variable-buffer-local 'flymake-master-file-name)
1567
1568(defvar flymake-temp-master-file-name nil)
1569(make-variable-buffer-local 'flymake-temp-master-file-name)
1610 1570
1611(defun flymake-init-create-temp-buffer-copy (buffer create-temp-f) 1571(defvar flymake-base-dir nil)
1572(make-variable-buffer-local 'flymake-base-dir)
1573
1574(defun flymake-init-create-temp-buffer-copy (create-temp-f)
1612 "Make a temporary copy of the current buffer, save its name in buffer data and return the name." 1575 "Make a temporary copy of the current buffer, save its name in buffer data and return the name."
1613 (let* ((source-file-name (buffer-file-name buffer)) 1576 (let* ((source-file-name buffer-file-name)
1614 (temp-source-file-name (funcall create-temp-f source-file-name "flymake"))) 1577 (temp-source-file-name (funcall create-temp-f source-file-name "flymake")))
1615 1578
1616 (flymake-save-buffer-in-file buffer temp-source-file-name) 1579 (flymake-save-buffer-in-file temp-source-file-name)
1617 (flymake-set-buffer-value buffer "temp-source-file-name" temp-source-file-name) 1580 (setq flymake-temp-source-file-name temp-source-file-name)
1618 temp-source-file-name)) 1581 temp-source-file-name))
1619 1582
1620(defun flymake-simple-cleanup (buffer) 1583(defun flymake-simple-cleanup ()
1621 "Do cleanup after `flymake-init-create-temp-buffer-copy'. 1584 "Do cleanup after `flymake-init-create-temp-buffer-copy'.
1622Delete temp file." 1585Delete temp file."
1623 (let* ((temp-source-file-name (flymake-get-buffer-value buffer "temp-source-file-name"))) 1586 (flymake-safe-delete-file flymake-temp-source-file-name)
1624 (flymake-safe-delete-file temp-source-file-name) 1587 (setq flymake-last-change-time nil))
1625 (with-current-buffer buffer
1626 (setq flymake-last-change-time nil))))
1627 1588
1628(defun flymake-get-real-file-name (buffer file-name-from-err-msg) 1589(defun flymake-get-real-file-name (file-name-from-err-msg)
1629 "Translate file name from error message to \"real\" file name. 1590 "Translate file name from error message to \"real\" file name.
1630Return full-name. Names are real, not patched." 1591Return full-name. Names are real, not patched."
1631 (let* ((real-name nil) 1592 (let* ((real-name nil)
1632 (source-file-name (buffer-file-name buffer)) 1593 (source-file-name buffer-file-name)
1633 (master-file-name (flymake-get-buffer-value buffer "master-file-name")) 1594 (master-file-name flymake-master-file-name)
1634 (temp-source-file-name (flymake-get-buffer-value buffer "temp-source-file-name")) 1595 (temp-source-file-name flymake-temp-source-file-name)
1635 (temp-master-file-name (flymake-get-buffer-value buffer "temp-master-file-name")) 1596 (temp-master-file-name flymake-temp-master-file-name)
1636 (base-dirs (list (flymake-get-buffer-value buffer "base-dir") 1597 (base-dirs
1637 (file-name-directory source-file-name) 1598 (list flymake-base-dir
1638 (if master-file-name (file-name-directory master-file-name) nil))) 1599 (file-name-directory source-file-name)
1639 (files (list (list source-file-name source-file-name) 1600 (if master-file-name (file-name-directory master-file-name))))
1640 (list temp-source-file-name source-file-name) 1601 (files (list (list source-file-name source-file-name)
1641 (list master-file-name master-file-name) 1602 (list temp-source-file-name source-file-name)
1642 (list temp-master-file-name master-file-name)))) 1603 (list master-file-name master-file-name)
1604 (list temp-master-file-name master-file-name))))
1643 1605
1644 (when (equal 0 (length file-name-from-err-msg)) 1606 (when (equal 0 (length file-name-from-err-msg))
1645 (setq file-name-from-err-msg source-file-name)) 1607 (setq file-name-from-err-msg source-file-name))
@@ -1687,27 +1649,23 @@ Return full-name. Names are real, not patched."
1687 (setq base-dirs-count (1- base-dirs-count)))))) 1649 (setq base-dirs-count (1- base-dirs-count))))))
1688 real-name)) 1650 real-name))
1689 1651
1690(defun flymake-init-find-buildfile-dir (buffer source-file-name buildfile-name) 1652(defun flymake-init-find-buildfile-dir (source-file-name buildfile-name)
1691 "Find buildfile, store its dir in buffer data and return its dir, if found." 1653 "Find buildfile, store its dir in buffer data and return its dir, if found."
1692 (let* ((buildfile-dir (flymake-find-buildfile buildfile-name 1654 (let* ((buildfile-dir
1693 (file-name-directory source-file-name) 1655 (flymake-find-buildfile buildfile-name
1694 flymake-buildfile-dirs))) 1656 (file-name-directory source-file-name)
1695 (if (not buildfile-dir) 1657 flymake-buildfile-dirs)))
1696 (progn 1658 (if buildfile-dir
1697 (flymake-log 1 "no buildfile (%s) for %s" buildfile-name source-file-name) 1659 (setq flymake-base-dir buildfile-dir)
1698 (with-current-buffer buffer 1660 (flymake-log 1 "no buildfile (%s) for %s" buildfile-name source-file-name)
1699 (flymake-report-fatal-status "NOMK" (format "No buildfile (%s) found for %s" buildfile-name source-file-name))) 1661 (flymake-report-fatal-status
1700 ) 1662 "NOMK" (format "No buildfile (%s) found for %s"
1701 (progn 1663 buildfile-name source-file-name)))))
1702 (flymake-set-buffer-value buffer "base-dir" buildfile-dir)))
1703 buildfile-dir))
1704 1664
1705(defun flymake-init-create-temp-source-and-master-buffer-copy (buffer get-incl-dirs-f create-temp-f master-file-masks include-regexp-list) 1665(defun flymake-init-create-temp-source-and-master-buffer-copy (get-incl-dirs-f create-temp-f master-file-masks include-regexp-list)
1706 "Find master file (or buffer), create it's copy along with a copy of the source file." 1666 "Find master file (or buffer), create it's copy along with a copy of the source file."
1707 (let* ((source-file-name (buffer-file-name buffer)) 1667 (let* ((source-file-name buffer-file-name)
1708 (temp-source-file-name (flymake-init-create-temp-buffer-copy buffer create-temp-f)) 1668 (temp-source-file-name (flymake-init-create-temp-buffer-copy create-temp-f))
1709 (master-file-name nil)
1710 (temp-master-file-name nil)
1711 (master-and-temp-master (flymake-create-master-file 1669 (master-and-temp-master (flymake-create-master-file
1712 source-file-name temp-source-file-name 1670 source-file-name temp-source-file-name
1713 get-incl-dirs-f create-temp-f 1671 get-incl-dirs-f create-temp-f
@@ -1716,21 +1674,14 @@ Return full-name. Names are real, not patched."
1716 (if (not master-and-temp-master) 1674 (if (not master-and-temp-master)
1717 (progn 1675 (progn
1718 (flymake-log 1 "cannot find master file for %s" source-file-name) 1676 (flymake-log 1 "cannot find master file for %s" source-file-name)
1719 (when (bufferp buffer) 1677 (flymake-report-status "!" "") ; NOMASTER
1720 (with-current-buffer buffer 1678 nil)
1721 (flymake-report-status "!" ""))) ; NOMASTER 1679 (setq flymake-master-file-name (nth 0 master-and-temp-master))
1722 ) 1680 (setq flymake-temp-master-file-name (nth 1 master-and-temp-master)))))
1723 (progn
1724 (setq master-file-name (nth 0 master-and-temp-master))
1725 (setq temp-master-file-name (nth 1 master-and-temp-master))
1726 (flymake-set-buffer-value buffer "master-file-name" master-file-name)
1727 (flymake-set-buffer-value buffer "temp-master-file-name" temp-master-file-name)
1728 ))
1729 temp-master-file-name))
1730 1681
1731(defun flymake-master-cleanup (buffer) 1682(defun flymake-master-cleanup ()
1732 (flymake-simple-cleanup buffer) 1683 (flymake-simple-cleanup)
1733 (flymake-safe-delete-file (flymake-get-buffer-value buffer "temp-master-file-name"))) 1684 (flymake-safe-delete-file flymake-temp-master-file-name))
1734 1685
1735;;;; make-specific init-cleanup routines 1686;;;; make-specific init-cleanup routines
1736(defun flymake-get-syntax-check-program-args (source-file-name base-dir use-relative-base-dir use-relative-source get-cmd-line-f) 1687(defun flymake-get-syntax-check-program-args (source-file-name base-dir use-relative-base-dir use-relative-source get-cmd-line-f)
@@ -1762,30 +1713,30 @@ Return full-name. Names are real, not patched."
1762 (concat "-DCHK_SOURCES=" source) 1713 (concat "-DCHK_SOURCES=" source)
1763 "check-syntax"))) 1714 "check-syntax")))
1764 1715
1765(defun flymake-simple-make-init-impl (buffer create-temp-f use-relative-base-dir use-relative-source build-file-name get-cmdline-f) 1716(defun flymake-simple-make-init-impl (create-temp-f use-relative-base-dir use-relative-source build-file-name get-cmdline-f)
1766 "Create syntax check command line for a directly checked source file. 1717 "Create syntax check command line for a directly checked source file.
1767Use CREATE-TEMP-F for creating temp copy." 1718Use CREATE-TEMP-F for creating temp copy."
1768 (let* ((args nil) 1719 (let* ((args nil)
1769 (source-file-name (buffer-file-name buffer)) 1720 (source-file-name buffer-file-name)
1770 (buildfile-dir (flymake-init-find-buildfile-dir buffer source-file-name build-file-name))) 1721 (buildfile-dir (flymake-init-find-buildfile-dir source-file-name build-file-name)))
1771 (if buildfile-dir 1722 (if buildfile-dir
1772 (let* ((temp-source-file-name (flymake-init-create-temp-buffer-copy buffer create-temp-f))) 1723 (let* ((temp-source-file-name (flymake-init-create-temp-buffer-copy create-temp-f)))
1773 (setq args (flymake-get-syntax-check-program-args temp-source-file-name buildfile-dir 1724 (setq args (flymake-get-syntax-check-program-args temp-source-file-name buildfile-dir
1774 use-relative-base-dir use-relative-source 1725 use-relative-base-dir use-relative-source
1775 get-cmdline-f)))) 1726 get-cmdline-f))))
1776 args)) 1727 args))
1777 1728
1778(defun flymake-simple-make-init (buffer) 1729(defun flymake-simple-make-init ()
1779 (flymake-simple-make-init-impl buffer 'flymake-create-temp-inplace t t "Makefile" 'flymake-get-make-cmdline)) 1730 (flymake-simple-make-init-impl 'flymake-create-temp-inplace t t "Makefile" 'flymake-get-make-cmdline))
1780 1731
1781(defun flymake-master-make-init (buffer get-incl-dirs-f master-file-masks include-regexp-list) 1732(defun flymake-master-make-init (get-incl-dirs-f master-file-masks include-regexp-list)
1782 "Create make command line for a source file checked via master file compilation." 1733 "Create make command line for a source file checked via master file compilation."
1783 (let* ((make-args nil) 1734 (let* ((make-args nil)
1784 (temp-master-file-name (flymake-init-create-temp-source-and-master-buffer-copy 1735 (temp-master-file-name (flymake-init-create-temp-source-and-master-buffer-copy
1785 buffer get-incl-dirs-f 'flymake-create-temp-inplace 1736 get-incl-dirs-f 'flymake-create-temp-inplace
1786 master-file-masks include-regexp-list))) 1737 master-file-masks include-regexp-list)))
1787 (when temp-master-file-name 1738 (when temp-master-file-name
1788 (let* ((buildfile-dir (flymake-init-find-buildfile-dir buffer temp-master-file-name "Makefile"))) 1739 (let* ((buildfile-dir (flymake-init-find-buildfile-dir temp-master-file-name "Makefile")))
1789 (if buildfile-dir 1740 (if buildfile-dir
1790 (setq make-args (flymake-get-syntax-check-program-args 1741 (setq make-args (flymake-get-syntax-check-program-args
1791 temp-master-file-name buildfile-dir nil nil 'flymake-get-make-cmdline))))) 1742 temp-master-file-name buildfile-dir nil nil 'flymake-get-make-cmdline)))))
@@ -1795,30 +1746,29 @@ Use CREATE-TEMP-F for creating temp copy."
1795 (flymake-find-buildfile "Makefile" source-dir flymake-buildfile-dirs)) 1746 (flymake-find-buildfile "Makefile" source-dir flymake-buildfile-dirs))
1796 1747
1797;;;; .h/make specific 1748;;;; .h/make specific
1798(defun flymake-master-make-header-init (buffer) 1749(defun flymake-master-make-header-init ()
1799 (flymake-master-make-init buffer 1750 (flymake-master-make-init 'flymake-get-include-dirs
1800 'flymake-get-include-dirs 1751 '("\\.cpp\\'" "\\.c\\'")
1801 '(".+\\.cpp$" ".+\\.c$")
1802 '("[ \t]*#[ \t]*include[ \t]*\"\\([\w0-9/\\_\.]*[/\\]*\\)\\(%s\\)\"" 1 2))) 1752 '("[ \t]*#[ \t]*include[ \t]*\"\\([\w0-9/\\_\.]*[/\\]*\\)\\(%s\\)\"" 1 2)))
1803 1753
1804;;;; .java/make specific 1754;;;; .java/make specific
1805(defun flymake-simple-make-java-init (buffer) 1755(defun flymake-simple-make-java-init ()
1806 (flymake-simple-make-init-impl buffer 'flymake-create-temp-with-folder-structure nil nil "Makefile" 'flymake-get-make-cmdline)) 1756 (flymake-simple-make-init-impl 'flymake-create-temp-with-folder-structure nil nil "Makefile" 'flymake-get-make-cmdline))
1807 1757
1808(defun flymake-simple-ant-java-init (buffer) 1758(defun flymake-simple-ant-java-init ()
1809 (flymake-simple-make-init-impl buffer 'flymake-create-temp-with-folder-structure nil nil "build.xml" 'flymake-get-ant-cmdline)) 1759 (flymake-simple-make-init-impl 'flymake-create-temp-with-folder-structure nil nil "build.xml" 'flymake-get-ant-cmdline))
1810 1760
1811(defun flymake-simple-java-cleanup (buffer) 1761(defun flymake-simple-java-cleanup ()
1812 "Cleanup after `flymake-simple-make-java-init' -- delete temp file and dirs." 1762 "Cleanup after `flymake-simple-make-java-init' -- delete temp file and dirs."
1813 (let* ((temp-source-file-name (flymake-get-buffer-value buffer "temp-source-file-name"))) 1763 (flymake-safe-delete-file flymake-temp-source-file-name)
1814 (flymake-safe-delete-file temp-source-file-name) 1764 (when flymake-temp-source-file-name
1815 (when temp-source-file-name 1765 (flymake-delete-temp-directory
1816 (flymake-delete-temp-directory (file-name-directory temp-source-file-name))))) 1766 (file-name-directory flymake-temp-source-file-name))))
1817 1767
1818;;;; perl-specific init-cleanup routines 1768;;;; perl-specific init-cleanup routines
1819(defun flymake-perl-init (buffer) 1769(defun flymake-perl-init ()
1820 (let* ((temp-file (flymake-init-create-temp-buffer-copy 1770 (let* ((temp-file (flymake-init-create-temp-buffer-copy
1821 buffer 'flymake-create-temp-inplace)) 1771 'flymake-create-temp-inplace))
1822 (local-file (concat (flymake-build-relative-filename 1772 (local-file (concat (flymake-build-relative-filename
1823 (file-name-directory buffer-file-name) 1773 (file-name-directory buffer-file-name)
1824 (file-name-directory temp-file)) 1774 (file-name-directory temp-file))
@@ -1830,13 +1780,13 @@ Use CREATE-TEMP-F for creating temp copy."
1830 ;;(list "latex" (list "-c-style-errors" file-name)) 1780 ;;(list "latex" (list "-c-style-errors" file-name))
1831 (list "texify" (list "--pdf" "--tex-option=-c-style-errors" file-name))) 1781 (list "texify" (list "--pdf" "--tex-option=-c-style-errors" file-name)))
1832 1782
1833(defun flymake-simple-tex-init (buffer) 1783(defun flymake-simple-tex-init ()
1834 (flymake-get-tex-args (flymake-init-create-temp-buffer-copy buffer 'flymake-create-temp-inplace))) 1784 (flymake-get-tex-args (flymake-init-create-temp-buffer-copy 'flymake-create-temp-inplace)))
1835 1785
1836(defun flymake-master-tex-init (buffer) 1786(defun flymake-master-tex-init ()
1837 (let* ((temp-master-file-name (flymake-init-create-temp-source-and-master-buffer-copy 1787 (let* ((temp-master-file-name (flymake-init-create-temp-source-and-master-buffer-copy
1838 buffer 'flymake-get-include-dirs-dot 'flymake-create-temp-inplace 1788 'flymake-get-include-dirs-dot 'flymake-create-temp-inplace
1839 '(".+\\.tex$") 1789 '("\\.tex\\'")
1840 '("[ \t]*\\input[ \t]*{\\(.*\\)\\(%s\\)}" 1 2)))) 1790 '("[ \t]*\\input[ \t]*{\\(.*\\)\\(%s\\)}" 1 2))))
1841 (when temp-master-file-name 1791 (when temp-master-file-name
1842 (flymake-get-tex-args temp-master-file-name)))) 1792 (flymake-get-tex-args temp-master-file-name))))
@@ -1845,8 +1795,8 @@ Use CREATE-TEMP-F for creating temp copy."
1845 '(".")) 1795 '("."))
1846 1796
1847;;;; xml-specific init-cleanup routines 1797;;;; xml-specific init-cleanup routines
1848(defun flymake-xml-init (buffer) 1798(defun flymake-xml-init ()
1849 (list "xml" (list "val" (flymake-init-create-temp-buffer-copy buffer 'flymake-create-temp-inplace)))) 1799 (list "xml" (list "val" (flymake-init-create-temp-buffer-copy 'flymake-create-temp-inplace))))
1850 1800
1851(provide 'flymake) 1801(provide 'flymake)
1852 1802