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