1 |
;;; flymake.el -- a universal on-the-fly syntax checker |
;;; flymake.el -- a universal on-the-fly syntax checker |
2 |
|
|
3 |
;; Copyright (C) 2003 Free Software Foundation |
;; Copyright (C) 2003, 2005 Free Software Foundation |
4 |
|
|
5 |
;; Author: Pavel Kobiakov <pk_at_work@yahoo.com> |
;; Author: Pavel Kobiakov <pk_at_work@yahoo.com> |
6 |
;; Maintainer: Pavel Kobiakov <pk_at_work@yahoo.com> |
;; Maintainer: Pavel Kobiakov <pk_at_work@yahoo.com> |
170 |
tmp)) |
tmp)) |
171 |
|
|
172 |
(defun flymake-set-at (list pos val) |
(defun flymake-set-at (list pos val) |
173 |
"Set VAL at position POS in LIST" |
"Set VAL at position POS in LIST." |
174 |
(let ((tmp (copy-sequence list))) ; (???) |
(let ((tmp (copy-sequence list))) ; (???) |
175 |
(setcar (nthcdr pos tmp) val) |
(setcar (nthcdr pos tmp) val) |
176 |
tmp)) |
tmp)) |
231 |
(defun flymake-set-buffer-value (buffer name value) |
(defun flymake-set-buffer-value (buffer name value) |
232 |
(puthash name value (flymake-get-buffer-data buffer))) |
(puthash name value (flymake-get-buffer-data buffer))) |
233 |
|
|
234 |
(defvar flymake-output-residual nil "") |
(defvar flymake-output-residual nil) |
235 |
|
|
236 |
(make-variable-buffer-local 'flymake-output-residual) |
(make-variable-buffer-local 'flymake-output-residual) |
237 |
|
|
253 |
(".+[0-9]+\\.tex$" flymake-master-tex-init flymake-master-cleanup flymake-get-real-file-name) |
(".+[0-9]+\\.tex$" flymake-master-tex-init flymake-master-cleanup flymake-get-real-file-name) |
254 |
(".+\\.tex$" flymake-simple-tex-init flymake-simple-cleanup flymake-get-real-file-name) |
(".+\\.tex$" flymake-simple-tex-init flymake-simple-cleanup flymake-get-real-file-name) |
255 |
(".+\\.idl$" flymake-simple-make-init flymake-simple-cleanup flymake-get-real-file-name) |
(".+\\.idl$" flymake-simple-make-init flymake-simple-cleanup flymake-get-real-file-name) |
256 |
; (".+\\.cpp$" 1) |
;; (".+\\.cpp$" 1) |
257 |
; (".+\\.java$" 3) |
;; (".+\\.java$" 3) |
258 |
; (".+\\.h$" 2 (".+\\.cpp$" ".+\\.c$") |
;; (".+\\.h$" 2 (".+\\.cpp$" ".+\\.c$") |
259 |
; ("[ \t]*#[ \t]*include[ \t]*\"\\([\w0-9/\\_\.]*[/\\]*\\)\\(%s\\)\"" 1 2)) |
;; ("[ \t]*#[ \t]*include[ \t]*\"\\([\w0-9/\\_\.]*[/\\]*\\)\\(%s\\)\"" 1 2)) |
260 |
; (".+\\.idl$" 1) |
;; (".+\\.idl$" 1) |
261 |
; (".+\\.odl$" 1) |
;; (".+\\.odl$" 1) |
262 |
; (".+[0-9]+\\.tex$" 2 (".+\\.tex$") |
;; (".+[0-9]+\\.tex$" 2 (".+\\.tex$") |
263 |
; ("[ \t]*\\input[ \t]*{\\(.*\\)\\(%s\\)}" 1 2 )) |
;; ("[ \t]*\\input[ \t]*{\\(.*\\)\\(%s\\)}" 1 2 )) |
264 |
; (".+\\.tex$" 1) |
;; (".+\\.tex$" 1) |
265 |
) |
) |
266 |
"*Files syntax checking is allowed for." |
"*Files syntax checking is allowed for." |
267 |
:group 'flymake |
:group 'flymake |
268 |
:type '(repeat (string symbol symbol symbol))) |
:type '(repeat (string symbol symbol symbol))) |
269 |
|
|
270 |
(defun flymake-get-file-name-mode-and-masks (file-name) |
(defun flymake-get-file-name-mode-and-masks (file-name) |
271 |
"Return the corresponding entry from 'flymake-allowed-file-name-masks'." |
"Return the corresponding entry from `flymake-allowed-file-name-masks'." |
272 |
(unless (stringp file-name) |
(unless (stringp file-name) |
273 |
(error "Invalid file-name")) |
(error "Invalid file-name")) |
274 |
(let ((count (length flymake-allowed-file-name-masks)) |
(let ((count (length flymake-allowed-file-name-masks)) |
289 |
(defun flymake-get-init-function (file-name) |
(defun flymake-get-init-function (file-name) |
290 |
"Return init function to be used for the file." |
"Return init function to be used for the file." |
291 |
(let* ((init-f (nth 0 (flymake-get-file-name-mode-and-masks file-name)))) |
(let* ((init-f (nth 0 (flymake-get-file-name-mode-and-masks file-name)))) |
292 |
;(flymake-log 0 "calling %s" init-f) |
;;(flymake-log 0 "calling %s" init-f) |
293 |
;(funcall init-f (current-buffer)) |
;;(funcall init-f (current-buffer)) |
294 |
init-f)) |
init-f)) |
295 |
|
|
296 |
(defun flymake-get-cleanup-function (file-name) |
(defun flymake-get-cleanup-function (file-name) |
387 |
|
|
388 |
(defun flymake-build-relative-filename (from-dir to-dir) |
(defun flymake-build-relative-filename (from-dir to-dir) |
389 |
"Return rel: FROM-DIR/rel == TO-DIR." |
"Return rel: FROM-DIR/rel == TO-DIR." |
390 |
|
;; FIXME: Why not use `file-relative-name'? |
391 |
(if (not (equal (elt from-dir 0) (elt to-dir 0))) |
(if (not (equal (elt from-dir 0) (elt to-dir 0))) |
392 |
(error "First chars in file names %s, %s must be equal (same drive)" |
(error "First chars in file names %s, %s must be equal (same drive)" |
393 |
from-dir to-dir) |
from-dir to-dir) |
414 |
(or rel "./")))) |
(or rel "./")))) |
415 |
|
|
416 |
(defcustom flymake-master-file-dirs '("." "./src" "./UnitTest") |
(defcustom flymake-master-file-dirs '("." "./src" "./UnitTest") |
417 |
"Dirs where to llok for master files." |
"Dirs where to look for master files." |
418 |
:group 'flymake |
:group 'flymake |
419 |
:type '(repeat (string))) |
:type '(repeat (string))) |
420 |
|
|
427 |
(defvar flymake-included-file-name) |
(defvar flymake-included-file-name) |
428 |
|
|
429 |
(defun flymake-find-possible-master-files (file-name master-file-dirs masks) |
(defun flymake-find-possible-master-files (file-name master-file-dirs masks) |
430 |
"Find (by name and location) all posible master files. |
"Find (by name and location) all possible master files. |
431 |
Mater files are .cpp and .c for and .h. Files are searched for |
Master files are .cpp and .c for and .h. Files are searched for |
432 |
starting from the .h directory and max max-level parent dirs. |
starting from the .h directory and max max-level parent dirs. |
433 |
File contents are not checked." |
File contents are not checked." |
434 |
(let* ((dir-idx 0) |
(let* ((dir-idx 0) |
513 |
(when (flymake-check-include source-file-name inc-path inc-name include-dirs) |
(when (flymake-check-include source-file-name inc-path inc-name include-dirs) |
514 |
(setq found t) |
(setq found t) |
515 |
;; replace-match is not used here as it fails in |
;; replace-match is not used here as it fails in |
516 |
;; xemacs with 'last match not a buffer' error as |
;; XEmacs with 'last match not a buffer' error as |
517 |
;; check-includes calls replace-in-string |
;; check-includes calls replace-in-string |
518 |
(flymake-replace-region (current-buffer) match-beg match-end |
(flymake-replace-region (current-buffer) match-beg match-end |
519 |
(file-name-nondirectory patched-source-file-name)))) |
(file-name-nondirectory patched-source-file-name)))) |
520 |
(forward-line 1))) |
(forward-line 1))) |
521 |
(when found |
(when found |
522 |
(flymake-save-buffer-in-file (current-buffer) patched-master-file-name))) |
(flymake-save-buffer-in-file (current-buffer) patched-master-file-name))) |
523 |
;+(flymake-log 3 "killing buffer %s" (buffer-name master-file-temp-buffer)) |
;;+(flymake-log 3 "killing buffer %s" (buffer-name master-file-temp-buffer)) |
524 |
(kill-buffer master-file-temp-buffer))) |
(kill-buffer master-file-temp-buffer))) |
525 |
;+(flymake-log 3 "check-patch master file %s: %s" master-file-name found) |
;;+(flymake-log 3 "check-patch master file %s: %s" master-file-name found) |
526 |
(when found |
(when found |
527 |
(flymake-log 2 "found master file %s" master-file-name)) |
(flymake-log 2 "found master file %s" master-file-name)) |
528 |
found)) |
found)) |
867 |
(overlay-put ov 'help-echo tooltip-text) |
(overlay-put ov 'help-echo tooltip-text) |
868 |
(overlay-put ov 'flymake-overlay t) |
(overlay-put ov 'flymake-overlay t) |
869 |
(overlay-put ov 'priority 100) |
(overlay-put ov 'priority 100) |
870 |
;+(flymake-log 3 "created overlay %s" ov) |
;;+(flymake-log 3 "created overlay %s" ov) |
871 |
ov) |
ov) |
872 |
(flymake-log 3 "created an overlay at (%d-%d)" beg end))) |
(flymake-log 3 "created an overlay at (%d-%d)" beg end))) |
873 |
|
|
879 |
(while (consp ov) |
(while (consp ov) |
880 |
(when (flymake-overlay-p (car ov)) |
(when (flymake-overlay-p (car ov)) |
881 |
(delete-overlay (car ov)) |
(delete-overlay (car ov)) |
882 |
;+(flymake-log 3 "deleted overlay %s" ov) |
;;+(flymake-log 3 "deleted overlay %s" ov) |
883 |
) |
) |
884 |
(setq ov (cdr ov)))))) |
(setq ov (cdr ov)))))) |
885 |
|
|
894 |
(setq ov (cdr ov))))) |
(setq ov (cdr ov))))) |
895 |
|
|
896 |
(defface flymake-errline-face |
(defface flymake-errline-face |
897 |
;+ '((((class color)) (:foreground "OrangeRed" :bold t :underline t)) |
;;+ '((((class color)) (:foreground "OrangeRed" :bold t :underline t)) |
898 |
;+ '((((class color)) (:underline "OrangeRed")) |
;;+ '((((class color)) (:underline "OrangeRed")) |
899 |
'((((class color)) (:background "LightPink")) |
'((((class color)) (:background "LightPink")) |
900 |
(t (:bold t))) |
(t (:bold t))) |
901 |
"Face used for marking error lines." |
"Face used for marking error lines." |
971 |
|
|
972 |
(defun flymake-split-output (output) |
(defun flymake-split-output (output) |
973 |
"Split OUTPUT into lines. |
"Split OUTPUT into lines. |
974 |
Return last one as residual if it does not end with newline char. Returns ((lines) residual)." |
Return last one as residual if it does not end with newline char. |
975 |
|
Returns ((LINES) RESIDUAL)." |
976 |
(when (and output (> (length output) 0)) |
(when (and output (> (length output) 0)) |
977 |
(let* ((lines (flymake-split-string output "[\n\r]+")) |
(let* ((lines (flymake-split-string output "[\n\r]+")) |
978 |
(complete (equal "\n" (char-to-string (aref output (1- (length output)))))) |
(complete (equal "\n" (char-to-string (aref output (1- (length output)))))) |
1009 |
(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 |
(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 |
1010 |
(append |
(append |
1011 |
'( |
'( |
1012 |
; MS Visual C++ 6.0 |
;; MS Visual C++ 6.0 |
1013 |
("\\(\\([a-zA-Z]:\\)?[^:(\t\n]+\\)(\\([0-9]+\\)) \: \\(\\(error\\|warning\\|fatal error\\) \\(C[0-9]+\\):[ \t\n]*\\(.+\\)\\)" |
("\\(\\([a-zA-Z]:\\)?[^:(\t\n]+\\)(\\([0-9]+\\)) \: \\(\\(error\\|warning\\|fatal error\\) \\(C[0-9]+\\):[ \t\n]*\\(.+\\)\\)" |
1014 |
1 3 nil 4) |
1 3 nil 4) |
1015 |
; jikes |
;; jikes |
1016 |
("\\(\\([a-zA-Z]:\\)?[^:(\t\n]+\\)\:\\([0-9]+\\)\:[0-9]+\:[0-9]+\:[0-9]+\: \\(\\(Error\\|Warning\\|Caution\\|Semantic Error\\):[ \t\n]*\\(.+\\)\\)" |
("\\(\\([a-zA-Z]:\\)?[^:(\t\n]+\\)\:\\([0-9]+\\)\:[0-9]+\:[0-9]+\:[0-9]+\: \\(\\(Error\\|Warning\\|Caution\\|Semantic Error\\):[ \t\n]*\\(.+\\)\\)" |
1017 |
1 3 nil 4) |
1 3 nil 4) |
1018 |
; MS midl |
;; MS midl |
1019 |
("midl[ ]*:[ ]*\\(command line error .*\\)" |
("midl[ ]*:[ ]*\\(command line error .*\\)" |
1020 |
nil nil nil 1) |
nil nil nil 1) |
1021 |
; MS C# |
;; MS C# |
1022 |
("\\(\\([a-zA-Z]:\\)?[^:(\t\n]+\\)(\\([0-9]+\\),[0-9]+)\: \\(\\(error\\|warning\\|fatal error\\) \\(CS[0-9]+\\):[ \t\n]*\\(.+\\)\\)" |
("\\(\\([a-zA-Z]:\\)?[^:(\t\n]+\\)(\\([0-9]+\\),[0-9]+)\: \\(\\(error\\|warning\\|fatal error\\) \\(CS[0-9]+\\):[ \t\n]*\\(.+\\)\\)" |
1023 |
1 3 nil 4) |
1 3 nil 4) |
1024 |
; perl |
;; perl |
1025 |
("\\(.*\\) at \\([^ \n]+\\) line \\([0-9]+\\)[,.\n]" 2 3 nil 1) |
("\\(.*\\) at \\([^ \n]+\\) line \\([0-9]+\\)[,.\n]" 2 3 nil 1) |
1026 |
; LaTeX warnings (fileless) ("\\(LaTeX \\(Warning\\|Error\\): .*\\) on input line \\([0-9]+\\)" 20 3 nil 1) |
;; LaTeX warnings (fileless) ("\\(LaTeX \\(Warning\\|Error\\): .*\\) on input line \\([0-9]+\\)" 20 3 nil 1) |
1027 |
; ant/javac |
;; ant/javac |
1028 |
(" *\\(\\[javac\\]\\)? *\\(\\([a-zA-Z]:\\)?[^:(\t\n]+\\)\:\\([0-9]+\\)\:[ \t\n]*\\(.+\\)" |
(" *\\(\\[javac\\]\\)? *\\(\\([a-zA-Z]:\\)?[^:(\t\n]+\\)\:\\([0-9]+\\)\:[ \t\n]*\\(.+\\)" |
1029 |
2 4 nil 5)) |
2 4 nil 5)) |
1030 |
;; compilation-error-regexp-alist) |
;; compilation-error-regexp-alist) |
1031 |
(flymake-reformat-err-line-patterns-from-compile-el compilation-error-regexp-alist-alist)) |
(flymake-reformat-err-line-patterns-from-compile-el compilation-error-regexp-alist-alist)) |
1032 |
"patterns for matching error/warning lines, (regexp file-idx line-idx err-text-idx). Use flymake-reformat-err-line-patterns-from-compile-el to add patterns from compile.el") |
"Patterns for matching error/warning lines. |
1033 |
|
\(REGEXP FILE-IDX LINE-IDX ERR-TEXT-IDX). |
1034 |
;(defcustom flymake-err-line-patterns |
Use `flymake-reformat-err-line-patterns-from-compile-el' to add patterns |
1035 |
; '( |
from compile.el") |
1036 |
; ; MS Visual C++ 6.0 |
|
1037 |
; ("\\(\\([a-zA-Z]:\\)?[^:(\t\n]+\\)(\\([0-9]+\\)) \: \\(\\(error\\|warning\\|fatal error\\) \\(C[0-9]+\\):[ \t\n]*\\(.+\\)\\)" |
;;(defcustom flymake-err-line-patterns |
1038 |
; 1 3 4) |
;; '( |
1039 |
; ; jikes |
;; ; MS Visual C++ 6.0 |
1040 |
; ("\\(\\([a-zA-Z]:\\)?[^:(\t\n]+\\)\:\\([0-9]+\\)\:[0-9]+\:[0-9]+\:[0-9]+\: \\(\\(Error\\|Warning\\|Caution\\):[ \t\n]*\\(.+\\)\\)" |
;; ("\\(\\([a-zA-Z]:\\)?[^:(\t\n]+\\)(\\([0-9]+\\)) \: \\(\\(error\\|warning\\|fatal error\\) \\(C[0-9]+\\):[ \t\n]*\\(.+\\)\\)" |
1041 |
; 1 3 4)) |
;; 1 3 4) |
1042 |
; "patterns for matching error/warning lines, (regexp file-idx line-idx err-text-idx)" |
;; ; jikes |
1043 |
; :group 'flymake |
;; ("\\(\\([a-zA-Z]:\\)?[^:(\t\n]+\\)\:\\([0-9]+\\)\:[0-9]+\:[0-9]+\:[0-9]+\: \\(\\(Error\\|Warning\\|Caution\\):[ \t\n]*\\(.+\\)\\)" |
1044 |
; :type '(repeat (string number number number)) |
;; 1 3 4)) |
1045 |
;) |
;; "patterns for matching error/warning lines, (regexp file-idx line-idx err-text-idx)" |
1046 |
|
;; :group 'flymake |
1047 |
|
;; :type '(repeat (string number number number)) |
1048 |
|
;;) |
1049 |
|
|
1050 |
(defun flymake-parse-line (line) |
(defun flymake-parse-line (line) |
1051 |
"Parse LINE to see if it is an error of warning. |
"Parse LINE to see if it is an error of warning. |
1138 |
(if (flymake-get-project-include-dirs-from-cache basedir) |
(if (flymake-get-project-include-dirs-from-cache basedir) |
1139 |
(progn |
(progn |
1140 |
(flymake-get-project-include-dirs-from-cache basedir)) |
(flymake-get-project-include-dirs-from-cache basedir)) |
1141 |
;else |
;;else |
1142 |
(let* ((command-line (concat "make -C\"" basedir "\" DUMPVARS=INCLUDE_DIRS dumpvars")) |
(let* ((command-line (concat "make -C\"" basedir "\" DUMPVARS=INCLUDE_DIRS dumpvars")) |
1143 |
(output (shell-command-to-string command-line)) |
(output (shell-command-to-string command-line)) |
1144 |
(lines (flymake-split-string output "\n")) |
(lines (flymake-split-string output "\n")) |
1322 |
(call-interactively 'compile)) |
(call-interactively 'compile)) |
1323 |
|
|
1324 |
(defvar flymake-is-running nil |
(defvar flymake-is-running nil |
1325 |
"If t, flymake syntax check process is running for the current buffer") |
"If t, flymake syntax check process is running for the current buffer.") |
1326 |
|
|
1327 |
(make-variable-buffer-local 'flymake-is-running) |
(make-variable-buffer-local 'flymake-is-running) |
1328 |
|
|
1366 |
(flymake-set-buffer-var buffer 'flymake-check-start-time check-start-time)) |
(flymake-set-buffer-var buffer 'flymake-check-start-time check-start-time)) |
1367 |
|
|
1368 |
(defvar flymake-check-was-interrupted nil |
(defvar flymake-check-was-interrupted nil |
1369 |
"t if syntax check was killed by flymake-compile") |
"Non-nil if syntax check was killed by `flymake-compile'.") |
1370 |
|
|
1371 |
(make-variable-buffer-local 'flymake-check-was-interrupted) |
(make-variable-buffer-local 'flymake-check-was-interrupted) |
1372 |
|
|
1383 |
|
|
1384 |
(defun flymake-on-timer-event (buffer) |
(defun flymake-on-timer-event (buffer) |
1385 |
"Start a syntax check for buffer BUFFER if necessary." |
"Start a syntax check for buffer BUFFER if necessary." |
1386 |
;+(flymake-log 3 "timer: running=%s, time=%s, cur-time=%s" (flymake-get-buffer-is-running buffer) (flymake-get-buffer-last-change-time buffer) (flymake-float-time)) |
;;+(flymake-log 3 "timer: running=%s, time=%s, cur-time=%s" (flymake-get-buffer-is-running buffer) (flymake-get-buffer-last-change-time buffer) (flymake-float-time)) |
1387 |
(when (and (bufferp buffer) (not (flymake-get-buffer-is-running buffer))) |
(when (and (bufferp buffer) (not (flymake-get-buffer-is-running buffer))) |
1388 |
(save-excursion |
(save-excursion |
1389 |
(set-buffer buffer) |
(set-buffer buffer) |
1479 |
nil))) |
nil))) |
1480 |
|
|
1481 |
(defun flymake-goto-file-and-line (file line) |
(defun flymake-goto-file-and-line (file line) |
1482 |
"Try to get buffer for file and goto line line in it" |
"Try to get buffer for FILE and goto line LINE in it." |
1483 |
(if (not (file-exists-p file)) |
(if (not (file-exists-p file)) |
1484 |
(flymake-log 1 "file %s does not exists" file) |
(flymake-log 1 "file %s does not exists" file) |
1485 |
(progn |
(progn |
1595 |
(setq after-change-functions (cons 'flymake-after-change-function after-change-functions)) |
(setq after-change-functions (cons 'flymake-after-change-function after-change-functions)) |
1596 |
(add-hook 'after-save-hook 'flymake-after-save-hook) |
(add-hook 'after-save-hook 'flymake-after-save-hook) |
1597 |
(add-hook 'kill-buffer-hook 'flymake-kill-buffer-hook) |
(add-hook 'kill-buffer-hook 'flymake-kill-buffer-hook) |
1598 |
;+(add-hook 'find-file-hooks 'flymake-find-file-hook) |
;;+(add-hook 'find-file-hook 'flymake-find-file-hook) |
1599 |
|
|
1600 |
(flymake-report-status (current-buffer) "" "") |
(flymake-report-status (current-buffer) "" "") |
1601 |
|
|
1613 |
(setq after-change-functions (delq 'flymake-after-change-function after-change-functions)) |
(setq after-change-functions (delq 'flymake-after-change-function after-change-functions)) |
1614 |
(remove-hook 'after-save-hook (function flymake-after-save-hook) t) |
(remove-hook 'after-save-hook (function flymake-after-save-hook) t) |
1615 |
(remove-hook 'kill-buffer-hook (function flymake-kill-buffer-hook) t) |
(remove-hook 'kill-buffer-hook (function flymake-kill-buffer-hook) t) |
1616 |
;+(remove-hook 'find-file-hooks (function flymake-find-file-hook) t) |
;;+(remove-hook 'find-file-hook (function flymake-find-file-hook) t) |
1617 |
|
|
1618 |
(flymake-delete-own-overlays (current-buffer)) |
(flymake-delete-own-overlays (current-buffer)) |
1619 |
|
|
1632 |
:type 'boolean) |
:type 'boolean) |
1633 |
|
|
1634 |
(defun flymake-after-change-function (start stop len) |
(defun flymake-after-change-function (start stop len) |
1635 |
"Start syntax check for current buffer if it isn't already running" |
"Start syntax check for current buffer if it isn't already running." |
1636 |
;+(flymake-log 0 "setting change time to %s" (flymake-float-time)) |
;;+(flymake-log 0 "setting change time to %s" (flymake-float-time)) |
1637 |
(let((new-text (buffer-substring start stop))) |
(let((new-text (buffer-substring start stop))) |
1638 |
(when (and flymake-start-syntax-check-on-newline (equal new-text "\n")) |
(when (and flymake-start-syntax-check-on-newline (equal new-text "\n")) |
1639 |
(flymake-log 3 "starting syntax check as new-line has been seen") |
(flymake-log 3 "starting syntax check as new-line has been seen") |
1652 |
(flymake-set-buffer-timer (current-buffer) nil))) |
(flymake-set-buffer-timer (current-buffer) nil))) |
1653 |
|
|
1654 |
(defun flymake-find-file-hook () |
(defun flymake-find-file-hook () |
1655 |
;+(when flymake-start-syntax-check-on-find-file |
;;+(when flymake-start-syntax-check-on-find-file |
1656 |
;+ (flymake-log 3 "starting syntax check on file open") |
;;+ (flymake-log 3 "starting syntax check on file open") |
1657 |
;+ (flymake-start-syntax-check-for-current-buffer) |
;;+ (flymake-start-syntax-check-for-current-buffer) |
1658 |
;+) |
;;+) |
1659 |
(when (and (not (local-variable-p 'flymake-mode (current-buffer))) |
(when (and (not (local-variable-p 'flymake-mode (current-buffer))) |
1660 |
(flymake-can-syntax-check-file (buffer-file-name (current-buffer)))) |
(flymake-can-syntax-check-file (buffer-file-name (current-buffer)))) |
1661 |
(flymake-mode) |
(flymake-mode) |
1696 |
(forward-char))) |
(forward-char))) |
1697 |
|
|
1698 |
(defun flymake-goto-line (line-no) |
(defun flymake-goto-line (line-no) |
1699 |
"goto-line, then skip whitespace" |
"Go to line LINE-NO, then skip whitespace." |
1700 |
(goto-line line-no) |
(goto-line line-no) |
1701 |
(flymake-skip-whitespace)) |
(flymake-skip-whitespace)) |
1702 |
|
|
1703 |
(defun flymake-goto-next-error () |
(defun flymake-goto-next-error () |
1704 |
"go to next error in err ring" |
"Go to next error in err ring." |
1705 |
(interactive) |
(interactive) |
1706 |
(let ((line-no (flymake-get-next-err-line-no (flymake-get-buffer-err-info (current-buffer)) (flymake-current-line-no)))) |
(let ((line-no (flymake-get-next-err-line-no (flymake-get-buffer-err-info (current-buffer)) (flymake-current-line-no)))) |
1707 |
(when (not line-no) |
(when (not line-no) |
1712 |
(flymake-log 1 "no errors in current buffer")))) |
(flymake-log 1 "no errors in current buffer")))) |
1713 |
|
|
1714 |
(defun flymake-goto-prev-error () |
(defun flymake-goto-prev-error () |
1715 |
"go to prev error in err ring" |
"Go to prev error in err ring." |
1716 |
(interactive) |
(interactive) |
1717 |
(let ((line-no (flymake-get-prev-err-line-no (flymake-get-buffer-err-info (current-buffer)) (flymake-current-line-no)))) |
(let ((line-no (flymake-get-prev-err-line-no (flymake-get-buffer-err-info (current-buffer)) (flymake-current-line-no)))) |
1718 |
(when (not line-no) |
(when (not line-no) |
1761 |
pos)) |
pos)) |
1762 |
|
|
1763 |
(defun flymake-delete-temp-directory (dir-name) |
(defun flymake-delete-temp-directory (dir-name) |
1764 |
"attempt to delete temp dir created by flymake-create-temp-with-folder-structure, do not fail on error." |
"Attempt to delete temp dir created by `flymake-create-temp-with-folder-structure', do not fail on error." |
1765 |
(let* ((temp-dir (flymake-get-temp-dir)) |
(let* ((temp-dir (flymake-get-temp-dir)) |
1766 |
(suffix (substring dir-name (1+ (length temp-dir)))) |
(suffix (substring dir-name (1+ (length temp-dir)))) |
1767 |
(slash-pos nil)) |
(slash-pos nil)) |
1768 |
|
|
1769 |
(while (> (length suffix) 0) |
(while (> (length suffix) 0) |
1770 |
;+(flymake-log 0 "suffix=%s" suffix) |
;;+(flymake-log 0 "suffix=%s" suffix) |
1771 |
(flymake-safe-delete-directory (file-truename (concat (flymake-ensure-ends-with-slash temp-dir) suffix))) |
(flymake-safe-delete-directory (file-truename (concat (flymake-ensure-ends-with-slash temp-dir) suffix))) |
1772 |
(setq slash-pos (flymake-strrchr suffix (string-to-char "/"))) |
(setq slash-pos (flymake-strrchr suffix (string-to-char "/"))) |
1773 |
(if slash-pos |
(if slash-pos |
1791 |
(flymake-set-buffer-last-change-time buffer nil))) |
(flymake-set-buffer-last-change-time buffer nil))) |
1792 |
|
|
1793 |
(defun flymake-get-real-file-name (buffer file-name-from-err-msg) |
(defun flymake-get-real-file-name (buffer file-name-from-err-msg) |
1794 |
"Translate file name from error message to `real' file name. |
"Translate file name from error message to \"real\" file name. |
1795 |
Return full-name. Names are real, not patched." |
Return full-name. Names are real, not patched." |
1796 |
(let* ((real-name nil) |
(let* ((real-name nil) |
1797 |
(source-file-name (buffer-file-name buffer)) |
(source-file-name (buffer-file-name buffer)) |
1798 |
(master-file-name (flymake-get-buffer-value buffer "master-file-name")) |
(master-file-name (flymake-get-buffer-value buffer "master-file-name")) |
1810 |
(setq file-name-from-err-msg source-file-name)) |
(setq file-name-from-err-msg source-file-name)) |
1811 |
|
|
1812 |
(setq real-name (flymake-get-full-patched-file-name file-name-from-err-msg base-dirs files)) |
(setq real-name (flymake-get-full-patched-file-name file-name-from-err-msg base-dirs files)) |
1813 |
; if real-name is nil, than file name from err msg is none of the files we've patched |
;; if real-name is nil, than file name from err msg is none of the files we've patched |
1814 |
(if (not real-name) |
(if (not real-name) |
1815 |
(setq real-name (flymake-get-full-nonpatched-file-name file-name-from-err-msg base-dirs))) |
(setq real-name (flymake-get-full-nonpatched-file-name file-name-from-err-msg base-dirs))) |
1816 |
(if (not real-name) |
(if (not real-name) |
1830 |
(let* ((this-dir (nth (1- base-dirs-count) base-dirs)) |
(let* ((this-dir (nth (1- base-dirs-count) base-dirs)) |
1831 |
(this-file (nth 0 (nth (1- file-count) files))) |
(this-file (nth 0 (nth (1- file-count) files))) |
1832 |
(this-real-name (nth 1 (nth (1- file-count) files)))) |
(this-real-name (nth 1 (nth (1- file-count) files)))) |
1833 |
;+(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) |
;;+(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) |
1834 |
(when (and this-dir this-file (flymake-same-files |
(when (and this-dir this-file (flymake-same-files |
1835 |
(flymake-get-absolute-file-name-basedir file-name-from-err-msg this-dir) |
(flymake-get-absolute-file-name-basedir file-name-from-err-msg this-dir) |
1836 |
this-file)) |
this-file)) |
1946 |
(flymake-simple-make-init-impl buffer 'flymake-create-temp-inplace t t "Makefile" 'flymake-get-make-cmdline)) |
(flymake-simple-make-init-impl buffer 'flymake-create-temp-inplace t t "Makefile" 'flymake-get-make-cmdline)) |
1947 |
|
|
1948 |
(defun flymake-master-make-init (buffer get-incl-dirs-f master-file-masks include-regexp-list) |
(defun flymake-master-make-init (buffer get-incl-dirs-f master-file-masks include-regexp-list) |
1949 |
"create make command line for a source file checked via master file compilation" |
"Create make command line for a source file checked via master file compilation." |
1950 |
(let* ((make-args nil) |
(let* ((make-args nil) |
1951 |
(temp-master-file-name (flymake-init-create-temp-source-and-master-buffer-copy |
(temp-master-file-name (flymake-init-create-temp-source-and-master-buffer-copy |
1952 |
buffer get-incl-dirs-f 'flymake-create-temp-inplace |
buffer get-incl-dirs-f 'flymake-create-temp-inplace |
1976 |
(flymake-simple-make-init-impl buffer 'flymake-create-temp-with-folder-structure nil nil "build.xml" 'flymake-get-ant-cmdline)) |
(flymake-simple-make-init-impl buffer 'flymake-create-temp-with-folder-structure nil nil "build.xml" 'flymake-get-ant-cmdline)) |
1977 |
|
|
1978 |
(defun flymake-simple-java-cleanup (buffer) |
(defun flymake-simple-java-cleanup (buffer) |
1979 |
"cleanup after flymake-simple-make-java-init -- delete temp file and dirs" |
"Cleanup after `flymake-simple-make-java-init' -- delete temp file and dirs." |
1980 |
(let* ((temp-source-file-name (flymake-get-buffer-value buffer "temp-source-file-name"))) |
(let* ((temp-source-file-name (flymake-get-buffer-value buffer "temp-source-file-name"))) |
1981 |
(flymake-safe-delete-file temp-source-file-name) |
(flymake-safe-delete-file temp-source-file-name) |
1982 |
(when temp-source-file-name |
(when temp-source-file-name |
1992 |
|
|
1993 |
;;;; tex-specific init-cleanup routines |
;;;; tex-specific init-cleanup routines |
1994 |
(defun flymake-get-tex-args (file-name) |
(defun flymake-get-tex-args (file-name) |
1995 |
;(list "latex" (list "-c-style-errors" file-name)) |
;;(list "latex" (list "-c-style-errors" file-name)) |
1996 |
(list "texify" (list "--pdf" "--tex-option=-c-style-errors" file-name))) |
(list "texify" (list "--pdf" "--tex-option=-c-style-errors" file-name))) |
1997 |
|
|
1998 |
(defun flymake-simple-tex-init (buffer) |
(defun flymake-simple-tex-init (buffer) |
2015 |
|
|
2016 |
(provide 'flymake) |
(provide 'flymake) |
2017 |
|
|
2018 |
;;; arch-tag: 8f0d6090-061d-4cac-8862-7c151c4a02dd |
;; arch-tag: 8f0d6090-061d-4cac-8862-7c151c4a02dd |
2019 |
;;; flymake.el ends here |
;;; flymake.el ends here |