Mercurial > emacs
annotate lisp/progmodes/flymake.el @ 61714:de02ab04abd0
(menu-bar-options-save, menu-bar-showhide-menu): Add size-indication-mode.
author | Lute Kamstra <lute@gnu.org> |
---|---|
date | Thu, 21 Apr 2005 10:30:05 +0000 |
parents | b600a84e6555 |
children | 26bd7a854809 |
rev | line source |
---|---|
55822 | 1 ;;; flymake.el -- a universal on-the-fly syntax checker |
2 | |
60903
29db3b79c3fa
Misc fix up of comments and docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58561
diff
changeset
|
3 ;; Copyright (C) 2003, 2005 Free Software Foundation |
55822 | 4 |
5 ;; Author: Pavel Kobiakov <pk_at_work@yahoo.com> | |
6 ;; Maintainer: Pavel Kobiakov <pk_at_work@yahoo.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 2, or (at your option) | |
15 ;; 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; see the file COPYING. If not, write to the | |
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
25 ;; Boston, MA 02111-1307, USA. | |
26 | |
27 ;;; Commentary: | |
28 ;; | |
29 ;; Flymake is a minor Emacs mode performing on-the-fly syntax | |
30 ;; checks using the external syntax check tool (for C/C++ this | |
31 ;; is usually the compiler) | |
32 | |
33 ;;; Code: | |
34 | |
58561 | 35 ;;;; [[ Xemacs overlay compatibility |
36 (if (featurep 'xemacs) (progn | |
55822 | 37 (autoload 'make-overlay "overlay" "Overlay compatibility kit." t) |
38 (autoload 'overlayp "overlay" "Overlay compatibility kit." t) | |
39 (autoload 'overlays-in "overlay" "Overlay compatibility kit." t) | |
40 (autoload 'delete-overlay "overlay" "Overlay compatibility kit." t) | |
41 (autoload 'overlay-put "overlay" "Overlay compatibility kit." t) | |
42 (autoload 'overlay-get "overlay" "Overlay compatibility kit." t) | |
58561 | 43 )) |
55822 | 44 ;;;; ]] |
45 | |
46 ;;;; [[ cross-emacs compatibility routines | |
58561 | 47 (defsubst flymake-makehash (&optional test) |
48 (if (fboundp 'make-hash-table) | |
49 (if test (make-hash-table :test test) (make-hash-table)) | |
50 (makehash test))) | |
55822 | 51 |
60904
6c1fb526eda5
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60903
diff
changeset
|
52 (defalias 'flymake-float-time |
6c1fb526eda5
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60903
diff
changeset
|
53 (if (fboundp 'float-time) |
6c1fb526eda5
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60903
diff
changeset
|
54 'float-time |
6c1fb526eda5
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60903
diff
changeset
|
55 (lambda () |
6c1fb526eda5
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60903
diff
changeset
|
56 (multiple-value-bind (s0 s1 s2) (current-time) |
6c1fb526eda5
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60903
diff
changeset
|
57 (+ (* (float (ash 1 16)) s0) (float s1) (* 0.0000001 s2)))))) |
58515 | 58 |
58561 | 59 (defsubst flymake-replace-regexp-in-string (regexp rep str) |
60904
6c1fb526eda5
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60903
diff
changeset
|
60 (if (fboundp 'replace-regexp-in-string) |
6c1fb526eda5
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60903
diff
changeset
|
61 (replace-regexp-in-string regexp rep str) |
6c1fb526eda5
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60903
diff
changeset
|
62 (replace-in-string str regexp rep))) |
55822 | 63 |
58561 | 64 (defun flymake-split-string (str pattern) |
58515 | 65 "Split, then remove first and/or last in case it's empty." |
66 (let* ((splitted (split-string str pattern))) | |
67 (if (and (> (length splitted) 0) (= 0 (length (elt splitted 0)))) | |
68 (setq splitted (cdr splitted))) | |
69 (if (and (> (length splitted) 0) (= 0 (length (elt splitted (1- (length splitted)))))) | |
70 (setq splitted (reverse (cdr (reverse splitted))))) | |
71 splitted)) | |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
72 |
58561 | 73 (defsubst flymake-get-temp-dir () |
60904
6c1fb526eda5
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60903
diff
changeset
|
74 (if (fboundp 'temp-directory) |
58561 | 75 (temp-directory) |
76 temporary-file-directory)) | |
55822 | 77 |
60904
6c1fb526eda5
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60903
diff
changeset
|
78 (defalias 'flymake-line-beginning-position |
6c1fb526eda5
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60903
diff
changeset
|
79 (if (fboundp 'line-beginning-position) |
6c1fb526eda5
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60903
diff
changeset
|
80 'line-beginning-position |
6c1fb526eda5
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60903
diff
changeset
|
81 (lambda (&optional arg) (save-excursion (beginning-of-line arg) (point))))) |
55822 | 82 |
60904
6c1fb526eda5
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60903
diff
changeset
|
83 (defalias 'flymake-line-end-position |
6c1fb526eda5
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60903
diff
changeset
|
84 (if (fboundp 'line-end-position) |
6c1fb526eda5
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60903
diff
changeset
|
85 'line-end-position |
6c1fb526eda5
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60903
diff
changeset
|
86 (lambda (&optional arg) (save-excursion (end-of-line arg) (point))))) |
55822 | 87 |
58515 | 88 (defun flymake-popup-menu (pos menu-data) |
60904
6c1fb526eda5
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60903
diff
changeset
|
89 (if (and (fboundp 'popup-menu) (fboundp 'make-event)) |
58561 | 90 (let* ((x-pos (nth 0 (nth 0 pos))) |
91 (y-pos (nth 1 (nth 0 pos))) | |
92 (fake-event-props '(button 1 x 1 y 1))) | |
93 (setq fake-event-props (plist-put fake-event-props 'x x-pos)) | |
94 (setq fake-event-props (plist-put fake-event-props 'y y-pos)) | |
95 (popup-menu (flymake-make-xemacs-menu menu-data) (make-event 'button-press fake-event-props))) | |
96 (x-popup-menu pos (flymake-make-emacs-menu menu-data)))) | |
55822 | 97 |
58515 | 98 (defun flymake-make-emacs-menu (menu-data) |
99 (let* ((menu-title (nth 0 menu-data)) | |
100 (menu-items (nth 1 menu-data)) | |
101 (menu-commands nil)) | |
102 (setq menu-commands (mapcar (lambda (foo) | |
103 (cons (nth 0 foo) (nth 1 foo))) | |
104 menu-items)) | |
105 (list menu-title (cons "" menu-commands)))) | |
55822 | 106 |
60904
6c1fb526eda5
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60903
diff
changeset
|
107 (if (featurep 'xemacs) (progn |
55822 | 108 |
60904
6c1fb526eda5
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60903
diff
changeset
|
109 (defun flymake-nop ()) |
58561 | 110 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
111 (defun flymake-make-xemacs-menu (menu-data) |
58515 | 112 (let* ((menu-title (nth 0 menu-data)) |
113 (menu-items (nth 1 menu-data)) | |
114 (menu-commands nil)) | |
115 (setq menu-commands (mapcar (lambda (foo) | |
116 (vector (nth 0 foo) (or (nth 1 foo) '(flymake-nop)) t)) | |
117 menu-items)) | |
118 (cons menu-title menu-commands))) | |
55822 | 119 |
58515 | 120 (defun flymake-xemacs-window-edges (&optional window) |
121 (let ((edges (window-pixel-edges window)) | |
122 tmp) | |
123 (setq tmp edges) | |
124 (setcar tmp (/ (car tmp) (face-width 'default))) | |
125 (setq tmp (cdr tmp)) | |
126 (setcar tmp (/ (car tmp) (face-height 'default))) | |
127 (setq tmp (cdr tmp)) | |
128 (setcar tmp (/ (car tmp) (face-width 'default))) | |
129 (setq tmp (cdr tmp)) | |
130 (setcar tmp (/ (car tmp) (face-height 'default))) | |
131 edges)) | |
55822 | 132 |
58561 | 133 )) ;; xemacs |
134 | |
58515 | 135 (defun flymake-current-row () |
136 "Return current row number in current frame." | |
60904
6c1fb526eda5
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60903
diff
changeset
|
137 (if (fboundp 'window-edges) |
6c1fb526eda5
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60903
diff
changeset
|
138 (+ (car (cdr (window-edges))) (count-lines (window-start) (point))) |
6c1fb526eda5
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60903
diff
changeset
|
139 (count-lines (window-start) (point)))) |
55822 | 140 |
58515 | 141 (defun flymake-selected-frame () |
60904
6c1fb526eda5
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60903
diff
changeset
|
142 (if (fboundp 'window-edges) |
6c1fb526eda5
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60903
diff
changeset
|
143 (selected-frame) |
6c1fb526eda5
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60903
diff
changeset
|
144 (selected-window))) |
55822 | 145 |
146 ;;;; ]] | |
147 | |
148 (defcustom flymake-log-level -1 | |
60904
6c1fb526eda5
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60903
diff
changeset
|
149 "Logging level, only messages with level lower or equal will be logged. |
55822 | 150 -1 = NONE, 0 = ERROR, 1 = WARNING, 2 = INFO, 3 = DEBUG" |
58515 | 151 :group 'flymake |
152 :type 'integer) | |
55822 | 153 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
154 (defun flymake-log (level text &rest args) |
58515 | 155 "Log a message with optional arguments." |
156 (if (<= level flymake-log-level) | |
157 (let* ((msg (apply 'format text args))) | |
158 (message msg) | |
159 ;;(with-temp-buffer | |
160 ;; (insert msg) | |
161 ;; (insert "\n") | |
162 ;; (flymake-save-buffer-in-file (current-buffer) "d:/flymake.log" t) ; make log file name customizable | |
163 ;;) | |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
164 ))) |
55822 | 165 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
166 (defun flymake-ins-after (list pos val) |
58515 | 167 "Insert VAL into LIST after position POS." |
168 (let ((tmp (copy-sequence list))) ; (???) | |
169 (setcdr (nthcdr pos tmp) (cons val (nthcdr (1+ pos) tmp))) | |
170 tmp)) | |
55822 | 171 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
172 (defun flymake-set-at (list pos val) |
60903
29db3b79c3fa
Misc fix up of comments and docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58561
diff
changeset
|
173 "Set VAL at position POS in LIST." |
58515 | 174 (let ((tmp (copy-sequence list))) ; (???) |
175 (setcar (nthcdr pos tmp) val) | |
176 tmp)) | |
55822 | 177 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
178 (defvar flymake-pid-to-names (flymake-makehash) |
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
179 "pid -> source buffer name, output file name mapping.") |
55822 | 180 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
181 (defun flymake-reg-names (pid source-buffer-name) |
58515 | 182 "Save into in PID map." |
183 (unless (stringp source-buffer-name) | |
184 (error "Invalid buffer name")) | |
185 (puthash pid (list source-buffer-name) flymake-pid-to-names)) | |
55822 | 186 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
187 (defun flymake-get-source-buffer-name (pid) |
58515 | 188 "Return buffer name stored in PID map." |
189 (nth 0 (gethash pid flymake-pid-to-names))) | |
55822 | 190 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
191 (defun flymake-unreg-names (pid) |
58515 | 192 "Delete PID->buffer name mapping." |
193 (remhash pid flymake-pid-to-names)) | |
55822 | 194 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
195 (defun flymake-get-buffer-var (buffer var-name) |
58515 | 196 "Switch to BUFFER if necessary and return local variable VAR-NAME." |
197 (unless (bufferp buffer) | |
198 (error "Invalid buffer")) | |
55822 | 199 |
58515 | 200 (if (eq buffer (current-buffer)) |
201 (symbol-value var-name) | |
60904
6c1fb526eda5
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60903
diff
changeset
|
202 (with-current-buffer buffer |
58515 | 203 (symbol-value var-name)))) |
55822 | 204 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
205 (defun flymake-set-buffer-var (buffer var-name var-value) |
58515 | 206 "Switch to BUFFER if necessary and set local variable VAR-NAME to VAR-VALUE." |
207 (unless (bufferp buffer) | |
208 (error "Invalid buffer")) | |
55822 | 209 |
58515 | 210 (if (eq buffer (current-buffer)) |
211 (set var-name var-value) | |
60904
6c1fb526eda5
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60903
diff
changeset
|
212 (with-current-buffer buffer |
58515 | 213 (set var-name var-value)))) |
55822 | 214 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
215 (defvar flymake-buffer-data (flymake-makehash) |
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
216 "Data specific to syntax check tool, in name-value pairs.") |
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
217 |
55822 | 218 (make-variable-buffer-local 'flymake-buffer-data) |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
219 |
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
220 (defun flymake-get-buffer-data (buffer) |
58515 | 221 (flymake-get-buffer-var buffer 'flymake-buffer-data)) |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
222 |
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
223 (defun flymake-set-buffer-data (buffer data) |
58515 | 224 (flymake-set-buffer-var buffer 'flymake-buffer-data data)) |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
225 |
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
226 (defun flymake-get-buffer-value (buffer name) |
58515 | 227 (gethash name (flymake-get-buffer-data buffer))) |
55822 | 228 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
229 (defun flymake-set-buffer-value (buffer name value) |
58515 | 230 (puthash name value (flymake-get-buffer-data buffer))) |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
231 |
60903
29db3b79c3fa
Misc fix up of comments and docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58561
diff
changeset
|
232 (defvar flymake-output-residual nil) |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
233 |
55822 | 234 (make-variable-buffer-local 'flymake-output-residual) |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
235 |
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
236 (defun flymake-get-buffer-output-residual (buffer) |
58515 | 237 (flymake-get-buffer-var buffer 'flymake-output-residual)) |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
238 |
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
239 (defun flymake-set-buffer-output-residual (buffer residual) |
58515 | 240 (flymake-set-buffer-var buffer 'flymake-output-residual residual)) |
55822 | 241 |
58515 | 242 (defcustom flymake-allowed-file-name-masks |
243 '((".+\\.c$" flymake-simple-make-init flymake-simple-cleanup flymake-get-real-file-name) | |
244 (".+\\.cpp$" flymake-simple-make-init flymake-simple-cleanup flymake-get-real-file-name) | |
245 (".+\\.xml$" flymake-xml-init flymake-simple-cleanup flymake-get-real-file-name) | |
246 (".+\\.html?$" flymake-xml-init flymake-simple-cleanup flymake-get-real-file-name) | |
247 (".+\\.cs$" flymake-simple-make-init flymake-simple-cleanup flymake-get-real-file-name) | |
248 (".+\\.pl$" flymake-perl-init flymake-simple-cleanup flymake-get-real-file-name) | |
249 (".+\\.h$" flymake-master-make-header-init flymake-master-cleanup flymake-get-real-file-name) | |
250 (".+\\.java$" flymake-simple-make-java-init flymake-simple-java-cleanup flymake-get-real-file-name) | |
251 (".+[0-9]+\\.tex$" flymake-master-tex-init flymake-master-cleanup flymake-get-real-file-name) | |
252 (".+\\.tex$" flymake-simple-tex-init flymake-simple-cleanup flymake-get-real-file-name) | |
253 (".+\\.idl$" flymake-simple-make-init flymake-simple-cleanup flymake-get-real-file-name) | |
60903
29db3b79c3fa
Misc fix up of comments and docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58561
diff
changeset
|
254 ;; (".+\\.cpp$" 1) |
29db3b79c3fa
Misc fix up of comments and docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58561
diff
changeset
|
255 ;; (".+\\.java$" 3) |
29db3b79c3fa
Misc fix up of comments and docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58561
diff
changeset
|
256 ;; (".+\\.h$" 2 (".+\\.cpp$" ".+\\.c$") |
29db3b79c3fa
Misc fix up of comments and docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58561
diff
changeset
|
257 ;; ("[ \t]*#[ \t]*include[ \t]*\"\\([\w0-9/\\_\.]*[/\\]*\\)\\(%s\\)\"" 1 2)) |
29db3b79c3fa
Misc fix up of comments and docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58561
diff
changeset
|
258 ;; (".+\\.idl$" 1) |
29db3b79c3fa
Misc fix up of comments and docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58561
diff
changeset
|
259 ;; (".+\\.odl$" 1) |
29db3b79c3fa
Misc fix up of comments and docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58561
diff
changeset
|
260 ;; (".+[0-9]+\\.tex$" 2 (".+\\.tex$") |
29db3b79c3fa
Misc fix up of comments and docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58561
diff
changeset
|
261 ;; ("[ \t]*\\input[ \t]*{\\(.*\\)\\(%s\\)}" 1 2 )) |
29db3b79c3fa
Misc fix up of comments and docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58561
diff
changeset
|
262 ;; (".+\\.tex$" 1) |
58515 | 263 ) |
264 "*Files syntax checking is allowed for." | |
265 :group 'flymake | |
266 :type '(repeat (string symbol symbol symbol))) | |
55822 | 267 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
268 (defun flymake-get-file-name-mode-and-masks (file-name) |
60903
29db3b79c3fa
Misc fix up of comments and docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58561
diff
changeset
|
269 "Return the corresponding entry from `flymake-allowed-file-name-masks'." |
58515 | 270 (unless (stringp file-name) |
271 (error "Invalid file-name")) | |
60906
9b761ddc6f4b
(flymake-get-file-name-mode-and-masks)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60905
diff
changeset
|
272 (let ((fnm flymake-allowed-file-name-masks) |
58515 | 273 (mode-and-masks nil)) |
60906
9b761ddc6f4b
(flymake-get-file-name-mode-and-masks)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60905
diff
changeset
|
274 (while (and (not mode-and-masks) fnm) |
9b761ddc6f4b
(flymake-get-file-name-mode-and-masks)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60905
diff
changeset
|
275 (if (string-match (car (car fnm)) file-name) |
9b761ddc6f4b
(flymake-get-file-name-mode-and-masks)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60905
diff
changeset
|
276 (setq mode-and-masks (cdr (car fnm)))) |
9b761ddc6f4b
(flymake-get-file-name-mode-and-masks)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60905
diff
changeset
|
277 (setq fnm (cdr fnm))) |
58515 | 278 (flymake-log 3 "file %s, init=%s" file-name (car mode-and-masks)) |
279 mode-and-masks)) | |
55822 | 280 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
281 (defun flymake-can-syntax-check-file (file-name) |
58515 | 282 "Determine whether we can syntax check FILE-NAME. |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
283 Return nil if we cannot, non-nil if we can." |
58515 | 284 (if (flymake-get-init-function file-name) t nil)) |
55822 | 285 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
286 (defun flymake-get-init-function (file-name) |
58515 | 287 "Return init function to be used for the file." |
288 (let* ((init-f (nth 0 (flymake-get-file-name-mode-and-masks file-name)))) | |
60903
29db3b79c3fa
Misc fix up of comments and docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58561
diff
changeset
|
289 ;;(flymake-log 0 "calling %s" init-f) |
29db3b79c3fa
Misc fix up of comments and docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58561
diff
changeset
|
290 ;;(funcall init-f (current-buffer)) |
58515 | 291 init-f)) |
55822 | 292 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
293 (defun flymake-get-cleanup-function (file-name) |
58515 | 294 "Return cleanup function to be used for the file." |
295 (nth 1 (flymake-get-file-name-mode-and-masks file-name))) | |
55822 | 296 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
297 (defun flymake-get-real-file-name-function (file-name) |
58515 | 298 (or (nth 2 (flymake-get-file-name-mode-and-masks file-name)) 'flymake-get-real-file-name)) |
55822 | 299 |
300 (defcustom flymake-buildfile-dirs '("." ".." "../.." "../../.." "../../../.." "../../../../.." "../../../../../.." "../../../../../../.." "../../../../../../../.." "../../../../../../../../.." "../../../../../../../../../.." "../../../../../../../../../../..") | |
58515 | 301 "Dirs to look for buildfile." |
302 :group 'flymake | |
303 :type '(repeat (string))) | |
55822 | 304 |
305 (defvar flymake-find-buildfile-cache (flymake-makehash 'equal)) | |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
306 |
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
307 (defun flymake-get-buildfile-from-cache (dir-name) |
58515 | 308 (gethash dir-name flymake-find-buildfile-cache)) |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
309 |
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
310 (defun flymake-add-buildfile-to-cache (dir-name buildfile) |
58515 | 311 (puthash dir-name buildfile flymake-find-buildfile-cache)) |
55822 | 312 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
313 (defun flymake-clear-buildfile-cache () |
58515 | 314 (clrhash flymake-find-buildfile-cache)) |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
315 |
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
316 (defun flymake-find-buildfile (buildfile-name source-dir-name dirs) |
58515 | 317 "Find buildfile starting from current directory. |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
318 Buildfile includes Makefile, build.xml etc. |
58515 | 319 Return its file name if found, or nil if not found." |
320 (if (flymake-get-buildfile-from-cache source-dir-name) | |
321 (progn | |
322 (flymake-get-buildfile-from-cache source-dir-name)) | |
323 (let* ((buildfile-dir nil) | |
324 (buildfile nil) | |
325 (found nil)) | |
60906
9b761ddc6f4b
(flymake-get-file-name-mode-and-masks)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60905
diff
changeset
|
326 (while (and (not found) dirs) |
9b761ddc6f4b
(flymake-get-file-name-mode-and-masks)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60905
diff
changeset
|
327 (setq buildfile-dir (concat source-dir-name (car dirs))) |
58515 | 328 (setq buildfile (concat buildfile-dir "/" buildfile-name)) |
329 (when (file-exists-p buildfile) | |
330 (setq found t)) | |
60906
9b761ddc6f4b
(flymake-get-file-name-mode-and-masks)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60905
diff
changeset
|
331 (setq dirs (cdr dirs))) |
58515 | 332 (if found |
333 (progn | |
334 (flymake-log 3 "found buildfile at %s/%s" buildfile-dir buildfile-name) | |
335 (flymake-add-buildfile-to-cache source-dir-name buildfile-dir) | |
336 buildfile-dir) | |
55822 | 337 (progn |
58515 | 338 (flymake-log 3 "buildfile for %s not found" source-dir-name) |
339 nil))))) | |
55822 | 340 |
58515 | 341 (defun flymake-fix-file-name (name) |
342 "Replace all occurences of '\' with '/'." | |
343 (when name | |
344 (let* ((new-name (flymake-replace-regexp-in-string "[\\]" "/" (expand-file-name name))) | |
345 (last-char (elt new-name (1- (length new-name))))) | |
346 (setq new-name (flymake-replace-regexp-in-string "\\./" "" new-name)) | |
347 (if (equal "/" (char-to-string last-char)) | |
348 (setq new-name (substring new-name 0 (1- (length new-name))))) | |
349 new-name))) | |
55822 | 350 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
351 (defun flymake-same-files (file-name-one file-name-two) |
58515 | 352 "Check if FILE-NAME-ONE and FILE-NAME-TWO point to same file. |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
353 Return t if so, nil if not." |
58515 | 354 (equal (flymake-fix-file-name file-name-one) |
355 (flymake-fix-file-name file-name-two))) | |
55822 | 356 |
58515 | 357 (defun flymake-get-common-file-prefix (string-one string-two) |
358 "Return common prefix for two file names STRING-ONE and STRING-TWO." | |
60905
6611fdf35049
(flymake-ensure-ends-with-slash): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60904
diff
changeset
|
359 (setq string-one (file-name-as-directory string-one)) |
6611fdf35049
(flymake-ensure-ends-with-slash): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60904
diff
changeset
|
360 (setq string-two (file-name-as-directory string-two)) |
6611fdf35049
(flymake-ensure-ends-with-slash): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60904
diff
changeset
|
361 (let ((n (compare-strings string-one nil nil string-two nil nil))) |
6611fdf35049
(flymake-ensure-ends-with-slash): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60904
diff
changeset
|
362 (if (eq n t) string-one |
6611fdf35049
(flymake-ensure-ends-with-slash): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60904
diff
changeset
|
363 (setq n (abs (1+ n))) |
6611fdf35049
(flymake-ensure-ends-with-slash): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60904
diff
changeset
|
364 (file-name-directory (substring string-one 0 n))))) |
55822 | 365 |
58515 | 366 (defun flymake-build-relative-filename (from-dir to-dir) |
367 "Return rel: FROM-DIR/rel == TO-DIR." | |
60903
29db3b79c3fa
Misc fix up of comments and docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58561
diff
changeset
|
368 ;; FIXME: Why not use `file-relative-name'? |
58515 | 369 (if (not (equal (elt from-dir 0) (elt to-dir 0))) |
370 (error "First chars in file names %s, %s must be equal (same drive)" | |
371 from-dir to-dir) | |
60905
6611fdf35049
(flymake-ensure-ends-with-slash): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60904
diff
changeset
|
372 (let* ((from (file-name-as-directory (flymake-fix-file-name from-dir))) |
6611fdf35049
(flymake-ensure-ends-with-slash): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60904
diff
changeset
|
373 (to (file-name-as-directory (flymake-fix-file-name to-dir))) |
58515 | 374 (prefix (flymake-get-common-file-prefix from to)) |
375 (from-suffix (substring from (length prefix))) | |
376 (up-count (length (flymake-split-string from-suffix "[/]"))) | |
377 (to-suffix (substring to (length prefix))) | |
378 (idx 0) | |
379 (rel nil)) | |
380 (if (and (> (length to-suffix) 0) (equal "/" (char-to-string (elt to-suffix 0)))) | |
381 (setq to-suffix (substring to-suffix 1))) | |
55822 | 382 |
58515 | 383 (while (< idx up-count) |
384 (if (> (length rel) 0) | |
385 (setq rel (concat rel "/"))) | |
386 (setq rel (concat rel "..")) | |
387 (setq idx (1+ idx))) | |
388 (if (> (length rel) 0) | |
389 (setq rel (concat rel "/"))) | |
390 (if (> (length to-suffix) 0) | |
391 (setq rel (concat rel to-suffix))) | |
392 (or rel "./")))) | |
55822 | 393 |
394 (defcustom flymake-master-file-dirs '("." "./src" "./UnitTest") | |
60903
29db3b79c3fa
Misc fix up of comments and docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58561
diff
changeset
|
395 "Dirs where to look for master files." |
58515 | 396 :group 'flymake |
397 :type '(repeat (string))) | |
55822 | 398 |
399 (defcustom flymake-master-file-count-limit 32 | |
58515 | 400 "Max number of master files to check." |
401 :group 'flymake | |
402 :type 'integer) | |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
403 |
58561 | 404 ;; This is bound dynamically to pass a parameter to a sort predicate below |
405 (defvar flymake-included-file-name) | |
55822 | 406 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
407 (defun flymake-find-possible-master-files (file-name master-file-dirs masks) |
60903
29db3b79c3fa
Misc fix up of comments and docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58561
diff
changeset
|
408 "Find (by name and location) all possible master files. |
29db3b79c3fa
Misc fix up of comments and docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58561
diff
changeset
|
409 Master files are .cpp and .c for and .h. Files are searched for |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
410 starting from the .h directory and max max-level parent dirs. |
55822 | 411 File contents are not checked." |
60906
9b761ddc6f4b
(flymake-get-file-name-mode-and-masks)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60905
diff
changeset
|
412 (let* ((dirs master-file-dirs) |
58515 | 413 (files nil) |
60906
9b761ddc6f4b
(flymake-get-file-name-mode-and-masks)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60905
diff
changeset
|
414 (done nil)) |
55822 | 415 |
60906
9b761ddc6f4b
(flymake-get-file-name-mode-and-masks)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60905
diff
changeset
|
416 (while (and (not done) dirs) |
9b761ddc6f4b
(flymake-get-file-name-mode-and-masks)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60905
diff
changeset
|
417 (let* ((dir (concat (flymake-fix-file-name (file-name-directory file-name)) |
9b761ddc6f4b
(flymake-get-file-name-mode-and-masks)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60905
diff
changeset
|
418 "/" (car dirs))) |
9b761ddc6f4b
(flymake-get-file-name-mode-and-masks)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60905
diff
changeset
|
419 (masks masks)) |
9b761ddc6f4b
(flymake-get-file-name-mode-and-masks)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60905
diff
changeset
|
420 (while (and (file-exists-p dir) (not done) masks) |
9b761ddc6f4b
(flymake-get-file-name-mode-and-masks)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60905
diff
changeset
|
421 (let* ((mask (car masks)) |
9b761ddc6f4b
(flymake-get-file-name-mode-and-masks)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60905
diff
changeset
|
422 (dir-files (directory-files dir t mask))) |
55822 | 423 |
60906
9b761ddc6f4b
(flymake-get-file-name-mode-and-masks)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60905
diff
changeset
|
424 (flymake-log 3 "dir %s, %d file(s) for mask %s" |
9b761ddc6f4b
(flymake-get-file-name-mode-and-masks)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60905
diff
changeset
|
425 dir (length dir-files) mask) |
9b761ddc6f4b
(flymake-get-file-name-mode-and-masks)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60905
diff
changeset
|
426 (while (and (not done) dir-files) |
9b761ddc6f4b
(flymake-get-file-name-mode-and-masks)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60905
diff
changeset
|
427 (when (not (file-directory-p (car dir-files))) |
9b761ddc6f4b
(flymake-get-file-name-mode-and-masks)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60905
diff
changeset
|
428 (setq files (cons (car dir-files) files)) |
58515 | 429 (when (>= (length files) flymake-master-file-count-limit) |
430 (flymake-log 3 "master file count limit (%d) reached" flymake-master-file-count-limit) | |
431 (setq done t))) | |
60906
9b761ddc6f4b
(flymake-get-file-name-mode-and-masks)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60905
diff
changeset
|
432 (setq dir-files (cdr dir-files)))) |
9b761ddc6f4b
(flymake-get-file-name-mode-and-masks)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60905
diff
changeset
|
433 (setq masks (cdr masks)))) |
9b761ddc6f4b
(flymake-get-file-name-mode-and-masks)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60905
diff
changeset
|
434 (setq dirs (cdr dirs))) |
58515 | 435 (when files |
58561 | 436 (let ((flymake-included-file-name (file-name-nondirectory file-name))) |
437 (setq files (sort files 'flymake-master-file-compare)))) | |
58515 | 438 (flymake-log 3 "found %d possible master file(s)" (length files)) |
439 files)) | |
55822 | 440 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
441 (defun flymake-master-file-compare (file-one file-two) |
58515 | 442 "Compare two files speccified by FILE-ONE and FILE-TWO. |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
443 This function is used in sort to move most possible file names |
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
444 to the beginning of the list (File.h -> File.cpp moved to top." |
58515 | 445 (and (equal (file-name-sans-extension flymake-included-file-name) |
446 (file-name-sans-extension (file-name-nondirectory file-one))) | |
447 (not (equal file-one file-two)))) | |
55822 | 448 |
449 (defcustom flymake-check-file-limit 8192 | |
58515 | 450 "Max number of chars to look at when checking possible master file." |
451 :group 'flymake | |
452 :type 'integer) | |
55822 | 453 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
454 (defun flymake-check-patch-master-file-buffer (master-file-temp-buffer |
58515 | 455 master-file-name patched-master-file-name |
456 source-file-name patched-source-file-name | |
457 include-dirs regexp-list) | |
458 "Check if MASTER-FILE-NAME is a master file for SOURCE-FILE-NAME. | |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
459 For .cpp master file this means it includes SOURCE-FILE-NAME (.h). |
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
460 If yes, patch a copy of MASTER-FILE-NAME to include PATCHED-SOURCE-FILE-NAME |
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
461 instead of SOURCE-FILE-NAME. |
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
462 Whether a buffer for MATER-FILE-NAME exists, use it as a source |
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
463 instead of reading master file from disk." |
58515 | 464 (let* ((found nil) |
465 (regexp (format (nth 0 regexp-list) ; "[ \t]*#[ \t]*include[ \t]*\"\\([\w0-9/\\_\.]*[/\\]*\\)\\(%s\\)\"" | |
466 (file-name-nondirectory source-file-name))) | |
467 (path-idx (nth 1 regexp-list)) | |
468 (name-idx (nth 2 regexp-list)) | |
469 (inc-path nil) | |
470 (inc-name nil) | |
471 (search-limit flymake-check-file-limit)) | |
472 (save-excursion | |
473 (unwind-protect | |
474 (progn | |
475 (set-buffer master-file-temp-buffer) | |
476 (when (> search-limit (point-max)) | |
477 (setq search-limit (point-max))) | |
478 (flymake-log 3 "checking %s against regexp %s" master-file-name regexp) | |
479 (goto-char (point-min)) | |
480 (while (and (< (point) search-limit) (re-search-forward regexp search-limit t)) | |
481 (let* ((match-beg (match-beginning name-idx)) | |
482 (match-end (match-end name-idx))) | |
55822 | 483 |
58515 | 484 (flymake-log 3 "found possible match for %s" (file-name-nondirectory source-file-name)) |
485 (setq inc-path (match-string path-idx)) | |
486 (setq inc-name (match-string name-idx)) | |
487 (when (string= inc-name (file-name-nondirectory source-file-name)) | |
488 (flymake-log 3 "inc-path=%s inc-name=%s" inc-path inc-name) | |
489 (when (flymake-check-include source-file-name inc-path inc-name include-dirs) | |
490 (setq found t) | |
491 ;; replace-match is not used here as it fails in | |
60903
29db3b79c3fa
Misc fix up of comments and docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58561
diff
changeset
|
492 ;; XEmacs with 'last match not a buffer' error as |
58515 | 493 ;; check-includes calls replace-in-string |
60905
6611fdf35049
(flymake-ensure-ends-with-slash): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60904
diff
changeset
|
494 (flymake-replace-region match-beg match-end |
58515 | 495 (file-name-nondirectory patched-source-file-name)))) |
496 (forward-line 1))) | |
497 (when found | |
498 (flymake-save-buffer-in-file (current-buffer) patched-master-file-name))) | |
60903
29db3b79c3fa
Misc fix up of comments and docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58561
diff
changeset
|
499 ;;+(flymake-log 3 "killing buffer %s" (buffer-name master-file-temp-buffer)) |
58515 | 500 (kill-buffer master-file-temp-buffer))) |
60903
29db3b79c3fa
Misc fix up of comments and docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58561
diff
changeset
|
501 ;;+(flymake-log 3 "check-patch master file %s: %s" master-file-name found) |
58515 | 502 (when found |
503 (flymake-log 2 "found master file %s" master-file-name)) | |
504 found)) | |
55822 | 505 |
60905
6611fdf35049
(flymake-ensure-ends-with-slash): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60904
diff
changeset
|
506 (defun flymake-replace-region (beg end rep) |
58515 | 507 "Replace text in BUFFER in region (BEG END) with REP." |
508 (save-excursion | |
60905
6611fdf35049
(flymake-ensure-ends-with-slash): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60904
diff
changeset
|
509 (goto-char end) |
6611fdf35049
(flymake-ensure-ends-with-slash): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60904
diff
changeset
|
510 ;; Insert before deleting, so as to better preserve markers's positions. |
6611fdf35049
(flymake-ensure-ends-with-slash): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60904
diff
changeset
|
511 (insert rep) |
6611fdf35049
(flymake-ensure-ends-with-slash): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60904
diff
changeset
|
512 (delete-region beg end))) |
55822 | 513 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
514 (defun flymake-read-file-to-temp-buffer (file-name) |
58515 | 515 "Insert contents of FILE-NAME into newly created temp buffer." |
516 (let* ((temp-buffer (get-buffer-create (generate-new-buffer-name (concat "flymake:" (file-name-nondirectory file-name)))))) | |
60904
6c1fb526eda5
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60903
diff
changeset
|
517 (with-current-buffer temp-buffer |
58515 | 518 (insert-file-contents file-name)) |
519 temp-buffer)) | |
55822 | 520 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
521 (defun flymake-copy-buffer-to-temp-buffer (buffer) |
58515 | 522 "Copy contents of BUFFER into newly created temp buffer." |
523 (let ((contents nil) | |
524 (temp-buffer nil)) | |
60904
6c1fb526eda5
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60903
diff
changeset
|
525 (with-current-buffer buffer |
58515 | 526 (setq contents (buffer-string)) |
55822 | 527 |
58515 | 528 (setq temp-buffer (get-buffer-create (generate-new-buffer-name (concat "flymake:" (buffer-name buffer))))) |
529 (set-buffer temp-buffer) | |
530 (insert contents)) | |
531 temp-buffer)) | |
55822 | 532 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
533 (defun flymake-check-include (source-file-name inc-path inc-name include-dirs) |
58515 | 534 "Check if SOURCE-FILE-NAME can be found in include path. |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
535 Return t if it can be found via include path using INC-PATH and INC-NAME." |
58515 | 536 (if (file-name-absolute-p inc-path) |
537 (flymake-same-files source-file-name (concat inc-path "/" inc-name)) | |
60906
9b761ddc6f4b
(flymake-get-file-name-mode-and-masks)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60905
diff
changeset
|
538 (let* ((file-name nil) |
58515 | 539 (found nil)) |
60906
9b761ddc6f4b
(flymake-get-file-name-mode-and-masks)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60905
diff
changeset
|
540 (while (and (not found) include-dirs) |
9b761ddc6f4b
(flymake-get-file-name-mode-and-masks)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60905
diff
changeset
|
541 (setq file-name (concat (file-name-directory source-file-name) |
9b761ddc6f4b
(flymake-get-file-name-mode-and-masks)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60905
diff
changeset
|
542 "/" (car include-dirs))) |
58515 | 543 (if (> (length inc-path) 0) |
544 (setq file-name (concat file-name "/" inc-path))) | |
545 (setq file-name (concat file-name "/" inc-name)) | |
546 (when (flymake-same-files source-file-name file-name) | |
547 (setq found t)) | |
60906
9b761ddc6f4b
(flymake-get-file-name-mode-and-masks)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60905
diff
changeset
|
548 (setq include-dirs (cdr include-dirs))) |
58515 | 549 found))) |
55822 | 550 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
551 (defun flymake-find-buffer-for-file (file-name) |
58515 | 552 "Check if there exists a buffer visiting FILE-NAME. |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
553 Return t if so, nil if not." |
58515 | 554 (let ((buffer-name (get-file-buffer file-name))) |
555 (if buffer-name | |
556 (get-buffer buffer-name)))) | |
55822 | 557 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
558 (defun flymake-create-master-file (source-file-name patched-source-file-name get-incl-dirs-f create-temp-f masks include-regexp-list) |
58515 | 559 "Save SOURCE-FILE-NAME with a different name. |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
560 Find master file, patch and save it." |
58515 | 561 (let* ((possible-master-files (flymake-find-possible-master-files source-file-name flymake-master-file-dirs masks)) |
562 (master-file-count (length possible-master-files)) | |
563 (idx 0) | |
564 (temp-buffer nil) | |
565 (master-file-name nil) | |
566 (patched-master-file-name nil) | |
567 (found nil)) | |
55822 | 568 |
58515 | 569 (while (and (not found) (< idx master-file-count)) |
570 (setq master-file-name (nth idx possible-master-files)) | |
571 (setq patched-master-file-name (funcall create-temp-f master-file-name "flymake_master")) | |
572 (if (flymake-find-buffer-for-file master-file-name) | |
573 (setq temp-buffer (flymake-copy-buffer-to-temp-buffer (flymake-find-buffer-for-file master-file-name))) | |
574 (setq temp-buffer (flymake-read-file-to-temp-buffer master-file-name))) | |
575 (setq found | |
576 (flymake-check-patch-master-file-buffer | |
577 temp-buffer | |
578 master-file-name | |
579 patched-master-file-name | |
580 source-file-name | |
581 patched-source-file-name | |
582 (funcall get-incl-dirs-f (file-name-directory master-file-name)) | |
583 include-regexp-list)) | |
584 (setq idx (1+ idx))) | |
585 (if found | |
586 (list master-file-name patched-master-file-name) | |
587 (progn | |
588 (flymake-log 3 "none of %d master file(s) checked includes %s" master-file-count | |
589 (file-name-nondirectory source-file-name)) | |
590 nil)))) | |
55822 | 591 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
592 (defun flymake-save-buffer-in-file (buffer file-name) |
58515 | 593 (or buffer |
594 (error "Invalid buffer")) | |
60904
6c1fb526eda5
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60903
diff
changeset
|
595 (with-current-buffer buffer |
58515 | 596 (save-restriction |
597 (widen) | |
598 (make-directory (file-name-directory file-name) 1) | |
599 (write-region (point-min) (point-max) file-name nil 566))) | |
600 (flymake-log 3 "saved buffer %s in file %s" (buffer-name buffer) file-name)) | |
55822 | 601 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
602 (defun flymake-save-string-to-file (file-name data) |
58515 | 603 "Save string DATA to file FILE-NAME." |
604 (write-region data nil file-name nil 566)) | |
55822 | 605 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
606 (defun flymake-read-file-to-string (file-name) |
58515 | 607 "Read contents of file FILE-NAME and return as a string." |
608 (with-temp-buffer | |
609 (insert-file-contents file-name) | |
610 (buffer-substring (point-min) (point-max)))) | |
55822 | 611 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
612 (defun flymake-process-filter (process output) |
58515 | 613 "Parse OUTPUT and highlight error lines. |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
614 It's flymake process filter." |
58515 | 615 (let* ((pid (process-id process)) |
616 (source-buffer (get-buffer (flymake-get-source-buffer-name pid)))) | |
55822 | 617 |
58515 | 618 (flymake-log 3 "received %d byte(s) of output from process %d" (length output) pid) |
619 (when source-buffer | |
620 (flymake-parse-output-and-residual source-buffer output)))) | |
55822 | 621 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
622 (defun flymake-process-sentinel (process event) |
58515 | 623 "Sentinel for syntax check buffers." |
624 (if (memq (process-status process) '(signal exit)) | |
625 (let*((exit-status (process-exit-status process)) | |
626 (command (process-command process)) | |
627 (pid (process-id process)) | |
628 (source-buffer (get-buffer (flymake-get-source-buffer-name pid))) | |
629 (cleanup-f (flymake-get-cleanup-function (buffer-file-name source-buffer)))) | |
55822 | 630 |
58515 | 631 (flymake-log 2 "process %d exited with code %d" pid exit-status) |
632 (condition-case err | |
633 (progn | |
634 (flymake-log 3 "cleaning up using %s" cleanup-f) | |
635 (funcall cleanup-f source-buffer) | |
55822 | 636 |
58515 | 637 (flymake-unreg-names pid) |
638 (delete-process process) | |
55822 | 639 |
58515 | 640 (when source-buffer |
60904
6c1fb526eda5
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60903
diff
changeset
|
641 (with-current-buffer source-buffer |
55822 | 642 |
58515 | 643 (flymake-parse-residual source-buffer) |
644 (flymake-post-syntax-check source-buffer exit-status command) | |
645 (flymake-set-buffer-is-running source-buffer nil)))) | |
646 (error | |
647 (let ((err-str (format "Error in process sentinel for buffer %s: %s" | |
648 source-buffer (error-message-string err)))) | |
649 (flymake-log 0 err-str) | |
650 (flymake-set-buffer-is-running source-buffer nil))))))) | |
55822 | 651 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
652 (defun flymake-post-syntax-check (source-buffer exit-status command) |
58515 | 653 (flymake-set-buffer-err-info source-buffer (flymake-get-buffer-new-err-info source-buffer)) |
654 (flymake-set-buffer-new-err-info source-buffer nil) | |
55822 | 655 |
58515 | 656 (flymake-set-buffer-err-info source-buffer (flymake-fix-line-numbers |
657 (flymake-get-buffer-err-info source-buffer) | |
658 1 | |
659 (flymake-count-lines source-buffer))) | |
660 (flymake-delete-own-overlays source-buffer) | |
661 (flymake-highlight-err-lines source-buffer (flymake-get-buffer-err-info source-buffer)) | |
55822 | 662 |
58515 | 663 (let ((err-count (flymake-get-err-count (flymake-get-buffer-err-info source-buffer) "e")) |
664 (warn-count (flymake-get-err-count (flymake-get-buffer-err-info source-buffer) "w"))) | |
55822 | 665 |
58515 | 666 (flymake-log 2 "%s: %d error(s), %d warning(s) in %.2f second(s)" |
667 (buffer-name source-buffer) err-count warn-count | |
668 (- (flymake-float-time) (flymake-get-buffer-check-start-time source-buffer))) | |
669 (flymake-set-buffer-check-start-time source-buffer nil) | |
670 (if (and (equal 0 err-count) (equal 0 warn-count)) | |
671 (if (equal 0 exit-status) | |
672 (flymake-report-status source-buffer "" "") ; PASSED | |
673 (if (not (flymake-get-buffer-check-was-interrupted source-buffer)) | |
674 (flymake-report-fatal-status (current-buffer) "CFGERR" | |
675 (format "Configuration error has occured while running %s" command)) | |
676 (flymake-report-status source-buffer nil ""))) ; "STOPPED" | |
677 (flymake-report-status source-buffer (format "%d/%d" err-count warn-count) "")))) | |
55822 | 678 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
679 (defun flymake-parse-output-and-residual (source-buffer output) |
58515 | 680 "Split OUTPUT into lines, merge in residual if necessary." |
60904
6c1fb526eda5
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60903
diff
changeset
|
681 (with-current-buffer source-buffer |
58515 | 682 (let* ((buffer-residual (flymake-get-buffer-output-residual source-buffer)) |
683 (total-output (if buffer-residual (concat buffer-residual output) output)) | |
684 (lines-and-residual (flymake-split-output total-output)) | |
685 (lines (nth 0 lines-and-residual)) | |
686 (new-residual (nth 1 lines-and-residual))) | |
55822 | 687 |
58515 | 688 (flymake-set-buffer-output-residual source-buffer new-residual) |
689 (flymake-set-buffer-new-err-info source-buffer (flymake-parse-err-lines | |
690 (flymake-get-buffer-new-err-info source-buffer) | |
691 source-buffer lines))))) | |
55822 | 692 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
693 (defun flymake-parse-residual (source-buffer) |
58515 | 694 "Parse residual if it's non empty." |
60904
6c1fb526eda5
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60903
diff
changeset
|
695 (with-current-buffer source-buffer |
58515 | 696 (when (flymake-get-buffer-output-residual source-buffer) |
697 (flymake-set-buffer-new-err-info source-buffer (flymake-parse-err-lines | |
698 (flymake-get-buffer-new-err-info source-buffer) | |
699 source-buffer | |
700 (list (flymake-get-buffer-output-residual source-buffer)))) | |
701 (flymake-set-buffer-output-residual source-buffer nil)))) | |
55822 | 702 |
703 (defvar flymake-err-info nil | |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
704 "Sorted list of line numbers and lists of err info in the form (file, err-text).") |
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
705 |
55822 | 706 (make-variable-buffer-local 'flymake-err-info) |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
707 |
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
708 (defun flymake-get-buffer-err-info (buffer) |
58515 | 709 (flymake-get-buffer-var buffer 'flymake-err-info)) |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
710 |
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
711 (defun flymake-set-buffer-err-info (buffer err-info) |
58515 | 712 (flymake-set-buffer-var buffer 'flymake-err-info err-info)) |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
713 |
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
714 (defun flymake-er-make-er (line-no line-err-info-list) |
58515 | 715 (list line-no line-err-info-list)) |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
716 |
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
717 (defun flymake-er-get-line (err-info) |
58515 | 718 (nth 0 err-info)) |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
719 |
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
720 (defun flymake-er-get-line-err-info-list (err-info) |
58515 | 721 (nth 1 err-info)) |
55822 | 722 |
723 (defvar flymake-new-err-info nil | |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
724 "Same as 'flymake-err-info', effective when a syntax check is in progress.") |
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
725 |
55822 | 726 (make-variable-buffer-local 'flymake-new-err-info) |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
727 |
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
728 (defun flymake-get-buffer-new-err-info (buffer) |
58515 | 729 (flymake-get-buffer-var buffer 'flymake-new-err-info)) |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
730 |
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
731 (defun flymake-set-buffer-new-err-info (buffer new-err-info) |
58515 | 732 (flymake-set-buffer-var buffer 'flymake-new-err-info new-err-info)) |
55822 | 733 |
734 ;; getters/setters for line-err-info: (file, line, type, text). | |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
735 (defun flymake-ler-make-ler (file line type text &optional full-file) |
58515 | 736 (list file line type text full-file)) |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
737 |
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
738 (defun flymake-ler-get-file (line-err-info) |
58515 | 739 (nth 0 line-err-info)) |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
740 |
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
741 (defun flymake-ler-get-line (line-err-info) |
58515 | 742 (nth 1 line-err-info)) |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
743 |
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
744 (defun flymake-ler-get-type (line-err-info) |
58515 | 745 (nth 2 line-err-info)) |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
746 |
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
747 (defun flymake-ler-get-text (line-err-info) |
58515 | 748 (nth 3 line-err-info)) |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
749 |
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
750 (defun flymake-ler-get-full-file (line-err-info) |
58515 | 751 (nth 4 line-err-info)) |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
752 |
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
753 (defun flymake-ler-set-file (line-err-info file) |
58515 | 754 (flymake-ler-make-ler file |
55822 | 755 (flymake-ler-get-line line-err-info) |
756 (flymake-ler-get-type line-err-info) | |
757 (flymake-ler-get-text line-err-info) | |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
758 (flymake-ler-get-full-file line-err-info))) |
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
759 |
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
760 (defun flymake-ler-set-full-file (line-err-info full-file) |
58515 | 761 (flymake-ler-make-ler (flymake-ler-get-file line-err-info) |
55822 | 762 (flymake-ler-get-line line-err-info) |
763 (flymake-ler-get-type line-err-info) | |
764 (flymake-ler-get-text line-err-info) | |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
765 full-file)) |
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
766 |
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
767 (defun flymake-ler-set-line (line-err-info line) |
58515 | 768 (flymake-ler-make-ler (flymake-ler-get-file line-err-info) |
55822 | 769 line |
770 (flymake-ler-get-type line-err-info) | |
771 (flymake-ler-get-text line-err-info) | |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
772 (flymake-ler-get-full-file line-err-info))) |
55822 | 773 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
774 (defun flymake-get-line-err-count (line-err-info-list type) |
58515 | 775 "Return number of errors of specified TYPE. |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
776 Value of TYPE is eigher e or w." |
58515 | 777 (let* ((idx 0) |
778 (count (length line-err-info-list)) | |
779 (err-count 0)) | |
55822 | 780 |
58515 | 781 (while (< idx count) |
782 (when (equal type (flymake-ler-get-type (nth idx line-err-info-list))) | |
783 (setq err-count (1+ err-count))) | |
784 (setq idx (1+ idx))) | |
785 err-count)) | |
55822 | 786 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
787 (defun flymake-get-err-count (err-info-list type) |
58515 | 788 "Return number of errors of specified TYPE for ERR-INFO-LIST." |
789 (let* ((idx 0) | |
790 (count (length err-info-list)) | |
791 (err-count 0)) | |
792 (while (< idx count) | |
793 (setq err-count (+ err-count (flymake-get-line-err-count (nth 1 (nth idx err-info-list)) type))) | |
794 (setq idx (1+ idx))) | |
795 err-count)) | |
55822 | 796 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
797 (defun flymake-fix-line-numbers (err-info-list min-line max-line) |
58515 | 798 "Replace line numbers with fixed value. |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
799 If line-numbers is less than MIN-LINE, set line numbers to MIN-LINE. |
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
800 If line numbers is greater than MAX-LINE, set line numbers to MAX-LINE. |
58561 | 801 The reason for this fix is because some compilers might report |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
802 line number outside the file being compiled." |
58515 | 803 (let* ((count (length err-info-list)) |
804 (err-info nil) | |
805 (line 0)) | |
806 (while (> count 0) | |
807 (setq err-info (nth (1- count) err-info-list)) | |
808 (setq line (flymake-er-get-line err-info)) | |
809 (when (or (< line min-line) (> line max-line)) | |
810 (setq line (if (< line min-line) min-line max-line)) | |
811 (setq err-info-list (flymake-set-at err-info-list (1- count) | |
812 (flymake-er-make-er line | |
813 (flymake-er-get-line-err-info-list err-info))))) | |
814 (setq count (1- count)))) | |
815 err-info-list) | |
55822 | 816 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
817 (defun flymake-highlight-err-lines (buffer err-info-list) |
58515 | 818 "Highlight error lines in BUFFER using info from ERR-INFO-LIST." |
60904
6c1fb526eda5
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60903
diff
changeset
|
819 (with-current-buffer buffer |
58515 | 820 (let* ((idx 0) |
821 (count (length err-info-list))) | |
822 (while (< idx count) | |
823 (flymake-highlight-line (car (nth idx err-info-list)) (nth 1 (nth idx err-info-list))) | |
824 (setq idx (1+ idx)))))) | |
55822 | 825 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
826 (defun flymake-overlay-p (ov) |
58515 | 827 "Determine whether overlay OV was created by flymake." |
828 (and (overlayp ov) (overlay-get ov 'flymake-overlay))) | |
55822 | 829 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
830 (defun flymake-make-overlay (beg end tooltip-text face mouse-face) |
58515 | 831 "Allocate a flymake overlay in range BEG and END." |
832 (when (not (flymake-region-has-flymake-overlays beg end)) | |
833 (let ((ov (make-overlay beg end nil t t))) | |
834 (overlay-put ov 'face face) | |
835 (overlay-put ov 'mouse-face mouse-face) | |
836 (overlay-put ov 'help-echo tooltip-text) | |
837 (overlay-put ov 'flymake-overlay t) | |
838 (overlay-put ov 'priority 100) | |
60903
29db3b79c3fa
Misc fix up of comments and docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58561
diff
changeset
|
839 ;;+(flymake-log 3 "created overlay %s" ov) |
58515 | 840 ov) |
841 (flymake-log 3 "created an overlay at (%d-%d)" beg end))) | |
55822 | 842 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
843 (defun flymake-delete-own-overlays (buffer) |
58515 | 844 "Delete all flymake overlays in BUFFER." |
60904
6c1fb526eda5
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60903
diff
changeset
|
845 (with-current-buffer buffer |
58515 | 846 (let ((ov (overlays-in (point-min) (point-max)))) |
847 (while (consp ov) | |
848 (when (flymake-overlay-p (car ov)) | |
849 (delete-overlay (car ov)) | |
60903
29db3b79c3fa
Misc fix up of comments and docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58561
diff
changeset
|
850 ;;+(flymake-log 3 "deleted overlay %s" ov) |
58515 | 851 ) |
852 (setq ov (cdr ov)))))) | |
55822 | 853 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
854 (defun flymake-region-has-flymake-overlays (beg end) |
58515 | 855 "Check if region specified by BEG and END has overlay. |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
856 Return t if it has at least one flymake overlay, nil if no overlay." |
58515 | 857 (let ((ov (overlays-in beg end)) |
858 (has-flymake-overlays nil)) | |
859 (while (consp ov) | |
860 (when (flymake-overlay-p (car ov)) | |
861 (setq has-flymake-overlays t)) | |
60904
6c1fb526eda5
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60903
diff
changeset
|
862 (setq ov (cdr ov))) |
6c1fb526eda5
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60903
diff
changeset
|
863 has-flymake-overlays)) |
55822 | 864 |
865 (defface flymake-errline-face | |
60903
29db3b79c3fa
Misc fix up of comments and docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58561
diff
changeset
|
866 ;;+ '((((class color)) (:foreground "OrangeRed" :bold t :underline t)) |
29db3b79c3fa
Misc fix up of comments and docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58561
diff
changeset
|
867 ;;+ '((((class color)) (:underline "OrangeRed")) |
58515 | 868 '((((class color)) (:background "LightPink")) |
869 (t (:bold t))) | |
870 "Face used for marking error lines." | |
871 :group 'flymake) | |
55822 | 872 |
873 (defface flymake-warnline-face | |
58515 | 874 '((((class color)) (:background "LightBlue2")) |
875 (t (:bold t))) | |
876 "Face used for marking warning lines." | |
877 :group 'flymake) | |
55822 | 878 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
879 (defun flymake-highlight-line (line-no line-err-info-list) |
58515 | 880 "Highlight line LINE-NO in current buffer. |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
881 Perhaps use text from LINE-ERR-INFO-ILST to enhance highlighting." |
58515 | 882 (goto-line line-no) |
883 (let* ((line-beg (flymake-line-beginning-position)) | |
884 (line-end (flymake-line-end-position)) | |
885 (beg line-beg) | |
886 (end line-end) | |
887 (tooltip-text (flymake-ler-get-text (nth 0 line-err-info-list))) | |
888 (face nil)) | |
55822 | 889 |
58515 | 890 (goto-char line-beg) |
891 (while (looking-at "[ \t]") | |
892 (forward-char)) | |
55822 | 893 |
58515 | 894 (setq beg (point)) |
55822 | 895 |
58515 | 896 (goto-char line-end) |
897 (while (and (looking-at "[ \t\r\n]") (> (point) 1)) | |
898 (backward-char)) | |
55822 | 899 |
58515 | 900 (setq end (1+ (point))) |
55822 | 901 |
58515 | 902 (when (<= end beg) |
903 (setq beg line-beg) | |
904 (setq end line-end)) | |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
905 |
58515 | 906 (when (= end beg) |
907 (goto-char end) | |
908 (forward-line) | |
909 (setq end (point))) | |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
910 |
58515 | 911 (if (> (flymake-get-line-err-count line-err-info-list "e") 0) |
912 (setq face 'flymake-errline-face) | |
913 (setq face 'flymake-warnline-face)) | |
55822 | 914 |
58515 | 915 (flymake-make-overlay beg end tooltip-text face nil))) |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
916 |
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
917 (defun flymake-parse-err-lines (err-info-list source-buffer lines) |
58515 | 918 "Parse err LINES, store info in ERR-INFO-LIST." |
919 (let* ((count (length lines)) | |
920 (idx 0) | |
921 (line-err-info nil) | |
922 (real-file-name nil) | |
923 (source-file-name (buffer-file-name source-buffer)) | |
924 (get-real-file-name-f (flymake-get-real-file-name-function source-file-name))) | |
55822 | 925 |
58515 | 926 (while (< idx count) |
927 (setq line-err-info (flymake-parse-line (nth idx lines))) | |
928 (when line-err-info | |
929 (setq real-file-name (funcall get-real-file-name-f source-buffer (flymake-ler-get-file line-err-info))) | |
930 (setq line-err-info (flymake-ler-set-full-file line-err-info real-file-name)) | |
55822 | 931 |
58515 | 932 (if (flymake-same-files real-file-name source-file-name) |
933 (setq line-err-info (flymake-ler-set-file line-err-info nil)) | |
934 (setq line-err-info (flymake-ler-set-file line-err-info (file-name-nondirectory real-file-name)))) | |
55822 | 935 |
58515 | 936 (setq err-info-list (flymake-add-err-info err-info-list line-err-info))) |
937 (flymake-log 3 "parsed '%s', %s line-err-info" (nth idx lines) (if line-err-info "got" "no")) | |
938 (setq idx (1+ idx))) | |
939 err-info-list)) | |
55822 | 940 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
941 (defun flymake-split-output (output) |
58515 | 942 "Split OUTPUT into lines. |
60903
29db3b79c3fa
Misc fix up of comments and docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58561
diff
changeset
|
943 Return last one as residual if it does not end with newline char. |
29db3b79c3fa
Misc fix up of comments and docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58561
diff
changeset
|
944 Returns ((LINES) RESIDUAL)." |
58515 | 945 (when (and output (> (length output) 0)) |
946 (let* ((lines (flymake-split-string output "[\n\r]+")) | |
947 (complete (equal "\n" (char-to-string (aref output (1- (length output)))))) | |
948 (residual nil)) | |
949 (when (not complete) | |
950 (setq residual (car (last lines))) | |
951 (setq lines (butlast lines))) | |
952 (list lines residual)))) | |
55822 | 953 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
954 (defun flymake-reformat-err-line-patterns-from-compile-el (original-list) |
58515 | 955 "Grab error line patterns from ORIGINAL-LIST in compile.el format. |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
956 Convert it to flymake internal format." |
58515 | 957 (let* ((converted-list '())) |
60904
6c1fb526eda5
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60903
diff
changeset
|
958 (dolist (item original-list) |
6c1fb526eda5
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60903
diff
changeset
|
959 (setq item (cdr item)) |
6c1fb526eda5
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60903
diff
changeset
|
960 (let ((regexp (nth 0 item)) |
6c1fb526eda5
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60903
diff
changeset
|
961 (file (nth 1 item)) |
6c1fb526eda5
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60903
diff
changeset
|
962 (line (nth 2 item)) |
6c1fb526eda5
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60903
diff
changeset
|
963 (col (nth 3 item))) |
6c1fb526eda5
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60903
diff
changeset
|
964 (if (consp file) (setq file (car file))) |
6c1fb526eda5
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60903
diff
changeset
|
965 (if (consp line) (setq line (car line))) |
6c1fb526eda5
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60903
diff
changeset
|
966 (if (consp col) (setq col (car col))) |
61284
fb2f8ebf304e
(flymake-mode): Specify :group.
Lute Kamstra <lute@gnu.org>
parents:
60978
diff
changeset
|
967 |
60904
6c1fb526eda5
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60903
diff
changeset
|
968 (when (not (functionp line)) |
6c1fb526eda5
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60903
diff
changeset
|
969 (setq converted-list (cons (list regexp file line col) converted-list))))) |
58515 | 970 converted-list)) |
57847
4bac9c04ed9e
2004-11-2 Pavel Kobiakov <pk_at_work@yahoo.com>
Masatake YAMATO <jet@gyve.org>
parents:
57696
diff
changeset
|
971 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
972 (eval-when-compile |
58515 | 973 (require 'compile)) |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
974 |
58515 | 975 (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 |
976 (append | |
977 '( | |
60903
29db3b79c3fa
Misc fix up of comments and docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58561
diff
changeset
|
978 ;; MS Visual C++ 6.0 |
58515 | 979 ("\\(\\([a-zA-Z]:\\)?[^:(\t\n]+\\)(\\([0-9]+\\)) \: \\(\\(error\\|warning\\|fatal error\\) \\(C[0-9]+\\):[ \t\n]*\\(.+\\)\\)" |
980 1 3 nil 4) | |
60903
29db3b79c3fa
Misc fix up of comments and docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58561
diff
changeset
|
981 ;; jikes |
58515 | 982 ("\\(\\([a-zA-Z]:\\)?[^:(\t\n]+\\)\:\\([0-9]+\\)\:[0-9]+\:[0-9]+\:[0-9]+\: \\(\\(Error\\|Warning\\|Caution\\|Semantic Error\\):[ \t\n]*\\(.+\\)\\)" |
983 1 3 nil 4) | |
60903
29db3b79c3fa
Misc fix up of comments and docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58561
diff
changeset
|
984 ;; MS midl |
58515 | 985 ("midl[ ]*:[ ]*\\(command line error .*\\)" |
986 nil nil nil 1) | |
60903
29db3b79c3fa
Misc fix up of comments and docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58561
diff
changeset
|
987 ;; MS C# |
58515 | 988 ("\\(\\([a-zA-Z]:\\)?[^:(\t\n]+\\)(\\([0-9]+\\),[0-9]+)\: \\(\\(error\\|warning\\|fatal error\\) \\(CS[0-9]+\\):[ \t\n]*\\(.+\\)\\)" |
989 1 3 nil 4) | |
60903
29db3b79c3fa
Misc fix up of comments and docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58561
diff
changeset
|
990 ;; perl |
58515 | 991 ("\\(.*\\) at \\([^ \n]+\\) line \\([0-9]+\\)[,.\n]" 2 3 nil 1) |
60903
29db3b79c3fa
Misc fix up of comments and docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58561
diff
changeset
|
992 ;; LaTeX warnings (fileless) ("\\(LaTeX \\(Warning\\|Error\\): .*\\) on input line \\([0-9]+\\)" 20 3 nil 1) |
29db3b79c3fa
Misc fix up of comments and docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58561
diff
changeset
|
993 ;; ant/javac |
58515 | 994 (" *\\(\\[javac\\]\\)? *\\(\\([a-zA-Z]:\\)?[^:(\t\n]+\\)\:\\([0-9]+\\)\:[ \t\n]*\\(.+\\)" |
995 2 4 nil 5)) | |
996 ;; compilation-error-regexp-alist) | |
58561 | 997 (flymake-reformat-err-line-patterns-from-compile-el compilation-error-regexp-alist-alist)) |
60903
29db3b79c3fa
Misc fix up of comments and docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58561
diff
changeset
|
998 "Patterns for matching error/warning lines. |
29db3b79c3fa
Misc fix up of comments and docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58561
diff
changeset
|
999 \(REGEXP FILE-IDX LINE-IDX ERR-TEXT-IDX). |
29db3b79c3fa
Misc fix up of comments and docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58561
diff
changeset
|
1000 Use `flymake-reformat-err-line-patterns-from-compile-el' to add patterns |
29db3b79c3fa
Misc fix up of comments and docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58561
diff
changeset
|
1001 from compile.el") |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1002 |
60903
29db3b79c3fa
Misc fix up of comments and docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58561
diff
changeset
|
1003 ;;(defcustom flymake-err-line-patterns |
29db3b79c3fa
Misc fix up of comments and docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58561
diff
changeset
|
1004 ;; '( |
29db3b79c3fa
Misc fix up of comments and docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58561
diff
changeset
|
1005 ;; ; MS Visual C++ 6.0 |
29db3b79c3fa
Misc fix up of comments and docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58561
diff
changeset
|
1006 ;; ("\\(\\([a-zA-Z]:\\)?[^:(\t\n]+\\)(\\([0-9]+\\)) \: \\(\\(error\\|warning\\|fatal error\\) \\(C[0-9]+\\):[ \t\n]*\\(.+\\)\\)" |
29db3b79c3fa
Misc fix up of comments and docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58561
diff
changeset
|
1007 ;; 1 3 4) |
29db3b79c3fa
Misc fix up of comments and docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58561
diff
changeset
|
1008 ;; ; jikes |
29db3b79c3fa
Misc fix up of comments and docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58561
diff
changeset
|
1009 ;; ("\\(\\([a-zA-Z]:\\)?[^:(\t\n]+\\)\:\\([0-9]+\\)\:[0-9]+\:[0-9]+\:[0-9]+\: \\(\\(Error\\|Warning\\|Caution\\):[ \t\n]*\\(.+\\)\\)" |
29db3b79c3fa
Misc fix up of comments and docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58561
diff
changeset
|
1010 ;; 1 3 4)) |
29db3b79c3fa
Misc fix up of comments and docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58561
diff
changeset
|
1011 ;; "patterns for matching error/warning lines, (regexp file-idx line-idx err-text-idx)" |
29db3b79c3fa
Misc fix up of comments and docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58561
diff
changeset
|
1012 ;; :group 'flymake |
29db3b79c3fa
Misc fix up of comments and docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58561
diff
changeset
|
1013 ;; :type '(repeat (string number number number)) |
29db3b79c3fa
Misc fix up of comments and docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58561
diff
changeset
|
1014 ;;) |
55822 | 1015 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1016 (defun flymake-parse-line (line) |
58515 | 1017 "Parse LINE to see if it is an error of warning. |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1018 Return its components if so, nil if no." |
58515 | 1019 (let ((raw-file-name nil) |
1020 (line-no 0) | |
1021 (err-type "e") | |
1022 (err-text nil) | |
60906
9b761ddc6f4b
(flymake-get-file-name-mode-and-masks)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60905
diff
changeset
|
1023 (patterns flymake-err-line-patterns) |
58515 | 1024 (matched nil)) |
60906
9b761ddc6f4b
(flymake-get-file-name-mode-and-masks)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60905
diff
changeset
|
1025 (while (and patterns (not matched)) |
9b761ddc6f4b
(flymake-get-file-name-mode-and-masks)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60905
diff
changeset
|
1026 (when (string-match (car (car patterns)) line) |
9b761ddc6f4b
(flymake-get-file-name-mode-and-masks)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60905
diff
changeset
|
1027 (let* ((file-idx (nth 1 (car patterns))) |
9b761ddc6f4b
(flymake-get-file-name-mode-and-masks)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60905
diff
changeset
|
1028 (line-idx (nth 2 (car patterns)))) |
55822 | 1029 |
58515 | 1030 (setq raw-file-name (if file-idx (match-string file-idx line) nil)) |
1031 (setq line-no (if line-idx (string-to-int (match-string line-idx line)) 0)) | |
60906
9b761ddc6f4b
(flymake-get-file-name-mode-and-masks)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60905
diff
changeset
|
1032 (setq err-text (if (> (length (car patterns)) 4) |
9b761ddc6f4b
(flymake-get-file-name-mode-and-masks)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60905
diff
changeset
|
1033 (match-string (nth 4 (car patterns)) line) |
58515 | 1034 (flymake-patch-err-text (substring line (match-end 0))))) |
1035 (or err-text (setq err-text "<no error text>")) | |
1036 (if (and err-text (string-match "^[wW]arning" err-text)) | |
1037 (setq err-type "w") | |
1038 ) | |
1039 (flymake-log 3 "parse line: file-idx=%s line-idx=%s file=%s line=%s text=%s" file-idx line-idx | |
1040 raw-file-name line-no err-text) | |
1041 (setq matched t))) | |
60906
9b761ddc6f4b
(flymake-get-file-name-mode-and-masks)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60905
diff
changeset
|
1042 (setq patterns (cdr patterns))) |
58515 | 1043 (if matched |
1044 (flymake-ler-make-ler raw-file-name line-no err-type err-text) | |
1045 ()))) | |
55822 | 1046 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1047 (defun flymake-find-err-info (err-info-list line-no) |
58515 | 1048 "Find (line-err-info-list pos) for specified LINE-NO." |
1049 (if err-info-list | |
1050 (let* ((line-err-info-list nil) | |
1051 (pos 0) | |
1052 (count (length err-info-list))) | |
55822 | 1053 |
58515 | 1054 (while (and (< pos count) (< (car (nth pos err-info-list)) line-no)) |
1055 (setq pos (1+ pos))) | |
1056 (when (and (< pos count) (equal (car (nth pos err-info-list)) line-no)) | |
1057 (setq line-err-info-list (flymake-er-get-line-err-info-list (nth pos err-info-list)))) | |
1058 (list line-err-info-list pos)) | |
1059 '(nil 0))) | |
55822 | 1060 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1061 (defun flymake-line-err-info-is-less-or-equal (line-one line-two) |
58515 | 1062 (or (string< (flymake-ler-get-type line-one) (flymake-ler-get-type line-two)) |
1063 (and (string= (flymake-ler-get-type line-one) (flymake-ler-get-type line-two)) | |
1064 (not (flymake-ler-get-file line-one)) (flymake-ler-get-file line-two)) | |
1065 (and (string= (flymake-ler-get-type line-one) (flymake-ler-get-type line-two)) | |
1066 (or (and (flymake-ler-get-file line-one) (flymake-ler-get-file line-two)) | |
1067 (and (not (flymake-ler-get-file line-one)) (not (flymake-ler-get-file line-two))))))) | |
55822 | 1068 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1069 (defun flymake-add-line-err-info (line-err-info-list line-err-info) |
58515 | 1070 "Insert new err info favoring sorting: err-type e/w, filename nil/non-nil." |
1071 (if (not line-err-info-list) | |
1072 (list line-err-info) | |
1073 (let* ((count (length line-err-info-list)) | |
1074 (idx 0)) | |
1075 (while (and (< idx count) (flymake-line-err-info-is-less-or-equal (nth idx line-err-info-list) line-err-info)) | |
1076 (setq idx (1+ idx))) | |
1077 (cond ((equal 0 idx) (setq line-err-info-list (cons line-err-info line-err-info-list))) | |
1078 (t (setq line-err-info-list (flymake-ins-after line-err-info-list (1- idx) line-err-info)))) | |
1079 line-err-info-list))) | |
55822 | 1080 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1081 (defun flymake-add-err-info (err-info-list line-err-info) |
58515 | 1082 "Add error info (file line type text) to err info list preserving sort order." |
60905
6611fdf35049
(flymake-ensure-ends-with-slash): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60904
diff
changeset
|
1083 (let* ((line-no (if (flymake-ler-get-file line-err-info) 1 (flymake-ler-get-line line-err-info))) |
58515 | 1084 (info-and-pos (flymake-find-err-info err-info-list line-no)) |
1085 (exists (car info-and-pos)) | |
1086 (pos (nth 1 info-and-pos)) | |
1087 (line-err-info-list nil) | |
1088 (err-info nil)) | |
55822 | 1089 |
58515 | 1090 (if exists |
1091 (setq line-err-info-list (flymake-er-get-line-err-info-list (car (nthcdr pos err-info-list))))) | |
1092 (setq line-err-info-list (flymake-add-line-err-info line-err-info-list line-err-info)) | |
55822 | 1093 |
58515 | 1094 (setq err-info (flymake-er-make-er line-no line-err-info-list)) |
1095 (cond (exists (setq err-info-list (flymake-set-at err-info-list pos err-info))) | |
1096 ((equal 0 pos) (setq err-info-list (cons err-info err-info-list))) | |
1097 (t (setq err-info-list (flymake-ins-after err-info-list (1- pos) err-info)))) | |
1098 err-info-list)) | |
55822 | 1099 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1100 (defun flymake-get-project-include-dirs-imp (basedir) |
58515 | 1101 "Include dirs for the project current file belongs to." |
1102 (if (flymake-get-project-include-dirs-from-cache basedir) | |
1103 (progn | |
1104 (flymake-get-project-include-dirs-from-cache basedir)) | |
60903
29db3b79c3fa
Misc fix up of comments and docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58561
diff
changeset
|
1105 ;;else |
58515 | 1106 (let* ((command-line (concat "make -C\"" basedir "\" DUMPVARS=INCLUDE_DIRS dumpvars")) |
1107 (output (shell-command-to-string command-line)) | |
1108 (lines (flymake-split-string output "\n")) | |
1109 (count (length lines)) | |
1110 (idx 0) | |
1111 (inc-dirs nil)) | |
1112 (while (and (< idx count) (not (string-match "^INCLUDE_DIRS=.*" (nth idx lines)))) | |
1113 (setq idx (1+ idx))) | |
1114 (when (< idx count) | |
1115 (let* ((inc-lines (flymake-split-string (nth idx lines) " *-I")) | |
1116 (inc-count (length inc-lines))) | |
1117 (while (> inc-count 0) | |
1118 (when (not (string-match "^INCLUDE_DIRS=.*" (nth (1- inc-count) inc-lines))) | |
1119 (setq inc-dirs (cons (flymake-replace-regexp-in-string "\"" "" (nth (1- inc-count) inc-lines)) inc-dirs))) | |
1120 (setq inc-count (1- inc-count))))) | |
1121 (flymake-add-project-include-dirs-to-cache basedir inc-dirs) | |
1122 inc-dirs))) | |
55822 | 1123 |
1124 (defcustom flymake-get-project-include-dirs-function 'flymake-get-project-include-dirs-imp | |
58515 | 1125 "Function used to get project inc dirs, one paramater: basedir name." |
1126 :group 'flymake | |
1127 :type 'function) | |
55822 | 1128 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1129 (defun flymake-get-project-include-dirs (basedir) |
58515 | 1130 (funcall flymake-get-project-include-dirs-function basedir)) |
55822 | 1131 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1132 (defun flymake-get-system-include-dirs () |
58515 | 1133 "System include dirs - from the 'INCLUDE' env setting." |
1134 (let* ((includes (getenv "INCLUDE"))) | |
1135 (if includes (flymake-split-string includes path-separator) nil))) | |
55822 | 1136 |
1137 (defvar flymake-project-include-dirs-cache (flymake-makehash 'equal)) | |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1138 |
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1139 (defun flymake-get-project-include-dirs-from-cache (base-dir) |
58515 | 1140 (gethash base-dir flymake-project-include-dirs-cache)) |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1141 |
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1142 (defun flymake-add-project-include-dirs-to-cache (base-dir include-dirs) |
58515 | 1143 (puthash base-dir include-dirs flymake-project-include-dirs-cache)) |
55822 | 1144 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1145 (defun flymake-clear-project-include-dirs-cache () |
58515 | 1146 (clrhash flymake-project-include-dirs-cache)) |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1147 |
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1148 (defun flymake-get-include-dirs (base-dir) |
58515 | 1149 "Get dirs to use when resolving local file names." |
1150 (let* ((include-dirs (append '(".") (flymake-get-project-include-dirs base-dir) (flymake-get-system-include-dirs)))) | |
1151 include-dirs)) | |
55822 | 1152 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1153 (defun flymake-find-file (rel-file-name include-dirs) |
58515 | 1154 "Iterate through include-dirs to find file REL-FILE-NAME. |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1155 Return first 'INCLUDE-DIRS/REL-FILE-NAME' that exists, or just REL-FILE-NAME if not." |
58515 | 1156 (let* ((count (length include-dirs)) |
1157 (idx 0) | |
1158 (found nil) | |
1159 (full-file-name rel-file-name)) | |
55822 | 1160 |
58515 | 1161 (while (and (not found) (< idx count)) |
1162 (let* ((dir (nth idx include-dirs))) | |
1163 (setq full-file-name (concat dir "/" rel-file-name)) | |
1164 (when (file-exists-p full-file-name) | |
1165 (setq found t))) | |
1166 (setq idx (1+ idx))) | |
1167 (if found | |
1168 full-file-name | |
1169 rel-file-name))) | |
55822 | 1170 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1171 (defun flymake-restore-formatting (source-buffer) |
58515 | 1172 "Remove any formatting made by flymake." |
1173 ) | |
55822 | 1174 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1175 (defun flymake-get-program-dir (buffer) |
58515 | 1176 "Get dir to start program in." |
1177 (unless (bufferp buffer) | |
60904
6c1fb526eda5
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60903
diff
changeset
|
1178 (error "Invalid buffer")) |
6c1fb526eda5
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60903
diff
changeset
|
1179 (with-current-buffer buffer |
58515 | 1180 default-directory)) |
55822 | 1181 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1182 (defun flymake-safe-delete-file (file-name) |
58515 | 1183 (when (and file-name (file-exists-p file-name)) |
1184 (delete-file file-name) | |
1185 (flymake-log 1 "deleted file %s" file-name))) | |
55822 | 1186 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1187 (defun flymake-safe-delete-directory (dir-name) |
58515 | 1188 (condition-case err |
1189 (progn | |
1190 (delete-directory dir-name) | |
1191 (flymake-log 1 "deleted dir %s" dir-name)) | |
1192 (error | |
1193 (flymake-log 1 "Failed to delete dir %s, error ignored" dir-name)))) | |
55822 | 1194 |
58561 | 1195 (defcustom flymake-compilation-prevents-syntax-check t |
58515 | 1196 "If non-nil, syntax check won't be started in case compilation is running." |
1197 :group 'flymake | |
1198 :type 'boolean) | |
55822 | 1199 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1200 (defun flymake-start-syntax-check (buffer) |
58515 | 1201 "Start syntax checking for buffer BUFFER." |
1202 (unless (bufferp buffer) | |
1203 (error "Expected a buffer")) | |
60904
6c1fb526eda5
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60903
diff
changeset
|
1204 (with-current-buffer buffer |
58515 | 1205 (flymake-log 3 "flymake is running: %s" (flymake-get-buffer-is-running buffer)) |
1206 (when (and (not (flymake-get-buffer-is-running buffer)) | |
1207 (flymake-can-syntax-check-file (buffer-file-name buffer))) | |
1208 (when (or (not flymake-compilation-prevents-syntax-check) | |
1209 (not (flymake-compilation-is-running))) ;+ (flymake-rep-ort-status buffer "COMP") | |
1210 (flymake-clear-buildfile-cache) | |
1211 (flymake-clear-project-include-dirs-cache) | |
55822 | 1212 |
58515 | 1213 (flymake-set-buffer-check-was-interrupted buffer nil) |
1214 (flymake-set-buffer-data buffer (flymake-makehash 'equal)) | |
55822 | 1215 |
58515 | 1216 (let* ((source-file-name (buffer-file-name buffer)) |
1217 (init-f (flymake-get-init-function source-file-name)) | |
1218 (cleanup-f (flymake-get-cleanup-function source-file-name)) | |
1219 (cmd-and-args (funcall init-f buffer)) | |
1220 (cmd (nth 0 cmd-and-args)) | |
1221 (args (nth 1 cmd-and-args)) | |
1222 (dir (nth 2 cmd-and-args))) | |
1223 (if (not cmd-and-args) | |
1224 (progn | |
1225 (flymake-log 0 "init function %s for %s failed, cleaning up" init-f source-file-name) | |
1226 (funcall cleanup-f buffer)) | |
1227 (progn | |
1228 (flymake-set-buffer-last-change-time buffer nil) | |
1229 (flymake-start-syntax-check-process buffer cmd args dir)))))))) | |
55822 | 1230 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1231 (defun flymake-start-syntax-check-process (buffer cmd args dir) |
58515 | 1232 "Start syntax check process." |
1233 (let* ((process nil)) | |
1234 (condition-case err | |
1235 (progn | |
1236 (when dir | |
1237 (let ((default-directory dir)) | |
1238 (flymake-log 3 "starting process on dir %s" default-directory))) | |
1239 (setq process (get-process (apply 'start-process "flymake-proc" nil cmd args))) | |
1240 (set-process-sentinel process 'flymake-process-sentinel) | |
1241 (set-process-filter process 'flymake-process-filter) | |
55822 | 1242 |
58515 | 1243 (flymake-reg-names (process-id process) (buffer-name buffer)) |
55822 | 1244 |
58515 | 1245 (flymake-set-buffer-is-running buffer t) |
1246 (flymake-set-buffer-last-change-time buffer nil) | |
1247 (flymake-set-buffer-check-start-time buffer (flymake-float-time)) | |
55822 | 1248 |
58515 | 1249 (flymake-report-status buffer nil "*") |
1250 (flymake-log 2 "started process %d, command=%s, dir=%s" | |
1251 (process-id process) (process-command process) default-directory) | |
1252 process) | |
1253 (error | |
1254 (let* ((err-str (format "Failed to launch syntax check process '%s' with args %s: %s" | |
1255 cmd args (error-message-string err))) | |
1256 (source-file-name (buffer-file-name buffer)) | |
1257 (cleanup-f (flymake-get-cleanup-function source-file-name))) | |
1258 (flymake-log 0 err-str) | |
1259 (funcall cleanup-f buffer) | |
1260 (flymake-report-fatal-status buffer "PROCERR" err-str)))))) | |
55822 | 1261 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1262 (defun flymake-kill-process (pid &optional rest) |
58515 | 1263 "Kill process PID." |
1264 (signal-process pid 9) | |
1265 (let* ((buffer-name (flymake-get-source-buffer-name pid))) | |
1266 (when (and buffer-name (get-buffer buffer-name)) | |
1267 (flymake-set-buffer-check-was-interrupted (get-buffer buffer-name) t))) | |
1268 (flymake-log 1 "killed process %d" pid)) | |
55822 | 1269 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1270 (defun flymake-stop-all-syntax-checks () |
58515 | 1271 "Kill all syntax check processes." |
1272 (interactive) | |
1273 (let ((pids (copy-hash-table flymake-pid-to-names))) | |
1274 (maphash 'flymake-kill-process pids))) | |
55822 | 1275 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1276 (defun flymake-compilation-is-running () |
58515 | 1277 (and (boundp 'compilation-in-progress) |
1278 compilation-in-progress)) | |
55822 | 1279 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1280 (defun flymake-compile () |
58515 | 1281 "Kill all flymake syntax checks, start compilation." |
1282 (interactive) | |
1283 (flymake-stop-all-syntax-checks) | |
1284 (call-interactively 'compile)) | |
55822 | 1285 |
1286 (defvar flymake-is-running nil | |
60903
29db3b79c3fa
Misc fix up of comments and docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58561
diff
changeset
|
1287 "If t, flymake syntax check process is running for the current buffer.") |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1288 |
55822 | 1289 (make-variable-buffer-local 'flymake-is-running) |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1290 |
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1291 (defun flymake-get-buffer-is-running (buffer) |
58515 | 1292 (flymake-get-buffer-var buffer 'flymake-is-running)) |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1293 |
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1294 (defun flymake-set-buffer-is-running (buffer is-running) |
58515 | 1295 (flymake-set-buffer-var buffer 'flymake-is-running is-running)) |
55822 | 1296 |
1297 (defvar flymake-timer nil | |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1298 "Timer for starting syntax check.") |
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1299 |
55822 | 1300 (make-variable-buffer-local 'flymake-timer) |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1301 |
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1302 (defun flymake-get-buffer-timer (buffer) |
58515 | 1303 (flymake-get-buffer-var buffer 'flymake-timer)) |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1304 |
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1305 (defun flymake-set-buffer-timer (buffer timer) |
58515 | 1306 (flymake-set-buffer-var buffer 'flymake-timer timer)) |
55822 | 1307 |
1308 (defvar flymake-last-change-time nil | |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1309 "Time of last buffer change.") |
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1310 |
55822 | 1311 (make-variable-buffer-local 'flymake-last-change-time) |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1312 |
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1313 (defun flymake-get-buffer-last-change-time (buffer) |
58515 | 1314 (flymake-get-buffer-var buffer 'flymake-last-change-time)) |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1315 |
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1316 (defun flymake-set-buffer-last-change-time (buffer change-time) |
58515 | 1317 (flymake-set-buffer-var buffer 'flymake-last-change-time change-time)) |
55822 | 1318 |
1319 (defvar flymake-check-start-time nil | |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1320 "Time at which syntax check was started.") |
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1321 |
55822 | 1322 (make-variable-buffer-local 'flymake-check-start-time) |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1323 |
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1324 (defun flymake-get-buffer-check-start-time (buffer) |
58515 | 1325 (flymake-get-buffer-var buffer 'flymake-check-start-time)) |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1326 |
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1327 (defun flymake-set-buffer-check-start-time (buffer check-start-time) |
58515 | 1328 (flymake-set-buffer-var buffer 'flymake-check-start-time check-start-time)) |
55822 | 1329 |
1330 (defvar flymake-check-was-interrupted nil | |
60903
29db3b79c3fa
Misc fix up of comments and docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58561
diff
changeset
|
1331 "Non-nil if syntax check was killed by `flymake-compile'.") |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1332 |
55822 | 1333 (make-variable-buffer-local 'flymake-check-was-interrupted) |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1334 |
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1335 (defun flymake-get-buffer-check-was-interrupted (buffer) |
58515 | 1336 (flymake-get-buffer-var buffer 'flymake-check-was-interrupted)) |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1337 |
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1338 (defun flymake-set-buffer-check-was-interrupted (buffer interrupted) |
58515 | 1339 (flymake-set-buffer-var buffer 'flymake-check-was-interrupted interrupted)) |
55822 | 1340 |
1341 (defcustom flymake-no-changes-timeout 0.5 | |
58515 | 1342 "Time to wait after last change before starting compilation." |
1343 :group 'flymake | |
1344 :type 'number) | |
55822 | 1345 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1346 (defun flymake-on-timer-event (buffer) |
58515 | 1347 "Start a syntax check for buffer BUFFER if necessary." |
60903
29db3b79c3fa
Misc fix up of comments and docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58561
diff
changeset
|
1348 ;;+(flymake-log 3 "timer: running=%s, time=%s, cur-time=%s" (flymake-get-buffer-is-running buffer) (flymake-get-buffer-last-change-time buffer) (flymake-float-time)) |
58515 | 1349 (when (and (bufferp buffer) (not (flymake-get-buffer-is-running buffer))) |
60904
6c1fb526eda5
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60903
diff
changeset
|
1350 (with-current-buffer buffer |
58515 | 1351 (when (and (flymake-get-buffer-last-change-time buffer) |
1352 (> (flymake-float-time) (+ flymake-no-changes-timeout (flymake-get-buffer-last-change-time buffer)))) | |
1353 (flymake-set-buffer-last-change-time buffer nil) | |
1354 (flymake-log 3 "starting syntax check as more than 1 second passed since last change") | |
1355 (flymake-start-syntax-check buffer))))) | |
55822 | 1356 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1357 (defun flymake-start-syntax-check-for-current-buffer () |
58515 | 1358 "Run 'flymake-start-syntax-check' for current buffer if it isn't already running." |
1359 (interactive) | |
1360 (flymake-start-syntax-check (current-buffer))) | |
55822 | 1361 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1362 (defun flymake-current-line-no () |
58515 | 1363 "Return number of current line in current buffer." |
1364 (interactive) | |
1365 (let ((beg (point-min)) | |
1366 (end (if (= (point) (point-max)) (point) (1+ (point))))) | |
1367 (count-lines beg end))) | |
55822 | 1368 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1369 (defun flymake-count-lines (buffer) |
58515 | 1370 "Return number of lines in buffer BUFFER." |
60904
6c1fb526eda5
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60903
diff
changeset
|
1371 (with-current-buffer buffer |
58515 | 1372 (count-lines (point-min) (point-max)))) |
55822 | 1373 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1374 (defun flymake-get-point-pixel-pos () |
58515 | 1375 "Return point position in pixels: (x, y)." |
1376 (let ((mouse-pos (mouse-position)) | |
1377 (pixel-pos nil) | |
1378 (ret nil)) | |
1379 (if (car (cdr mouse-pos)) | |
1380 (progn | |
1381 (set-mouse-position (flymake-selected-frame) (current-column) (flymake-current-row)) | |
1382 (setq pixel-pos (mouse-pixel-position)) | |
1383 (set-mouse-position (car mouse-pos) (car (cdr mouse-pos)) (cdr (cdr mouse-pos))) | |
1384 (setq ret (list (car (cdr pixel-pos)) (cdr (cdr pixel-pos))))) | |
1385 (progn | |
1386 (setq ret '(0 0)))) | |
1387 (flymake-log 3 "mouse pos is %s" ret) | |
1388 ret)) | |
55822 | 1389 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1390 (defun flymake-display-err-menu-for-current-line () |
58515 | 1391 "Display a menu with errors/warnings for current line if it has errors and/or warnings." |
1392 (interactive) | |
1393 (let* ((line-no (flymake-current-line-no)) | |
1394 (line-err-info-list (nth 0 (flymake-find-err-info (flymake-get-buffer-err-info (current-buffer)) line-no))) | |
1395 (menu-data (flymake-make-err-menu-data line-no line-err-info-list)) | |
1396 (choice nil) | |
1397 (mouse-pos (flymake-get-point-pixel-pos)) | |
1398 (menu-pos (list (flymake-get-point-pixel-pos) (selected-window)))) | |
1399 (if menu-data | |
1400 (progn | |
1401 (setq choice (flymake-popup-menu menu-pos menu-data)) | |
1402 (flymake-log 3 "choice=%s" choice) | |
1403 (when choice | |
1404 (eval choice))) | |
1405 (flymake-log 1 "no errors for line %d" line-no)))) | |
55822 | 1406 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1407 (defun flymake-make-err-menu-data (line-no line-err-info-list) |
58515 | 1408 "Make a (menu-title (item-title item-action)*) list with errors/warnings from line-err-info." |
1409 (let* ((menu-items nil)) | |
1410 (when line-err-info-list | |
1411 (let* ((count (length line-err-info-list)) | |
1412 (menu-item-text nil)) | |
1413 (while (> count 0) | |
1414 (setq menu-item-text (flymake-ler-get-text (nth (1- count) line-err-info-list))) | |
1415 (let* ((file (flymake-ler-get-file (nth (1- count) line-err-info-list))) | |
1416 (full-file (flymake-ler-get-full-file (nth (1- count) line-err-info-list))) | |
1417 (line (flymake-ler-get-line (nth (1- count) line-err-info-list)))) | |
1418 (if file | |
1419 (setq menu-item-text (concat menu-item-text " - " file "(" (format "%d" line) ")"))) | |
1420 (setq menu-items (cons (list menu-item-text | |
1421 (if file (list 'flymake-goto-file-and-line full-file line) nil)) | |
1422 menu-items))) | |
1423 (setq count (1- count))) | |
1424 (flymake-log 3 "created menu-items with %d item(s)" (length menu-items)))) | |
1425 (if menu-items | |
1426 (let* ((menu-title (format "Line %d: %d error(s), %d warning(s)" line-no | |
1427 (flymake-get-line-err-count line-err-info-list "e") | |
1428 (flymake-get-line-err-count line-err-info-list "w")))) | |
1429 (list menu-title menu-items)) | |
1430 nil))) | |
55822 | 1431 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1432 (defun flymake-goto-file-and-line (file line) |
60903
29db3b79c3fa
Misc fix up of comments and docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58561
diff
changeset
|
1433 "Try to get buffer for FILE and goto line LINE in it." |
58515 | 1434 (if (not (file-exists-p file)) |
1435 (flymake-log 1 "file %s does not exists" file) | |
1436 (progn | |
1437 (find-file file) | |
1438 (goto-line line)))) | |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1439 |
55822 | 1440 ;; flymake minor mode declarations |
60905
6611fdf35049
(flymake-ensure-ends-with-slash): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60904
diff
changeset
|
1441 (defvar flymake-mode-line nil) |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1442 |
55822 | 1443 (make-variable-buffer-local 'flymake-mode-line) |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1444 |
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1445 (defun flymake-get-buffer-mode-line (buffer) |
58515 | 1446 (flymake-get-buffer-var buffer 'flymake-mode-line)) |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1447 |
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1448 (defun flymake-set-buffer-mode-line (buffer mode-line-string) |
58515 | 1449 (flymake-set-buffer-var buffer 'flymake-mode-line mode-line-string)) |
55822 | 1450 |
1451 (defvar flymake-mode-line-e-w nil) | |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1452 |
55822 | 1453 (make-variable-buffer-local 'flymake-mode-line-e-w) |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1454 |
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1455 (defun flymake-get-buffer-mode-line-e-w (buffer) |
58515 | 1456 (flymake-get-buffer-var buffer 'flymake-mode-line-e-w)) |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1457 |
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1458 (defun flymake-set-buffer-mode-line-e-w (buffer e-w) |
58515 | 1459 (flymake-set-buffer-var buffer 'flymake-mode-line-e-w e-w)) |
55822 | 1460 |
1461 (defvar flymake-mode-line-status nil) | |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1462 |
55822 | 1463 (make-variable-buffer-local 'flymake-mode-line-status) |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1464 |
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1465 (defun flymake-get-buffer-mode-line-status (buffer) |
58515 | 1466 (flymake-get-buffer-var buffer 'flymake-mode-line-status)) |
55822 | 1467 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1468 (defun flymake-set-buffer-mode-line-status (buffer status) |
58515 | 1469 (flymake-set-buffer-var buffer 'flymake-mode-line-status status)) |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1470 |
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1471 (defun flymake-report-status (buffer e-w &optional status) |
58515 | 1472 "Show status in mode line." |
1473 (when (bufferp buffer) | |
60904
6c1fb526eda5
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60903
diff
changeset
|
1474 (with-current-buffer buffer |
58515 | 1475 (when e-w |
1476 (flymake-set-buffer-mode-line-e-w buffer e-w) | |
1477 ) | |
1478 (when status | |
1479 (flymake-set-buffer-mode-line-status buffer status)) | |
1480 (let* ((mode-line " Flymake")) | |
1481 (when (> (length (flymake-get-buffer-mode-line-e-w buffer)) 0) | |
1482 (setq mode-line (concat mode-line ":" (flymake-get-buffer-mode-line-e-w buffer)))) | |
1483 (setq mode-line (concat mode-line (flymake-get-buffer-mode-line-status buffer))) | |
1484 (flymake-set-buffer-mode-line buffer mode-line) | |
1485 (force-mode-line-update))))) | |
55822 | 1486 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1487 (defun flymake-display-warning (warning) |
58515 | 1488 "Display a warning to user." |
1489 (message-box warning)) | |
55822 | 1490 |
1491 (defcustom flymake-gui-warnings-enabled t | |
58515 | 1492 "Enables/disables gui warnings." |
1493 :group 'flymake | |
1494 :type 'boolean) | |
55822 | 1495 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1496 (defun flymake-report-fatal-status (buffer status warning) |
58515 | 1497 "Display a warning and switch flymake mode off." |
1498 (when flymake-gui-warnings-enabled | |
1499 (flymake-display-warning (format "Flymake: %s. Flymake will be switched OFF" warning)) | |
1500 ) | |
60904
6c1fb526eda5
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60903
diff
changeset
|
1501 (with-current-buffer buffer |
58515 | 1502 (flymake-mode 0) |
1503 (flymake-log 0 "switched OFF Flymake mode for buffer %s due to fatal status %s, warning %s" | |
1504 (buffer-name buffer) status warning))) | |
55822 | 1505 |
60978
d22b1a318941
(flymake-mode): Add autoload cookie.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60906
diff
changeset
|
1506 ;;;###autoload |
60905
6611fdf35049
(flymake-ensure-ends-with-slash): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60904
diff
changeset
|
1507 (define-minor-mode flymake-mode |
6611fdf35049
(flymake-ensure-ends-with-slash): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60904
diff
changeset
|
1508 "Minor mode to do on-the-fly syntax checking. |
6611fdf35049
(flymake-ensure-ends-with-slash): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60904
diff
changeset
|
1509 When called interactively, toggles the minor mode. |
6611fdf35049
(flymake-ensure-ends-with-slash): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60904
diff
changeset
|
1510 With arg, turn Flymake mode on if and only if arg is positive." |
61284
fb2f8ebf304e
(flymake-mode): Specify :group.
Lute Kamstra <lute@gnu.org>
parents:
60978
diff
changeset
|
1511 :group 'flymake :lighter flymake-mode-line |
60905
6611fdf35049
(flymake-ensure-ends-with-slash): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60904
diff
changeset
|
1512 (if flymake-mode |
6611fdf35049
(flymake-ensure-ends-with-slash): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60904
diff
changeset
|
1513 (if (flymake-can-syntax-check-file (buffer-file-name)) |
6611fdf35049
(flymake-ensure-ends-with-slash): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60904
diff
changeset
|
1514 (flymake-mode-on) |
6611fdf35049
(flymake-ensure-ends-with-slash): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60904
diff
changeset
|
1515 (flymake-log 2 "flymake cannot check syntax in buffer %s" (buffer-name))) |
6611fdf35049
(flymake-ensure-ends-with-slash): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60904
diff
changeset
|
1516 (flymake-mode-off))) |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1517 |
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1518 (defcustom flymake-start-syntax-check-on-find-file t |
58515 | 1519 "Start syntax check on find file." |
1520 :group 'flymake | |
1521 :type 'boolean) | |
55822 | 1522 |
1523 ;;;###autoload | |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1524 (defun flymake-mode-on () |
58515 | 1525 "Turn flymake mode on." |
1526 (when (not flymake-mode) | |
1527 (make-local-variable 'after-change-functions) | |
1528 (setq after-change-functions (cons 'flymake-after-change-function after-change-functions)) | |
1529 (add-hook 'after-save-hook 'flymake-after-save-hook) | |
1530 (add-hook 'kill-buffer-hook 'flymake-kill-buffer-hook) | |
60903
29db3b79c3fa
Misc fix up of comments and docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58561
diff
changeset
|
1531 ;;+(add-hook 'find-file-hook 'flymake-find-file-hook) |
55822 | 1532 |
58515 | 1533 (flymake-report-status (current-buffer) "" "") |
55822 | 1534 |
58515 | 1535 (flymake-set-buffer-timer (current-buffer) (run-at-time nil 1 'flymake-on-timer-event (current-buffer))) |
55822 | 1536 |
58515 | 1537 (setq flymake-mode t) |
1538 (flymake-log 1 "flymake mode turned ON for buffer %s" (buffer-name (current-buffer))) | |
1539 (when flymake-start-syntax-check-on-find-file | |
1540 (flymake-start-syntax-check-for-current-buffer)))) ; will be started by on-load hook | |
55822 | 1541 |
1542 ;;;###autoload | |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1543 (defun flymake-mode-off () |
58515 | 1544 "Turn flymake mode off." |
1545 (when flymake-mode | |
1546 (setq after-change-functions (delq 'flymake-after-change-function after-change-functions)) | |
1547 (remove-hook 'after-save-hook (function flymake-after-save-hook) t) | |
1548 (remove-hook 'kill-buffer-hook (function flymake-kill-buffer-hook) t) | |
60903
29db3b79c3fa
Misc fix up of comments and docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58561
diff
changeset
|
1549 ;;+(remove-hook 'find-file-hook (function flymake-find-file-hook) t) |
55822 | 1550 |
58515 | 1551 (flymake-delete-own-overlays (current-buffer)) |
55822 | 1552 |
58515 | 1553 (when (flymake-get-buffer-timer (current-buffer)) |
1554 (cancel-timer (flymake-get-buffer-timer (current-buffer))) | |
1555 (flymake-set-buffer-timer (current-buffer) nil)) | |
55822 | 1556 |
58515 | 1557 (flymake-set-buffer-is-running (current-buffer) nil) |
55822 | 1558 |
58515 | 1559 (setq flymake-mode nil) |
1560 (flymake-log 1 "flymake mode turned OFF for buffer %s" (buffer-name (current-buffer))))) | |
55822 | 1561 |
1562 (defcustom flymake-start-syntax-check-on-newline t | |
58515 | 1563 "Start syntax check if newline char was added/removed from the buffer." |
1564 :group 'flymake | |
1565 :type 'boolean) | |
55822 | 1566 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1567 (defun flymake-after-change-function (start stop len) |
60903
29db3b79c3fa
Misc fix up of comments and docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58561
diff
changeset
|
1568 "Start syntax check for current buffer if it isn't already running." |
29db3b79c3fa
Misc fix up of comments and docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58561
diff
changeset
|
1569 ;;+(flymake-log 0 "setting change time to %s" (flymake-float-time)) |
58515 | 1570 (let((new-text (buffer-substring start stop))) |
1571 (when (and flymake-start-syntax-check-on-newline (equal new-text "\n")) | |
1572 (flymake-log 3 "starting syntax check as new-line has been seen") | |
1573 (flymake-start-syntax-check-for-current-buffer)) | |
1574 (flymake-set-buffer-last-change-time (current-buffer) (flymake-float-time)))) | |
55822 | 1575 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1576 (defun flymake-after-save-hook () |
58515 | 1577 (if (local-variable-p 'flymake-mode (current-buffer)) ; (???) other way to determine whether flymake is active in buffer being saved? |
1578 (progn | |
1579 (flymake-log 3 "starting syntax check as buffer was saved") | |
1580 (flymake-start-syntax-check-for-current-buffer)))) ; no more mode 3. cannot start check if mode 3 (to temp copies) is active - (???) | |
55822 | 1581 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1582 (defun flymake-kill-buffer-hook () |
58515 | 1583 (when (flymake-get-buffer-timer (current-buffer)) |
1584 (cancel-timer (flymake-get-buffer-timer (current-buffer))) | |
1585 (flymake-set-buffer-timer (current-buffer) nil))) | |
55822 | 1586 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1587 (defun flymake-find-file-hook () |
60903
29db3b79c3fa
Misc fix up of comments and docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58561
diff
changeset
|
1588 ;;+(when flymake-start-syntax-check-on-find-file |
29db3b79c3fa
Misc fix up of comments and docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58561
diff
changeset
|
1589 ;;+ (flymake-log 3 "starting syntax check on file open") |
29db3b79c3fa
Misc fix up of comments and docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58561
diff
changeset
|
1590 ;;+ (flymake-start-syntax-check-for-current-buffer) |
29db3b79c3fa
Misc fix up of comments and docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58561
diff
changeset
|
1591 ;;+) |
58515 | 1592 (when (and (not (local-variable-p 'flymake-mode (current-buffer))) |
1593 (flymake-can-syntax-check-file (buffer-file-name (current-buffer)))) | |
1594 (flymake-mode) | |
1595 (flymake-log 3 "automatically turned ON flymake mode"))) | |
55822 | 1596 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1597 (defun flymake-get-first-err-line-no (err-info-list) |
58515 | 1598 "Return first line with error." |
1599 (when err-info-list | |
1600 (flymake-er-get-line (car err-info-list)))) | |
55822 | 1601 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1602 (defun flymake-get-last-err-line-no (err-info-list) |
58515 | 1603 "Return last line with error." |
1604 (when err-info-list | |
1605 (flymake-er-get-line (nth (1- (length err-info-list)) err-info-list)))) | |
55822 | 1606 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1607 (defun flymake-get-next-err-line-no (err-info-list line-no) |
58515 | 1608 "Return next line with error." |
1609 (when err-info-list | |
1610 (let* ((count (length err-info-list)) | |
1611 (idx 0)) | |
1612 (while (and (< idx count) (>= line-no (flymake-er-get-line (nth idx err-info-list)))) | |
1613 (setq idx (1+ idx))) | |
1614 (if (< idx count) | |
1615 (flymake-er-get-line (nth idx err-info-list)))))) | |
55822 | 1616 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1617 (defun flymake-get-prev-err-line-no (err-info-list line-no) |
58515 | 1618 "Return prev line with error." |
1619 (when err-info-list | |
1620 (let* ((count (length err-info-list))) | |
1621 (while (and (> count 0) (<= line-no (flymake-er-get-line (nth (1- count) err-info-list)))) | |
1622 (setq count (1- count))) | |
1623 (if (> count 0) | |
1624 (flymake-er-get-line (nth (1- count) err-info-list)))))) | |
55822 | 1625 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1626 (defun flymake-skip-whitespace () |
58515 | 1627 "Move forward until non-whitespace is reached." |
1628 (while (looking-at "[ \t]") | |
1629 (forward-char))) | |
55822 | 1630 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1631 (defun flymake-goto-line (line-no) |
60903
29db3b79c3fa
Misc fix up of comments and docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58561
diff
changeset
|
1632 "Go to line LINE-NO, then skip whitespace." |
58515 | 1633 (goto-line line-no) |
1634 (flymake-skip-whitespace)) | |
55822 | 1635 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1636 (defun flymake-goto-next-error () |
60903
29db3b79c3fa
Misc fix up of comments and docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58561
diff
changeset
|
1637 "Go to next error in err ring." |
58515 | 1638 (interactive) |
1639 (let ((line-no (flymake-get-next-err-line-no (flymake-get-buffer-err-info (current-buffer)) (flymake-current-line-no)))) | |
1640 (when (not line-no) | |
1641 (setq line-no (flymake-get-first-err-line-no (flymake-get-buffer-err-info (current-buffer)))) | |
1642 (flymake-log 1 "passed end of file")) | |
1643 (if line-no | |
1644 (flymake-goto-line line-no) | |
1645 (flymake-log 1 "no errors in current buffer")))) | |
55822 | 1646 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1647 (defun flymake-goto-prev-error () |
60903
29db3b79c3fa
Misc fix up of comments and docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58561
diff
changeset
|
1648 "Go to prev error in err ring." |
58515 | 1649 (interactive) |
1650 (let ((line-no (flymake-get-prev-err-line-no (flymake-get-buffer-err-info (current-buffer)) (flymake-current-line-no)))) | |
1651 (when (not line-no) | |
1652 (setq line-no (flymake-get-last-err-line-no (flymake-get-buffer-err-info (current-buffer)))) | |
1653 (flymake-log 1 "passed beginning of file")) | |
1654 (if line-no | |
1655 (flymake-goto-line line-no) | |
1656 (flymake-log 1 "no errors in current buffer")))) | |
55822 | 1657 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1658 (defun flymake-patch-err-text (string) |
58515 | 1659 (if (string-match "^[\n\t :0-9]*\\(.*\\)$" string) |
1660 (match-string 1 string) | |
1661 string)) | |
55822 | 1662 |
1663 ;;;; general init-cleanup and helper routines | |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1664 (defun flymake-create-temp-inplace (file-name prefix) |
58515 | 1665 (unless (stringp file-name) |
1666 (error "Invalid file-name")) | |
1667 (or prefix | |
1668 (setq prefix "flymake")) | |
1669 (let* ((temp-name (concat (file-name-sans-extension file-name) | |
1670 "_" prefix | |
1671 (and (file-name-extension file-name) | |
1672 (concat "." (file-name-extension file-name)))))) | |
1673 (flymake-log 3 "create-temp-inplace: file=%s temp=%s" file-name temp-name) | |
1674 temp-name)) | |
55822 | 1675 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1676 (defun flymake-create-temp-with-folder-structure (file-name prefix) |
58515 | 1677 (unless (stringp file-name) |
1678 (error "Invalid file-name")) | |
55822 | 1679 |
58515 | 1680 (let* ((dir (file-name-directory file-name)) |
1681 (slash-pos (string-match "/" dir)) | |
60905
6611fdf35049
(flymake-ensure-ends-with-slash): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60904
diff
changeset
|
1682 (temp-dir (concat (file-name-as-directory (flymake-get-temp-dir)) (substring dir (1+ slash-pos))))) |
55822 | 1683 |
60905
6611fdf35049
(flymake-ensure-ends-with-slash): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60904
diff
changeset
|
1684 (file-truename (concat (file-name-as-directory temp-dir) |
58515 | 1685 (file-name-nondirectory file-name))))) |
55822 | 1686 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1687 (defun flymake-strrchr (str ch) |
58515 | 1688 (let* ((count (length str)) |
1689 (pos nil)) | |
1690 (while (and (not pos) (> count 0)) | |
1691 (if (= ch (elt str (1- count))) | |
1692 (setq pos (1- count))) | |
1693 (setq count (1- count))) | |
1694 pos)) | |
55822 | 1695 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1696 (defun flymake-delete-temp-directory (dir-name) |
60903
29db3b79c3fa
Misc fix up of comments and docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58561
diff
changeset
|
1697 "Attempt to delete temp dir created by `flymake-create-temp-with-folder-structure', do not fail on error." |
58515 | 1698 (let* ((temp-dir (flymake-get-temp-dir)) |
1699 (suffix (substring dir-name (1+ (length temp-dir)))) | |
1700 (slash-pos nil)) | |
55822 | 1701 |
58515 | 1702 (while (> (length suffix) 0) |
60903
29db3b79c3fa
Misc fix up of comments and docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58561
diff
changeset
|
1703 ;;+(flymake-log 0 "suffix=%s" suffix) |
60905
6611fdf35049
(flymake-ensure-ends-with-slash): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60904
diff
changeset
|
1704 (flymake-safe-delete-directory (file-truename (concat (file-name-as-directory temp-dir) suffix))) |
58515 | 1705 (setq slash-pos (flymake-strrchr suffix (string-to-char "/"))) |
1706 (if slash-pos | |
1707 (setq suffix (substring suffix 0 slash-pos)) | |
1708 (setq suffix ""))))) | |
55822 | 1709 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1710 (defun flymake-init-create-temp-buffer-copy (buffer create-temp-f) |
58515 | 1711 "Make a temporary copy of the current buffer, save its name in buffer data and return the name." |
1712 (let* ((source-file-name (buffer-file-name buffer)) | |
1713 (temp-source-file-name (funcall create-temp-f source-file-name "flymake"))) | |
55822 | 1714 |
58515 | 1715 (flymake-save-buffer-in-file buffer temp-source-file-name) |
1716 (flymake-set-buffer-value buffer "temp-source-file-name" temp-source-file-name) | |
1717 temp-source-file-name)) | |
55822 | 1718 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1719 (defun flymake-simple-cleanup (buffer) |
58515 | 1720 "Do cleanup after 'flymake-init-create-temp-buffer-copy'. |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1721 Delete temp file." |
58515 | 1722 (let* ((temp-source-file-name (flymake-get-buffer-value buffer "temp-source-file-name"))) |
1723 (flymake-safe-delete-file temp-source-file-name) | |
1724 (flymake-set-buffer-last-change-time buffer nil))) | |
55822 | 1725 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1726 (defun flymake-get-real-file-name (buffer file-name-from-err-msg) |
60903
29db3b79c3fa
Misc fix up of comments and docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58561
diff
changeset
|
1727 "Translate file name from error message to \"real\" file name. |
29db3b79c3fa
Misc fix up of comments and docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58561
diff
changeset
|
1728 Return full-name. Names are real, not patched." |
58515 | 1729 (let* ((real-name nil) |
1730 (source-file-name (buffer-file-name buffer)) | |
1731 (master-file-name (flymake-get-buffer-value buffer "master-file-name")) | |
1732 (temp-source-file-name (flymake-get-buffer-value buffer "temp-source-file-name")) | |
1733 (temp-master-file-name (flymake-get-buffer-value buffer "temp-master-file-name")) | |
1734 (base-dirs (list (flymake-get-buffer-value buffer "base-dir") | |
1735 (file-name-directory source-file-name) | |
1736 (if master-file-name (file-name-directory master-file-name) nil))) | |
1737 (files (list (list source-file-name source-file-name) | |
1738 (list temp-source-file-name source-file-name) | |
1739 (list master-file-name master-file-name) | |
1740 (list temp-master-file-name master-file-name)))) | |
55822 | 1741 |
58515 | 1742 (when (equal 0 (length file-name-from-err-msg)) |
1743 (setq file-name-from-err-msg source-file-name)) | |
55822 | 1744 |
58515 | 1745 (setq real-name (flymake-get-full-patched-file-name file-name-from-err-msg base-dirs files)) |
60903
29db3b79c3fa
Misc fix up of comments and docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58561
diff
changeset
|
1746 ;; if real-name is nil, than file name from err msg is none of the files we've patched |
58515 | 1747 (if (not real-name) |
1748 (setq real-name (flymake-get-full-nonpatched-file-name file-name-from-err-msg base-dirs))) | |
1749 (if (not real-name) | |
1750 (setq real-name file-name-from-err-msg)) | |
1751 (setq real-name (flymake-fix-file-name real-name)) | |
1752 (flymake-log 3 "get-real-file-name: file-name=%s real-name=%s" file-name-from-err-msg real-name) | |
1753 real-name)) | |
55822 | 1754 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1755 (defun flymake-get-full-patched-file-name (file-name-from-err-msg base-dirs files) |
58515 | 1756 (let* ((base-dirs-count (length base-dirs)) |
1757 (file-count (length files)) | |
1758 (real-name nil)) | |
55822 | 1759 |
58515 | 1760 (while (and (not real-name) (> base-dirs-count 0)) |
1761 (setq file-count (length files)) | |
1762 (while (and (not real-name) (> file-count 0)) | |
1763 (let* ((this-dir (nth (1- base-dirs-count) base-dirs)) | |
1764 (this-file (nth 0 (nth (1- file-count) files))) | |
1765 (this-real-name (nth 1 (nth (1- file-count) files)))) | |
60903
29db3b79c3fa
Misc fix up of comments and docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58561
diff
changeset
|
1766 ;;+(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) |
58515 | 1767 (when (and this-dir this-file (flymake-same-files |
61674
b600a84e6555
(flymake-get-absolute-file-name-basedir): Remove. Update callers to use
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
61284
diff
changeset
|
1768 (expand-file-name file-name-from-err-msg this-dir) |
58515 | 1769 this-file)) |
1770 (setq real-name this-real-name))) | |
1771 (setq file-count (1- file-count))) | |
1772 (setq base-dirs-count (1- base-dirs-count))) | |
1773 real-name)) | |
55822 | 1774 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1775 (defun flymake-get-full-nonpatched-file-name (file-name-from-err-msg base-dirs) |
58515 | 1776 (let* ((real-name nil)) |
1777 (if (file-name-absolute-p file-name-from-err-msg) | |
1778 (setq real-name file-name-from-err-msg) | |
1779 (let* ((base-dirs-count (length base-dirs))) | |
1780 (while (and (not real-name) (> base-dirs-count 0)) | |
61674
b600a84e6555
(flymake-get-absolute-file-name-basedir): Remove. Update callers to use
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
61284
diff
changeset
|
1781 (let* ((full-name (expand-file-name file-name-from-err-msg |
b600a84e6555
(flymake-get-absolute-file-name-basedir): Remove. Update callers to use
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
61284
diff
changeset
|
1782 (nth (1- base-dirs-count) base-dirs)))) |
58515 | 1783 (if (file-exists-p full-name) |
1784 (setq real-name full-name)) | |
1785 (setq base-dirs-count (1- base-dirs-count)))))) | |
1786 real-name)) | |
55822 | 1787 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1788 (defun flymake-init-find-buildfile-dir (buffer source-file-name buildfile-name) |
58515 | 1789 "Find buildfile, store its dir in buffer data and return its dir, if found." |
1790 (let* ((buildfile-dir (flymake-find-buildfile buildfile-name | |
1791 (file-name-directory source-file-name) | |
1792 flymake-buildfile-dirs))) | |
1793 (if (not buildfile-dir) | |
1794 (progn | |
1795 (flymake-log 1 "no buildfile (%s) for %s" buildfile-name source-file-name) | |
1796 (flymake-report-fatal-status buffer "NOMK" (format "No buildfile (%s) found for %s" buildfile-name source-file-name)) | |
1797 ) | |
1798 (progn | |
1799 (flymake-set-buffer-value buffer "base-dir" buildfile-dir))) | |
1800 buildfile-dir)) | |
55822 | 1801 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1802 (defun flymake-init-create-temp-source-and-master-buffer-copy (buffer get-incl-dirs-f create-temp-f master-file-masks include-regexp-list) |
58515 | 1803 "Find master file (or buffer), create it's copy along with a copy of the source file." |
1804 (let* ((source-file-name (buffer-file-name buffer)) | |
1805 (temp-source-file-name (flymake-init-create-temp-buffer-copy buffer create-temp-f)) | |
1806 (master-file-name nil) | |
1807 (temp-master-file-name nil) | |
1808 (master-and-temp-master (flymake-create-master-file | |
1809 source-file-name temp-source-file-name | |
1810 get-incl-dirs-f create-temp-f | |
1811 master-file-masks include-regexp-list))) | |
55822 | 1812 |
58515 | 1813 (if (not master-and-temp-master) |
1814 (progn | |
1815 (flymake-log 1 "cannot find master file for %s" source-file-name) | |
1816 (flymake-report-status buffer "!" "") ; NOMASTER | |
1817 ) | |
1818 (progn | |
1819 (setq master-file-name (nth 0 master-and-temp-master)) | |
1820 (setq temp-master-file-name (nth 1 master-and-temp-master)) | |
1821 (flymake-set-buffer-value buffer "master-file-name" master-file-name) | |
1822 (flymake-set-buffer-value buffer "temp-master-file-name" temp-master-file-name) | |
1823 )) | |
1824 temp-master-file-name)) | |
55822 | 1825 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1826 (defun flymake-master-cleanup (buffer) |
58515 | 1827 (flymake-simple-cleanup buffer) |
1828 (flymake-safe-delete-file (flymake-get-buffer-value buffer "temp-master-file-name"))) | |
55822 | 1829 |
1830 ;;;; make-specific init-cleanup routines | |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1831 (defun flymake-get-syntax-check-program-args (source-file-name base-dir use-relative-base-dir use-relative-source get-cmd-line-f) |
58515 | 1832 "Create a command line for syntax check using GET-CMD-LINE-F." |
1833 (let* ((my-base-dir base-dir) | |
1834 (my-source source-file-name)) | |
55822 | 1835 |
58515 | 1836 (when use-relative-base-dir |
1837 (setq my-base-dir (flymake-build-relative-filename (file-name-directory source-file-name) base-dir))) | |
55822 | 1838 |
58515 | 1839 (when use-relative-source |
1840 (setq my-source (concat (flymake-build-relative-filename base-dir (file-name-directory source-file-name)) | |
1841 (file-name-nondirectory source-file-name)))) | |
1842 (funcall get-cmd-line-f my-source my-base-dir))) | |
55822 | 1843 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1844 (defun flymake-get-make-cmdline (source base-dir) |
58515 | 1845 (list "make" |
1846 (list "-s" | |
1847 "-C" | |
1848 base-dir | |
1849 (concat "CHK_SOURCES=" source) | |
1850 "SYNTAX_CHECK_MODE=1" | |
1851 "check-syntax"))) | |
55822 | 1852 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1853 (defun flymake-get-ant-cmdline (source base-dir) |
58515 | 1854 (list "ant" |
1855 (list "-buildfile" | |
1856 (concat base-dir "/" "build.xml") | |
1857 (concat "-DCHK_SOURCES=" source) | |
1858 "check-syntax"))) | |
55822 | 1859 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1860 (defun flymake-simple-make-init-impl (buffer create-temp-f use-relative-base-dir use-relative-source build-file-name get-cmdline-f) |
58515 | 1861 "Create syntax check command line for a directly checked source file. |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1862 Use CREATE-TEMP-F for creating temp copy." |
58515 | 1863 (let* ((args nil) |
1864 (source-file-name (buffer-file-name buffer)) | |
1865 (buildfile-dir (flymake-init-find-buildfile-dir buffer source-file-name build-file-name))) | |
1866 (if buildfile-dir | |
1867 (let* ((temp-source-file-name (flymake-init-create-temp-buffer-copy buffer create-temp-f))) | |
1868 (setq args (flymake-get-syntax-check-program-args temp-source-file-name buildfile-dir | |
1869 use-relative-base-dir use-relative-source | |
1870 get-cmdline-f)))) | |
1871 args)) | |
55822 | 1872 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1873 (defun flymake-simple-make-init (buffer) |
58515 | 1874 (flymake-simple-make-init-impl buffer 'flymake-create-temp-inplace t t "Makefile" 'flymake-get-make-cmdline)) |
55822 | 1875 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1876 (defun flymake-master-make-init (buffer get-incl-dirs-f master-file-masks include-regexp-list) |
60903
29db3b79c3fa
Misc fix up of comments and docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58561
diff
changeset
|
1877 "Create make command line for a source file checked via master file compilation." |
58515 | 1878 (let* ((make-args nil) |
1879 (temp-master-file-name (flymake-init-create-temp-source-and-master-buffer-copy | |
1880 buffer get-incl-dirs-f 'flymake-create-temp-inplace | |
1881 master-file-masks include-regexp-list))) | |
1882 (when temp-master-file-name | |
1883 (let* ((buildfile-dir (flymake-init-find-buildfile-dir buffer temp-master-file-name "Makefile"))) | |
1884 (if buildfile-dir | |
1885 (setq make-args (flymake-get-syntax-check-program-args | |
1886 temp-master-file-name buildfile-dir nil nil 'flymake-get-make-cmdline))))) | |
1887 make-args)) | |
55822 | 1888 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1889 (defun flymake-find-make-buildfile (source-dir) |
58515 | 1890 (flymake-find-buildfile "Makefile" source-dir flymake-buildfile-dirs)) |
55822 | 1891 |
1892 ;;;; .h/make specific | |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1893 (defun flymake-master-make-header-init (buffer) |
58515 | 1894 (flymake-master-make-init buffer |
1895 'flymake-get-include-dirs | |
1896 '(".+\\.cpp$" ".+\\.c$") | |
1897 '("[ \t]*#[ \t]*include[ \t]*\"\\([\w0-9/\\_\.]*[/\\]*\\)\\(%s\\)\"" 1 2))) | |
55822 | 1898 |
1899 ;;;; .java/make specific | |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1900 (defun flymake-simple-make-java-init (buffer) |
58515 | 1901 (flymake-simple-make-init-impl buffer 'flymake-create-temp-with-folder-structure nil nil "Makefile" 'flymake-get-make-cmdline)) |
55822 | 1902 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1903 (defun flymake-simple-ant-java-init (buffer) |
58515 | 1904 (flymake-simple-make-init-impl buffer 'flymake-create-temp-with-folder-structure nil nil "build.xml" 'flymake-get-ant-cmdline)) |
55822 | 1905 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1906 (defun flymake-simple-java-cleanup (buffer) |
60903
29db3b79c3fa
Misc fix up of comments and docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58561
diff
changeset
|
1907 "Cleanup after `flymake-simple-make-java-init' -- delete temp file and dirs." |
58515 | 1908 (let* ((temp-source-file-name (flymake-get-buffer-value buffer "temp-source-file-name"))) |
1909 (flymake-safe-delete-file temp-source-file-name) | |
1910 (when temp-source-file-name | |
1911 (flymake-delete-temp-directory (file-name-directory temp-source-file-name))))) | |
55822 | 1912 |
1913 ;;;; perl-specific init-cleanup routines | |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1914 (defun flymake-perl-init (buffer) |
60905
6611fdf35049
(flymake-ensure-ends-with-slash): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60904
diff
changeset
|
1915 (let* ((temp-file (flymake-init-create-temp-buffer-copy |
6611fdf35049
(flymake-ensure-ends-with-slash): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60904
diff
changeset
|
1916 buffer 'flymake-create-temp-inplace)) |
6611fdf35049
(flymake-ensure-ends-with-slash): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60904
diff
changeset
|
1917 (local-file (concat (flymake-build-relative-filename |
6611fdf35049
(flymake-ensure-ends-with-slash): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60904
diff
changeset
|
1918 (file-name-directory buffer-file-name) |
6611fdf35049
(flymake-ensure-ends-with-slash): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60904
diff
changeset
|
1919 (file-name-directory temp-file)) |
58515 | 1920 (file-name-nondirectory temp-file)))) |
1921 (list "perl" (list "-wc " local-file)))) | |
55822 | 1922 |
1923 ;;;; tex-specific init-cleanup routines | |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1924 (defun flymake-get-tex-args (file-name) |
60903
29db3b79c3fa
Misc fix up of comments and docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58561
diff
changeset
|
1925 ;;(list "latex" (list "-c-style-errors" file-name)) |
58515 | 1926 (list "texify" (list "--pdf" "--tex-option=-c-style-errors" file-name))) |
55822 | 1927 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1928 (defun flymake-simple-tex-init (buffer) |
58515 | 1929 (flymake-get-tex-args (flymake-init-create-temp-buffer-copy buffer 'flymake-create-temp-inplace))) |
55822 | 1930 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1931 (defun flymake-master-tex-init (buffer) |
58515 | 1932 (let* ((temp-master-file-name (flymake-init-create-temp-source-and-master-buffer-copy |
1933 buffer 'flymake-get-include-dirs-dot 'flymake-create-temp-inplace | |
1934 '(".+\\.tex$") | |
1935 '("[ \t]*\\input[ \t]*{\\(.*\\)\\(%s\\)}" 1 2)))) | |
1936 (when temp-master-file-name | |
1937 (flymake-get-tex-args temp-master-file-name)))) | |
55822 | 1938 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1939 (defun flymake-get-include-dirs-dot (base-dir) |
58515 | 1940 '(".")) |
55822 | 1941 |
1942 ;;;; xml-specific init-cleanup routines | |
60905
6611fdf35049
(flymake-ensure-ends-with-slash): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60904
diff
changeset
|
1943 (defun flymake-xml-init (buffer) |
58515 | 1944 (list "xml" (list "val" (flymake-init-create-temp-buffer-copy buffer 'flymake-create-temp-inplace)))) |
55822 | 1945 |
58514
287d0425c18a
Much whitespace and capitalization change.
Richard M. Stallman <rms@gnu.org>
parents:
57847
diff
changeset
|
1946 (provide 'flymake) |
55822 | 1947 |
60903
29db3b79c3fa
Misc fix up of comments and docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58561
diff
changeset
|
1948 ;; arch-tag: 8f0d6090-061d-4cac-8862-7c151c4a02dd |
55822 | 1949 ;;; flymake.el ends here |