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