annotate lisp/progmodes/flymake.el @ 57149:319d48feb1e9

*** empty log message ***
author Luc Teirlinck <teirllm@auburn.edu>
date Sun, 19 Sep 2004 01:11:35 +0000
parents 26e0724718e2
children fbcb259c5936
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
55822
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1 ;;; flymake.el -- a universal on-the-fly syntax checker
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
3 ;; Copyright (C) 2003 Free Software Foundation
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
4
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
5 ;; Author: Pavel Kobiakov <pk_at_work@yahoo.com>
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
6 ;; Maintainer: Pavel Kobiakov <pk_at_work@yahoo.com>
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
7 ;; Version: 0.3
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
8 ;; Keywords: c languages tools
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
9
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
10 ;; This file is part of GNU Emacs.
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
11
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
13 ;; it under the terms of the GNU General Public License as published by
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
14 ;; the Free Software Foundation; either version 2, or (at your option)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
15 ;; any later version.
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
16
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
17 ;; GNU Emacs is distributed in the hope that it will be useful,
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
20 ;; GNU General Public License for more details.
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
21
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
22 ;; You should have received a copy of the GNU General Public License
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
25 ;; Boston, MA 02111-1307, USA.
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
26
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
27 ;;; Commentary:
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
28 ;;
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
29 ;; Flymake is a minor Emacs mode performing on-the-fly syntax
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
30 ;; checks using the external syntax check tool (for C/C++ this
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
31 ;; is usually the compiler)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
32
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
33 ;;; Code:
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
34
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
35 ;;;_* Provide
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
36 (provide 'flymake)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
37
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
38 ;;;; [[ Overlay compatibility
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
39 (autoload 'make-overlay "overlay" "Overlay compatibility kit." t)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
40 (autoload 'overlayp "overlay" "Overlay compatibility kit." t)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
41 (autoload 'overlays-in "overlay" "Overlay compatibility kit." t)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
42 (autoload 'delete-overlay "overlay" "Overlay compatibility kit." t)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
43 (autoload 'overlay-put "overlay" "Overlay compatibility kit." t)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
44 (autoload 'overlay-get "overlay" "Overlay compatibility kit." t)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
45 ;;;; ]]
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
46
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
47 ;;;; [[ cross-emacs compatibility routines
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
48 (defvar flymake-emacs
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
49 (cond
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
50 ((string-match "XEmacs" emacs-version) 'xemacs)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
51 (t 'emacs)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
52 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
53 "Currently used emacs flavor"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
54 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
55
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
56 (defun flymake-makehash(&optional test)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
57 (cond
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
58 ((equal flymake-emacs 'xemacs) (if test (make-hash-table :test test) (make-hash-table)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
59 (t (makehash test))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
60 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
61 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
62
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
63 (defun flymake-time-to-float(&optional tm)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
64 "Convert `current-time` to a float number of seconds."
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
65 (multiple-value-bind (s0 s1 s2) (or tm (current-time))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
66 (+ (* (float (ash 1 16)) s0) (float s1) (* 0.0000001 s2)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
67 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
68 (defun flymake-float-time()
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
69 (cond
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
70 ((equal flymake-emacs 'xemacs) (flymake-time-to-float (current-time)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
71 (t (float-time))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
72 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
73 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
74
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
75 (defun flymake-replace-regexp-in-string(regexp rep str)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
76 (cond
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
77 ((equal flymake-emacs 'xemacs) (replace-in-string str regexp rep))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
78 (t (replace-regexp-in-string regexp rep str))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
79 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
80 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
81
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
82 (defun flymake-split-string-remove-empty-edges(str pattern)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
83 "split, then remove first and/or last in case it's empty"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
84 (let* ((splitted (split-string str pattern)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
85 (if (and (> (length splitted) 0) (= 0 (length (elt splitted 0))))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
86 (setq splitted (cdr splitted))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
87 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
88 (if (and (> (length splitted) 0) (= 0 (length (elt splitted (1- (length splitted))))))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
89 (setq splitted (reverse (cdr (reverse splitted))))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
90 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
91 splitted
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
92 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
93 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
94 (defun flymake-split-string(str pattern)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
95 (cond
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
96 ((equal flymake-emacs 'xemacs) (flymake-split-string-remove-empty-edges str pattern))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
97 (t (split-string str pattern))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
98 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
99 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
100
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
101 (defun flymake-get-temp-dir()
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
102 (cond
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
103 ((equal flymake-emacs 'xemacs) (temp-directory))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
104 (t temporary-file-directory)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
105 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
106 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
107
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
108 (defun flymake-line-beginning-position()
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
109 (save-excursion
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
110 (beginning-of-line)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
111 (point)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
112 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
113 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
114
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
115 (defun flymake-line-end-position()
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
116 (save-excursion
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
117 (end-of-line)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
118 (point)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
119 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
120 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
121
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
122 (defun flymake-popup-menu(pos menu-data)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
123 (cond
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
124 ((equal flymake-emacs 'xemacs)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
125 (let* ((x-pos (nth 0 (nth 0 pos)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
126 (y-pos (nth 1 (nth 0 pos)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
127 (fake-event-props '(button 1 x 1 y 1)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
128 (setq fake-event-props (plist-put fake-event-props 'x x-pos))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
129 (setq fake-event-props (plist-put fake-event-props 'y y-pos))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
130 (popup-menu (flymake-make-xemacs-menu menu-data) (make-event 'button-press fake-event-props))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
131 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
132 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
133 (t (x-popup-menu pos (flymake-make-emacs-menu menu-data)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
134 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
135 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
136
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
137 (defun flymake-make-emacs-menu(menu-data)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
138 (let* ((menu-title (nth 0 menu-data))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
139 (menu-items (nth 1 menu-data))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
140 (menu-commands nil))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
141
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
142 (setq menu-commands (mapcar (lambda (foo)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
143 (cons (nth 0 foo) (nth 1 foo)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
144 menu-items))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
145 (list menu-title (cons "" menu-commands))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
146 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
147 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
148
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
149 (defun flymake-nop()
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
150 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
151
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
152 (defun flymake-make-xemacs-menu(menu-data)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
153 (let* ((menu-title (nth 0 menu-data))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
154 (menu-items (nth 1 menu-data))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
155 (menu-commands nil))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
156 (setq menu-commands (mapcar (lambda (foo)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
157 (vector (nth 0 foo) (or (nth 1 foo) '(flymake-nop)) t))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
158 menu-items))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
159 (cons menu-title menu-commands)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
160 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
161 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
162
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
163 (defun flymake-xemacs-window-edges(&optional window)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
164 (let ((edges (window-pixel-edges window))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
165 tmp)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
166 (setq tmp edges)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
167 (setcar tmp (/ (car tmp) (face-width 'default)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
168 (setq tmp (cdr tmp))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
169 (setcar tmp (/ (car tmp) (face-height 'default)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
170 (setq tmp (cdr tmp))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
171 (setcar tmp (/ (car tmp) (face-width 'default)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
172 (setq tmp (cdr tmp))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
173 (setcar tmp (/ (car tmp) (face-height 'default)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
174 edges
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
175 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
176 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
177
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
178 (defun flymake-current-row()
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
179 "return current row in current frame"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
180 (cond
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
181 ((equal flymake-emacs 'xemacs) (count-lines (window-start) (point)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
182 (t (+ (car (cdr (window-edges))) (count-lines (window-start) (point))))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
183 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
184 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
185
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
186 (defun flymake-selected-frame()
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
187 (cond
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
188 ((equal flymake-emacs 'xemacs) (selected-window))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
189 (t (selected-frame))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
190 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
191 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
192
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
193 ;;;; ]]
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
194
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
195 (defcustom flymake-log-level -1
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
196 "Logging level, only messages with level > flymake-log-level will not be logged
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
197 -1 = NONE, 0 = ERROR, 1 = WARNING, 2 = INFO, 3 = DEBUG"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
198 :group 'flymake
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
199 :type 'integer
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
200 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
201
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
202 (defun flymake-log(level text &rest args)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
203 "Log a message with optional arguments"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
204 (if (<= level flymake-log-level)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
205 (let* ((msg (apply 'format text args)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
206 (message msg)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
207 ;(with-temp-buffer
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
208 ; (insert msg)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
209 ; (insert "\n")
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
210 ; (flymake-save-buffer-in-file (current-buffer) "d:/flymake.log" t) ; make log file name customizable
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
211 ;)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
212 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
213 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
214 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
215
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
216 (defun flymake-ins-after(list pos val)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
217 "insert val into list after position pos"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
218 (let ((tmp (copy-sequence list))) ; (???)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
219 (setcdr (nthcdr pos tmp) (cons val (nthcdr (1+ pos) tmp)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
220 tmp
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
221 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
222 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
223
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
224 (defun flymake-set-at(list pos val)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
225 "set val at position pos in list"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
226 (let ((tmp (copy-sequence list))) ; (???)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
227 (setcar (nthcdr pos tmp) val)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
228 tmp
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
229 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
230 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
231
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
232 (defvar flymake-pid-to-names(flymake-makehash)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
233 "pid -> source buffer name, output file name mapping"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
234 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
235
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
236 (defun flymake-reg-names(pid source-buffer-name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
237 "Save into in pid map"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
238 (unless (stringp source-buffer-name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
239 (error "invalid buffer name")
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
240 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
241 (puthash pid (list source-buffer-name) flymake-pid-to-names)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
242 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
243
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
244 (defun flymake-get-source-buffer-name(pid)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
245 "Return buffer name stored in pid map"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
246 (nth 0 (gethash pid flymake-pid-to-names))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
247 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
248
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
249 (defun flymake-unreg-names(pid)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
250 "Delete pid->buffer name mapping"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
251 (remhash pid flymake-pid-to-names)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
252 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
253
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
254 (defun flymake-get-buffer-var(buffer var-name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
255 "switch to buffer if necessary and return local variable var"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
256 (unless (bufferp buffer)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
257 (error "invalid buffer")
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
258 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
259
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
260 (if (eq buffer (current-buffer))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
261 (symbol-value var-name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
262 ;else
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
263 (save-excursion
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
264 (set-buffer buffer)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
265 (symbol-value var-name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
266 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
267 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
268 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
269
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
270 (defun flymake-set-buffer-var(buffer var-name var-value)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
271 "switch to buffer if necessary and set local variable var-name to var-value"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
272 (unless (bufferp buffer)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
273 (error "invalid buffer")
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
274 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
275
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
276 (if (eq buffer (current-buffer))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
277 (set var-name var-value)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
278 ;else
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
279 (save-excursion
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
280 (set-buffer buffer)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
281 (set var-name var-value)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
282 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
283 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
284 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
285
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
286 (defvar flymake-buffer-data(flymake-makehash)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
287 "data specific to syntax check tool, in name-value pairs"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
288 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
289 (make-variable-buffer-local 'flymake-buffer-data)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
290 (defun flymake-get-buffer-data(buffer)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
291 (flymake-get-buffer-var buffer 'flymake-buffer-data)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
292 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
293 (defun flymake-set-buffer-data(buffer data)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
294 (flymake-set-buffer-var buffer 'flymake-buffer-data data)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
295 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
296 (defun flymake-get-buffer-value(buffer name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
297 (gethash name (flymake-get-buffer-data buffer))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
298 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
299 (defun flymake-set-buffer-value(buffer name value)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
300 (puthash name value (flymake-get-buffer-data buffer))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
301 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
302
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
303 (defvar flymake-output-residual nil
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
304 ""
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
305 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
306 (make-variable-buffer-local 'flymake-output-residual)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
307 (defun flymake-get-buffer-output-residual(buffer)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
308 (flymake-get-buffer-var buffer 'flymake-output-residual)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
309 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
310 (defun flymake-set-buffer-output-residual(buffer residual)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
311 (flymake-set-buffer-var buffer 'flymake-output-residual residual)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
312 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
313
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
314 (defcustom flymake-allowed-file-name-masks '((".+\\.c$" flymake-simple-make-init flymake-simple-cleanup flymake-get-real-file-name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
315 (".+\\.cpp$" flymake-simple-make-init flymake-simple-cleanup flymake-get-real-file-name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
316 (".+\\.xml$" flymake-xml-init flymake-simple-cleanup flymake-get-real-file-name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
317 (".+\\.html?$" flymake-xml-init flymake-simple-cleanup flymake-get-real-file-name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
318 (".+\\.cs$" flymake-simple-make-init flymake-simple-cleanup flymake-get-real-file-name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
319 (".+\\.pl$" flymake-perl-init flymake-simple-cleanup flymake-get-real-file-name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
320 (".+\\.h$" flymake-master-make-header-init flymake-master-cleanup flymake-get-real-file-name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
321 (".+\\.java$" flymake-simple-make-java-init flymake-simple-java-cleanup flymake-get-real-file-name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
322 (".+[0-9]+\\.tex$" flymake-master-tex-init flymake-master-cleanup flymake-get-real-file-name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
323 (".+\\.tex$" flymake-simple-tex-init flymake-simple-cleanup flymake-get-real-file-name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
324 (".+\\.idl$" flymake-simple-make-init flymake-simple-cleanup flymake-get-real-file-name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
325 ; (".+\\.cpp$" 1)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
326 ; (".+\\.java$" 3)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
327 ; (".+\\.h$" 2 (".+\\.cpp$" ".+\\.c$")
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
328 ; ("[ \t]*#[ \t]*include[ \t]*\"\\([\w0-9/\\_\.]*[/\\]*\\)\\(%s\\)\"" 1 2))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
329 ; (".+\\.idl$" 1)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
330 ; (".+\\.odl$" 1)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
331 ; (".+[0-9]+\\.tex$" 2 (".+\\.tex$")
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
332 ; ("[ \t]*\\input[ \t]*{\\(.*\\)\\(%s\\)}" 1 2 ))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
333 ; (".+\\.tex$" 1)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
334 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
335 "*Files syntax checking is allowed for"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
336 :group 'flymake
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
337 :type '(repeat (string symbol symbol symbol))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
338 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
339
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
340 (defun flymake-get-file-name-mode-and-masks(file-name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
341 "return the corresponding entry from flymake-allowed-file-name-masks"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
342 (unless (stringp file-name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
343 (error "invalid file-name")
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
344 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
345 (let ((count (length flymake-allowed-file-name-masks))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
346 (idx 0)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
347 (mode-and-masks nil))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
348 (while (and (not mode-and-masks) (< idx count))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
349 (if (string-match (nth 0 (nth idx flymake-allowed-file-name-masks)) file-name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
350 (setq mode-and-masks (cdr (nth idx flymake-allowed-file-name-masks)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
351 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
352 (setq idx (1+ idx))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
353 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
354 (flymake-log 3 "file %s, init=%s" file-name (car mode-and-masks))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
355 mode-and-masks
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
356 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
357 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
358
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
359 (defun flymake-can-syntax-check-file(file-name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
360 "Determine whether we can syntax check file-name: nil if cannot, non-nil if can"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
361 (if (flymake-get-init-function file-name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
362 t
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
363 ;else
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
364 nil
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
365 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
366 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
367
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
368 (defun flymake-get-init-function(file-name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
369 "return init function to be used for the file"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
370 (let* ((init-f (nth 0 (flymake-get-file-name-mode-and-masks file-name))))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
371 ;(flymake-log 0 "calling %s" init-f)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
372 ;(funcall init-f (current-buffer))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
373 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
374 (nth 0 (flymake-get-file-name-mode-and-masks file-name))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
375 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
376
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
377 (defun flymake-get-cleanup-function(file-name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
378 "return cleanup function to be used for the file"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
379 (nth 1 (flymake-get-file-name-mode-and-masks file-name))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
380 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
381
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
382 (defun flymake-get-real-file-name-function(file-name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
383 ""
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
384 (or (nth 2 (flymake-get-file-name-mode-and-masks file-name)) 'flymake-get-real-file-name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
385 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
386
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
387 (defcustom flymake-buildfile-dirs '("." ".." "../.." "../../.." "../../../.." "../../../../.." "../../../../../.." "../../../../../../.." "../../../../../../../.." "../../../../../../../../.." "../../../../../../../../../.." "../../../../../../../../../../..")
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
388 "dirs to look for buildfile"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
389 :group 'flymake
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
390 :type '(repeat (string))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
391 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
392
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
393 (defvar flymake-find-buildfile-cache (flymake-makehash 'equal))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
394 (defun flymake-get-buildfile-from-cache(dir-name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
395 (gethash dir-name flymake-find-buildfile-cache)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
396 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
397 (defun flymake-add-buildfile-to-cache(dir-name buildfile)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
398 (puthash dir-name buildfile flymake-find-buildfile-cache)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
399 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
400 (defun flymake-clear-buildfile-cache()
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
401 (clrhash flymake-find-buildfile-cache)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
402 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
403
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
404 (defun flymake-find-buildfile(buildfile-name source-dir-name dirs)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
405 "find buildfile (i.e. Makefile, build.xml, etc.) starting from current directory. Return its path or nil if not found"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
406 (if (flymake-get-buildfile-from-cache source-dir-name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
407 (progn
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
408 (flymake-get-buildfile-from-cache source-dir-name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
409 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
410 ;else
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
411 (let* ((buildfile-dir nil)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
412 (buildfile nil)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
413 (dir-count (length dirs))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
414 (dir-idx 0)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
415 (found nil))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
416
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
417 (while (and (not found) (< dir-idx dir-count))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
418
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
419 (setq buildfile-dir (concat source-dir-name (nth dir-idx dirs)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
420 (setq buildfile (concat buildfile-dir "/" buildfile-name))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
421
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
422 (when (file-exists-p buildfile)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
423 (setq found t)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
424 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
425
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
426 (setq dir-idx (1+ dir-idx))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
427 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
428 (if found
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
429 (progn
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
430 (flymake-log 3 "found buildfile at %s/%s" buildfile-dir buildfile-name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
431 (flymake-add-buildfile-to-cache source-dir-name buildfile-dir)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
432 buildfile-dir
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
433 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
434 ;else
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
435 (progn
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
436 (flymake-log 3 "buildfile for %s not found" source-dir-name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
437 nil
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
438 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
439 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
440 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
441 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
442 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
443
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
444 (defun flymake-fix-path-name(name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
445 "replace all occurences of '\' with '/'"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
446 (when name
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
447 (let* ((new-name (flymake-replace-regexp-in-string "[\\]" "/" (expand-file-name name)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
448 (last-char (elt new-name (1- (length new-name)))))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
449 (setq new-name (flymake-replace-regexp-in-string "\\./" "" new-name))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
450 (if (equal "/" (char-to-string last-char))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
451 (setq new-name (substring new-name 0 (1- (length new-name))))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
452 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
453 new-name
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
454 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
455 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
456 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
457
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
458 (defun flymake-same-files(file-name-one file-name-two)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
459 "t if file-name-one and file-name-two actually point to the same file"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
460 (equal (flymake-fix-path-name file-name-one) (flymake-fix-path-name file-name-two))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
461 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
462
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
463 (defun flymake-ensure-ends-with-slash(path)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
464 (if (not (= (elt path (1- (length path))) (string-to-char "/")))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
465 (concat path "/")
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
466 ;else
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
467 path
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
468 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
469 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
470
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
471 (defun flymake-get-common-path-prefix(string-one string-two)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
472 "return common prefix for two paths"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
473 (when (and string-one string-two)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
474 (let* ((slash-pos-one -1)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
475 (slash-pos-two -1)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
476 (done nil)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
477 (prefix nil))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
478
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
479 (setq string-one (flymake-ensure-ends-with-slash string-one))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
480 (setq string-two (flymake-ensure-ends-with-slash string-two))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
481
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
482 (while (not done)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
483 (setq slash-pos-one (string-match "/" string-one (1+ slash-pos-one)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
484 (setq slash-pos-two (string-match "/" string-two (1+ slash-pos-two)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
485
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
486 (if (and slash-pos-one slash-pos-two
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
487 (= slash-pos-one slash-pos-two)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
488 (string= (substring string-one 0 slash-pos-one) (substring string-two 0 slash-pos-two)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
489 (progn
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
490 (setq prefix (substring string-one 0 (1+ slash-pos-one)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
491 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
492 ;else
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
493 (setq done t)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
494 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
495 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
496 prefix
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
497 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
498 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
499 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
500
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
501 (defun flymake-build-relative-path(from-dir to-dir)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
502 "return rel: from-dir/rel == to-dir"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
503 (if (not (equal (elt from-dir 0) (elt to-dir 0)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
504 (error "first chars in paths %s, %s must be equal (same drive)" from-dir to-dir)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
505 ;else
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
506 (let* ((from (flymake-ensure-ends-with-slash (flymake-fix-path-name from-dir)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
507 (to (flymake-ensure-ends-with-slash (flymake-fix-path-name to-dir)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
508 (prefix (flymake-get-common-path-prefix from to))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
509 (from-suffix (substring from (length prefix)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
510 (up-count (length (flymake-split-string from-suffix "[/]")))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
511 (to-suffix (substring to (length prefix)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
512 (idx 0)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
513 (rel nil))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
514
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
515 (if (and (> (length to-suffix) 0) (equal "/" (char-to-string (elt to-suffix 0))))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
516 (setq to-suffix (substring to-suffix 1))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
517 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
518
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
519 (while (< idx up-count)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
520 (if (> (length rel) 0)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
521 (setq rel (concat rel "/"))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
522 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
523 (setq rel (concat rel ".."))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
524 (setq idx (1+ idx))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
525 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
526 (if (> (length rel) 0)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
527 (setq rel (concat rel "/"))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
528 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
529 (if (> (length to-suffix) 0)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
530 (setq rel (concat rel to-suffix))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
531 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
532
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
533 (or rel "./")
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
534 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
535 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
536 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
537
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
538 (defcustom flymake-master-file-dirs '("." "./src" "./UnitTest")
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
539 "dirs where to llok for master files"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
540 :group 'flymake
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
541 :type '(repeat (string))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
542 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
543
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
544 (defcustom flymake-master-file-count-limit 32
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
545 "max number of master files to check"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
546 :group 'flymake
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
547 :type 'integer
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
548 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
549
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
550 (defun flymake-find-possible-master-files(file-name master-file-dirs masks)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
551 "find (by name and location) all posible master files, which are .cpp and .c for and .h.
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
552 Files are searched for starting from the .h directory and max max-level parent dirs.
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
553 File contents are not checked."
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
554 (let* ((dir-idx 0)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
555 (dir-count (length master-file-dirs))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
556 (files nil)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
557 (done nil)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
558 (masks-count (length masks)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
559
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
560 (while (and (not done) (< dir-idx dir-count))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
561 (let* ((dir (concat (flymake-fix-path-name (file-name-directory file-name)) "/" (nth dir-idx master-file-dirs)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
562 (masks-idx 0))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
563 (while (and (file-exists-p dir) (not done) (< masks-idx masks-count))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
564 (let* ((mask (nth masks-idx masks))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
565 (dir-files (directory-files dir t mask))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
566 (file-count (length dir-files))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
567 (file-idx 0))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
568
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
569 (flymake-log 3 "dir %s, %d file(s) for mask %s" dir file-count mask)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
570 (while (and (not done) (< file-idx file-count))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
571 (when (not (file-directory-p (nth file-idx dir-files)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
572 (setq files (cons (nth file-idx dir-files) files))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
573 (when (>= (length files) flymake-master-file-count-limit)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
574 (flymake-log 3 "master file count limit (%d) reached" flymake-master-file-count-limit)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
575 (setq done t)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
576 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
577 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
578 (setq file-idx (1+ file-idx))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
579 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
580 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
581 (setq masks-idx (1+ masks-idx))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
582 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
583 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
584 (setq dir-idx (1+ dir-idx))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
585 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
586 (when files
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
587 (setq flymake-included-file-name (file-name-nondirectory file-name))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
588 (setq files (sort files 'flymake-master-file-compare))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
589 (setq flymake-included-file-name nil)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
590 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
591 (flymake-log 3 "found %d possible master file(s)" (length files))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
592 files
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
593 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
594 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
595
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
596 (defvar flymake-included-file-name nil ; this is used to pass a parameter to a sort predicate below
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
597 ""
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
598 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
599
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
600 (defun flymake-master-file-compare(file-one file-two)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
601 "used in sort to move most possible file names to the beginning of the list (File.h -> File.cpp moved to top"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
602 (and (equal (file-name-sans-extension flymake-included-file-name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
603 (file-name-sans-extension (file-name-nondirectory file-one)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
604 (not (equal file-one file-two))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
605 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
606 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
607
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
608 (defcustom flymake-check-file-limit 8192
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
609 "max number of chars to look at when checking possible master file"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
610 :group 'flymake
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
611 :type 'integer
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
612 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
613
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
614 (defun flymake-check-patch-master-file-buffer(master-file-temp-buffer
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
615 master-file-name patched-master-file-name
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
616 source-file-name patched-source-file-name
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
617 include-dirs regexp-list)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
618 "check whether master-file-name is indeed a master file for source-file-name.
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
619 For .cpp master file this means it includes source-file-name (.h).
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
620 If yes, patch a copy of master-file-name to include patched-source-file-name instead of source-file-name.
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
621 Whenether a buffer for master-file-name exists, use it as a source instead of reading master file from disk"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
622 (let* ((found nil)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
623 (regexp (format (nth 0 regexp-list) ; "[ \t]*#[ \t]*include[ \t]*\"\\([\w0-9/\\_\.]*[/\\]*\\)\\(%s\\)\""
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
624 (file-name-nondirectory source-file-name)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
625 (path-idx (nth 1 regexp-list))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
626 (name-idx (nth 2 regexp-list))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
627 (inc-path nil)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
628 (inc-name nil)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
629 (search-limit flymake-check-file-limit))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
630 (save-excursion
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
631 (unwind-protect
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
632 (progn
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
633 (set-buffer master-file-temp-buffer)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
634 (when (> search-limit (point-max))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
635 (setq search-limit (point-max))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
636 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
637 (flymake-log 3 "checking %s against regexp %s" master-file-name regexp)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
638 (goto-char (point-min))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
639 (while (and (< (point) search-limit) (re-search-forward regexp search-limit t))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
640 (let* ((match-beg (match-beginning name-idx))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
641 (match-end (match-end name-idx)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
642
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
643 (flymake-log 3 "found possible match for %s" (file-name-nondirectory source-file-name))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
644 (setq inc-path (match-string path-idx))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
645 (setq inc-name (match-string name-idx))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
646 (when (string= inc-name (file-name-nondirectory source-file-name))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
647 (flymake-log 3 "inc-path=%s inc-name=%s" inc-path inc-name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
648 (when (flymake-check-include source-file-name inc-path inc-name include-dirs)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
649 (setq found t)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
650 ; replace-match is not used here as it fails in xemacs with
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
651 ; 'last match not a buffer' error as check-includes calls replace-in-string
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
652 (flymake-replace-region (current-buffer) match-beg match-end
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
653 (file-name-nondirectory patched-source-file-name))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
654 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
655 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
656 (forward-line 1)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
657 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
658 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
659 (when found
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
660 (flymake-save-buffer-in-file (current-buffer) patched-master-file-name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
661 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
662 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
663 ;+(flymake-log 3 "killing buffer %s" (buffer-name master-file-temp-buffer))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
664 (kill-buffer master-file-temp-buffer)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
665 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
666 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
667 ;+(flymake-log 3 "check-patch master file %s: %s" master-file-name found)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
668 (when found
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
669 (flymake-log 2 "found master file %s" master-file-name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
670 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
671 found
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
672 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
673 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
674
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
675 (defun flymake-replace-region(buffer beg end rep)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
676 "replace text in buffer in region (beg; end) with rep"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
677 (save-excursion
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
678 (delete-region beg end)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
679 (goto-char beg)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
680 (insert rep)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
681 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
682 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
683
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
684 (defun flymake-read-file-to-temp-buffer(file-name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
685 "isert contents of file-name into newly created temp buffer"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
686 (let* ((temp-buffer (get-buffer-create (generate-new-buffer-name (concat "flymake:" (file-name-nondirectory file-name))))))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
687 (save-excursion
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
688 (set-buffer temp-buffer)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
689 (insert-file-contents file-name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
690 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
691 temp-buffer
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
692 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
693 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
694
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
695 (defun flymake-copy-buffer-to-temp-buffer(buffer)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
696 "copy contents of buffer into newly created temp buffer"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
697 (let ((contents nil)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
698 (temp-buffer nil))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
699 (save-excursion
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
700 (set-buffer buffer)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
701 (setq contents (buffer-string))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
702
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
703 (setq temp-buffer (get-buffer-create (generate-new-buffer-name (concat "flymake:" (buffer-name buffer)))))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
704 (set-buffer temp-buffer)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
705 (insert contents)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
706 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
707 temp-buffer
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
708 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
709 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
710
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
711 (defun flymake-check-include(source-file-name inc-path inc-name include-dirs)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
712 "t if source-file-name is the one found via include dirs using inc-path and inc-name"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
713 (if (file-name-absolute-p inc-path)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
714 (flymake-same-files source-file-name (concat inc-path "/" inc-name))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
715 ;else
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
716 (let* ((count (length include-dirs))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
717 (idx 0)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
718 (file-name nil)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
719 (found nil))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
720 (while (and (not found) (< idx count))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
721 (setq file-name (concat (file-name-directory source-file-name) "/" (nth idx include-dirs)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
722 (if (> (length inc-path) 0)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
723 (setq file-name (concat file-name "/" inc-path))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
724 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
725 (setq file-name (concat file-name "/" inc-name))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
726 (when (flymake-same-files source-file-name file-name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
727 (setq found t)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
728 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
729 (setq idx (1+ idx))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
730 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
731 found
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
732 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
733 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
734 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
735
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
736 (defun flymake-find-buffer-for-file(file-name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
737 "buffer if there exists a buffer visiting file-name, nil otherwise"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
738 (let ((buffer-name (get-file-buffer file-name)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
739 (if buffer-name
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
740 (get-buffer buffer-name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
741 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
742 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
743 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
744
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
745 (defun flymake-create-master-file(source-file-name patched-source-file-name get-incl-dirs-f create-temp-f masks include-regexp-list)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
746 "save source-file-name with a different name, find master file, patch it and save it to."
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
747 (let* ((possible-master-files (flymake-find-possible-master-files source-file-name flymake-master-file-dirs masks))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
748 (master-file-count (length possible-master-files))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
749 (idx 0)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
750 (temp-buffer nil)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
751 (master-file-name nil)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
752 (patched-master-file-name nil)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
753 (found nil))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
754
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
755 (while (and (not found) (< idx master-file-count))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
756 (setq master-file-name (nth idx possible-master-files))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
757 (setq patched-master-file-name (funcall create-temp-f master-file-name "flymake_master"))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
758 (if (flymake-find-buffer-for-file master-file-name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
759 (setq temp-buffer (flymake-copy-buffer-to-temp-buffer (flymake-find-buffer-for-file master-file-name)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
760 ;else
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
761 (setq temp-buffer (flymake-read-file-to-temp-buffer master-file-name))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
762 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
763 (setq found
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
764 (flymake-check-patch-master-file-buffer
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
765 temp-buffer
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
766 master-file-name
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
767 patched-master-file-name
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
768 source-file-name
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
769 patched-source-file-name
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
770 (funcall get-incl-dirs-f (file-name-directory master-file-name))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
771 include-regexp-list))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
772 (setq idx (1+ idx))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
773 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
774 (if found
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
775 (list master-file-name patched-master-file-name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
776 ;else
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
777 (progn
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
778 (flymake-log 3 "none of %d master file(s) checked includes %s" master-file-count
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
779 (file-name-nondirectory source-file-name))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
780 nil
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
781 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
782 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
783 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
784 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
785
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
786 (defun flymake-save-buffer-in-file(buffer file-name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
787 (or buffer
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
788 (error "invalid buffer")
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
789 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
790 (save-excursion
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
791 (save-restriction
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
792 (set-buffer buffer)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
793 (widen)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
794 (make-directory (file-name-directory file-name) 1)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
795 (write-region (point-min) (point-max) file-name nil 566)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
796 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
797 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
798 (flymake-log 3 "saved buffer %s in file %s" (buffer-name buffer) file-name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
799 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
800
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
801 (defun flymake-save-string-to-file(file-name data)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
802 "save string data to file file-name"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
803 (write-region data nil file-name nil 566)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
804 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
805
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
806 (defun flymake-read-file-to-string(file-name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
807 "read file contents and return them as a string"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
808 (with-temp-buffer
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
809 (insert-file-contents file-name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
810 (buffer-substring (point-min) (point-max))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
811 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
812 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
813
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
814 (defun flymake-process-filter(process output)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
815 "flymake process filter: parse output, highlight err lines"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
816 (let* ((pid (process-id process))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
817 (source-buffer (get-buffer (flymake-get-source-buffer-name pid))))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
818
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
819 (flymake-log 3 "received %d byte(s) of output from process %d" (length output) pid)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
820 (when source-buffer
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
821 (flymake-parse-output-and-residual source-buffer output)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
822 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
823 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
824 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
825
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
826 (defun flymake-process-sentinel(process event)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
827 "Sentinel for syntax check buffers"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
828 (if (memq (process-status process) '(signal exit))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
829 (let*((exit-status (process-exit-status process))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
830 (command (process-command process))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
831 (pid (process-id process))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
832 (source-buffer (get-buffer (flymake-get-source-buffer-name pid)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
833 (cleanup-f (flymake-get-cleanup-function (buffer-file-name source-buffer))))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
834
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
835 (flymake-log 2 "process %d exited with code %d" pid exit-status)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
836 (condition-case err
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
837 (progn
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
838 (flymake-log 3 "cleaning up using %s" cleanup-f)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
839 (funcall cleanup-f source-buffer)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
840
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
841 (flymake-unreg-names pid)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
842 (delete-process process)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
843
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
844 (when source-buffer
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
845 (save-excursion
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
846 (set-buffer source-buffer)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
847
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
848 (flymake-parse-residual source-buffer)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
849 (flymake-post-syntax-check source-buffer)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
850 (flymake-set-buffer-is-running source-buffer nil)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
851 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
852 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
853 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
854 (error
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
855 (let ((err-str (format "Error in process sentinel for buffer %s: %s"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
856 source-buffer (error-message-string err))))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
857 (flymake-log 0 err-str)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
858 (flymake-set-buffer-is-running source-buffer nil)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
859 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
860 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
861 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
862 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
863 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
864 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
865
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
866 (defun flymake-post-syntax-check(source-buffer)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
867 ""
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
868 (flymake-set-buffer-err-info source-buffer (flymake-get-buffer-new-err-info source-buffer))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
869 (flymake-set-buffer-new-err-info source-buffer nil)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
870
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
871 (flymake-set-buffer-err-info source-buffer (flymake-fix-line-numbers
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
872 (flymake-get-buffer-err-info source-buffer)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
873 1
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
874 (flymake-count-lines source-buffer)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
875 (flymake-delete-own-overlays source-buffer)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
876 (flymake-highlight-err-lines source-buffer (flymake-get-buffer-err-info source-buffer))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
877
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
878 (let ((err-count (flymake-get-err-count (flymake-get-buffer-err-info source-buffer) "e"))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
879 (warn-count (flymake-get-err-count (flymake-get-buffer-err-info source-buffer) "w")))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
880
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
881 (flymake-log 2 "%s: %d error(s), %d warning(s) in %.2f second(s)"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
882 (buffer-name source-buffer) err-count warn-count
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
883 (- (flymake-float-time) (flymake-get-buffer-check-start-time source-buffer)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
884 (flymake-set-buffer-check-start-time source-buffer nil)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
885 (if (and (equal 0 err-count) (equal 0 warn-count))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
886 (if (equal 0 exit-status)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
887 (flymake-report-status source-buffer "" "") ; PASSED
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
888 ;else
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
889 (if (not (flymake-get-buffer-check-was-interrupted source-buffer))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
890 (flymake-report-fatal-status (current-buffer) "CFGERR"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
891 (format "Configuration error has occured while running %s" command))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
892 ;else
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
893 (flymake-report-status source-buffer nil "") ; "STOPPED"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
894 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
895 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
896 ;else
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
897 (flymake-report-status source-buffer (format "%d/%d" err-count warn-count) "")
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
898 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
899 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
900 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
901
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
902 (defun flymake-parse-output-and-residual(source-buffer output)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
903 "split output into lines, merge in residual if necessary"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
904 (save-excursion
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
905 (set-buffer source-buffer)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
906 (let* ((buffer-residual (flymake-get-buffer-output-residual source-buffer))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
907 (total-output (if buffer-residual (concat buffer-residual output) output))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
908 (lines-and-residual (flymake-split-output total-output))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
909 (lines (nth 0 lines-and-residual))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
910 (new-residual (nth 1 lines-and-residual)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
911
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
912 (flymake-set-buffer-output-residual source-buffer new-residual)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
913 (flymake-set-buffer-new-err-info source-buffer (flymake-parse-err-lines
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
914 (flymake-get-buffer-new-err-info source-buffer)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
915 source-buffer lines))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
916 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
917 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
918 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
919
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
920 (defun flymake-parse-residual(source-buffer)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
921 "parse residual if it's non empty"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
922 (save-excursion
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
923 (set-buffer source-buffer)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
924 (when (flymake-get-buffer-output-residual source-buffer)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
925 (flymake-set-buffer-new-err-info source-buffer (flymake-parse-err-lines
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
926 (flymake-get-buffer-new-err-info source-buffer)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
927 source-buffer
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
928 (list (flymake-get-buffer-output-residual source-buffer))))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
929 (flymake-set-buffer-output-residual source-buffer nil)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
930 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
931 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
932 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
933
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
934 (defvar flymake-err-info nil
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
935 "sorted list of line numbers and lists of err info in the form (file, err-text)."
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
936 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
937 (make-variable-buffer-local 'flymake-err-info)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
938 (defun flymake-get-buffer-err-info(buffer)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
939 (flymake-get-buffer-var buffer 'flymake-err-info)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
940 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
941 (defun flymake-set-buffer-err-info(buffer err-info)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
942 (flymake-set-buffer-var buffer 'flymake-err-info err-info)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
943 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
944 (defun flymake-er-make-er(line-no line-err-info-list)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
945 (list line-no line-err-info-list)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
946 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
947 (defun flymake-er-get-line(err-info)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
948 (nth 0 err-info)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
949 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
950 (defun flymake-er-get-line-err-info-list(err-info)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
951 (nth 1 err-info)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
952 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
953
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
954 (defvar flymake-new-err-info nil
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
955 "the same as flymake -err-info, effective when a syntax check is in progress"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
956 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
957 (make-variable-buffer-local 'flymake-new-err-info)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
958 (defun flymake-get-buffer-new-err-info(buffer)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
959 (flymake-get-buffer-var buffer 'flymake-new-err-info)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
960 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
961 (defun flymake-set-buffer-new-err-info(buffer new-err-info)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
962 (flymake-set-buffer-var buffer 'flymake-new-err-info new-err-info)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
963 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
964
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
965 ;; getters/setters for line-err-info: (file, line, type, text).
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
966 (defun flymake-ler-make-ler(file line type text &optional full-file)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
967 (list file line type text full-file)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
968 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
969 (defun flymake-ler-get-file(line-err-info)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
970 (nth 0 line-err-info)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
971 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
972 (defun flymake-ler-get-line(line-err-info)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
973 (nth 1 line-err-info)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
974 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
975 (defun flymake-ler-get-type(line-err-info)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
976 (nth 2 line-err-info)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
977 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
978 (defun flymake-ler-get-text(line-err-info)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
979 (nth 3 line-err-info)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
980 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
981 (defun flymake-ler-get-full-file(line-err-info)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
982 (nth 4 line-err-info)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
983 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
984 (defun flymake-ler-set-file(line-err-info file)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
985 (flymake-ler-make-ler file
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
986 (flymake-ler-get-line line-err-info)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
987 (flymake-ler-get-type line-err-info)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
988 (flymake-ler-get-text line-err-info)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
989 (flymake-ler-get-full-file line-err-info))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
990 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
991 (defun flymake-ler-set-full-file(line-err-info full-file)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
992 (flymake-ler-make-ler (flymake-ler-get-file line-err-info)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
993 (flymake-ler-get-line line-err-info)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
994 (flymake-ler-get-type line-err-info)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
995 (flymake-ler-get-text line-err-info)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
996 full-file)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
997 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
998 (defun flymake-ler-set-line(line-err-info line)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
999 (flymake-ler-make-ler (flymake-ler-get-file line-err-info)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1000 line
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1001 (flymake-ler-get-type line-err-info)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1002 (flymake-ler-get-text line-err-info)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1003 (flymake-ler-get-full-file line-err-info))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1004 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1005
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1006 (defun flymake-get-line-err-count(line-err-info-list type)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1007 "return number of errors of specified type - e or w"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1008 (let* ((idx 0)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1009 (count (length line-err-info-list))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1010 (err-count 0))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1011
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1012 (while (< idx count)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1013 (when (equal type (flymake-ler-get-type (nth idx line-err-info-list)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1014 (setq err-count (1+ err-count))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1015 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1016 (setq idx (1+ idx))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1017 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1018 err-count
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1019 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1020 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1021
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1022 (defun flymake-get-err-count(err-info-list type)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1023 "return number of errors of specified type for the err-info-list"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1024 (let* ((idx 0)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1025 (count (length err-info-list))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1026 (err-count 0))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1027 (while (< idx count)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1028 (setq err-count (+ err-count (flymake-get-line-err-count (nth 1 (nth idx err-info-list)) type)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1029 (setq idx (1+ idx))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1030 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1031 err-count
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1032 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1033 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1034
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1035 (defun flymake-fix-line-numbers(err-info-list min-line max-line)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1036 "replace line-numbers < min-line with min-line and > max-line with max-line - as some compilers might report line number outside the file being compiled"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1037 (let* ((count (length err-info-list))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1038 (err-info nil)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1039 (line 0))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1040 (while (> count 0)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1041 (setq err-info (nth (1- count) err-info-list))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1042 (setq line (flymake-er-get-line err-info))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1043 (when (or (< line min-line) (> line max-line))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1044 (setq line (if (< line min-line) min-line max-line))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1045 (setq err-info-list (flymake-set-at err-info-list (1- count)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1046 (flymake-er-make-er line
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1047 (flymake-er-get-line-err-info-list err-info))))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1048 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1049 (setq count (1- count))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1050 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1051 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1052 err-info-list
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1053 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1054
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1055 (defun flymake-highlight-err-lines(buffer err-info-list)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1056 "highlight err-lines in buffer using info from err-info-list"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1057 (save-excursion
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1058 (set-buffer buffer)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1059 (let* ((idx 0)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1060 (count (length err-info-list)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1061 (while (< idx count)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1062 (flymake-highlight-line (car (nth idx err-info-list)) (nth 1 (nth idx err-info-list)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1063 (setq idx (1+ idx))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1064 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1065 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1066 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1067 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1068
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1069 (defun flymake-overlay-p(ov)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1070 "Determine whether overlay was created by flymake"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1071 (and (overlayp ov) (overlay-get ov 'flymake-overlay))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1072 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1073
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1074 (defun flymake-make-overlay(beg end tooltip-text face mouse-face)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1075 "Allocate a flymake overlay in range beg end"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1076 (when (not (flymake-region-has-flymake-overlays beg end))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1077 (let ((ov (make-overlay beg end nil t t)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1078 (overlay-put ov 'face face)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1079 (overlay-put ov 'mouse-face mouse-face)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1080 (overlay-put ov 'help-echo tooltip-text)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1081 (overlay-put ov 'flymake-overlay t)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1082 (overlay-put ov 'priority 100)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1083 ;+(flymake-log 3 "created overlay %s" ov)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1084 ov
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1085 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1086 (flymake-log 3 "created an overlay at (%d-%d)" beg end)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1087 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1088 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1089
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1090 (defun flymake-delete-own-overlays(buffer)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1091 "Delete all flymake overlays in buffer"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1092 (save-excursion
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1093 (set-buffer buffer)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1094 (let ((ov (overlays-in (point-min) (point-max))))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1095 (while (consp ov)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1096 (when (flymake-overlay-p (car ov))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1097 (delete-overlay (car ov))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1098 ;+(flymake-log 3 "deleted overlay %s" ov)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1099 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1100 (setq ov (cdr ov))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1101 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1102 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1103 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1104 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1105
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1106 (defun flymake-region-has-flymake-overlays(beg end)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1107 "t if specified regions has at least one flymake overlay, nil otrherwise"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1108 (let ((ov (overlays-in beg end))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1109 (has-flymake-overlays nil))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1110 (while (consp ov)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1111 (when (flymake-overlay-p (car ov))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1112 (setq has-flymake-overlays t)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1113 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1114 (setq ov (cdr ov))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1115 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1116 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1117 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1118
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1119 (defface flymake-errline-face
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1120 ;+ '((((class color)) (:foreground "OrangeRed" :bold t :underline t))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1121 ;+ '((((class color)) (:underline "OrangeRed"))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1122 '((((class color)) (:background "LightPink"))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1123 (t (:bold t)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1124 "Face used for marking error lines"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1125 :group 'flymake
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1126 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1127
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1128 (defface flymake-warnline-face
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1129 '((((class color)) (:background "LightBlue2"))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1130 (t (:bold t)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1131 "Face used for marking warning lines"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1132 :group 'flymake
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1133 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1134
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1135
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1136 (defun flymake-highlight-line(line-no line-err-info-list)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1137 "highlight line line-no in current buffer, perhaps use text from line-err-info-list to enhance highlighting"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1138 (goto-line line-no)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1139 (let* ((line-beg (flymake-line-beginning-position))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1140 (line-end (flymake-line-end-position))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1141 (beg line-beg)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1142 (end line-end)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1143 (tooltip-text (flymake-ler-get-text (nth 0 line-err-info-list)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1144 (face nil))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1145
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1146 (goto-char line-beg)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1147 (while (looking-at "[ \t]")
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1148 (forward-char)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1149 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1150
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1151 (setq beg (point))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1152
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1153 (goto-char line-end)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1154 (while (and (looking-at "[ \t\r\n]") (> (point) 1))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1155 (backward-char)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1156 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1157
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1158 (setq end (1+ (point)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1159
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1160 (when (<= end beg)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1161 (setq beg line-beg)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1162 (setq end line-end)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1163 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1164 (when (= end beg)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1165 (goto-char end)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1166 (forward-line)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1167 (setq end (point))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1168 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1169 (if (> (flymake-get-line-err-count line-err-info-list "e") 0)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1170 (setq face 'flymake-errline-face)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1171 ;else
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1172 (setq face 'flymake-warnline-face)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1173 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1174 (flymake-make-overlay beg end tooltip-text face nil)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1175 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1176 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1177
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1178 (defun flymake-parse-err-lines(err-info-list source-buffer lines)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1179 "parse err lines, store info in err-info-list"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1180 (let* ((count (length lines))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1181 (idx 0)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1182 (line-err-info nil)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1183 (real-file-name nil)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1184 (source-file-name (buffer-file-name source-buffer))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1185 (get-real-file-name-f (flymake-get-real-file-name-function source-file-name)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1186
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1187 (while (< idx count)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1188 (setq line-err-info (flymake-parse-line (nth idx lines)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1189 (when line-err-info
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1190 (setq real-file-name (funcall get-real-file-name-f source-buffer (flymake-ler-get-file line-err-info)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1191 (setq line-err-info (flymake-ler-set-full-file line-err-info real-file-name))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1192
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1193 (if (flymake-same-files real-file-name source-file-name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1194 (setq line-err-info (flymake-ler-set-file line-err-info nil))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1195 ;else
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1196 (setq line-err-info (flymake-ler-set-file line-err-info (file-name-nondirectory real-file-name)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1197 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1198
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1199 (setq err-info-list (flymake-add-err-info err-info-list line-err-info))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1200 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1201 (flymake-log 3 "parsed '%s', %s line-err-info" (nth idx lines) (if line-err-info "got" "no"))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1202 (setq idx (1+ idx))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1203 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1204 err-info-list
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1205 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1206 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1207
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1208 (defun flymake-split-output(output)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1209 "split output into lines, return last one as residual if it does not end with newline char. Returns ((lines) residual)"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1210 (when (and output (> (length output) 0))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1211 (let* ((lines (flymake-split-string output "[\n\r]+"))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1212 (complete (equal "\n" (char-to-string (aref output (1- (length output))))))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1213 (residual nil))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1214 (when (not complete)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1215 (setq residual (car (last lines)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1216 (setq lines (butlast lines))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1217 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1218 (list lines residual)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1219 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1220 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1221 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1222
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1223 (eval-when-compile (require 'compile))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1224 (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
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1225 (append
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1226 '(
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1227 ; MS Visual C++ 6.0
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1228 ("\\(\\([a-zA-Z]:\\)?[^:(\t\n]+\\)(\\([0-9]+\\)) \: \\(\\(error\\|warning\\|fatal error\\) \\(C[0-9]+\\):[ \t\n]*\\(.+\\)\\)"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1229 1 3 nil 4)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1230 ; jikes
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1231 ("\\(\\([a-zA-Z]:\\)?[^:(\t\n]+\\)\:\\([0-9]+\\)\:[0-9]+\:[0-9]+\:[0-9]+\: \\(\\(Error\\|Warning\\|Caution\\|Semantic Error\\):[ \t\n]*\\(.+\\)\\)"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1232 1 3 nil 4)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1233 ; MS midl
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1234 ("midl[ ]*:[ ]*\\(command line error .*\\)"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1235 nil nil nil 1)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1236 ; MS C#
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1237 ("\\(\\([a-zA-Z]:\\)?[^:(\t\n]+\\)(\\([0-9]+\\),[0-9]+)\: \\(\\(error\\|warning\\|fatal error\\) \\(CS[0-9]+\\):[ \t\n]*\\(.+\\)\\)"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1238 1 3 nil 4)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1239 ; perl
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1240 ("\\(.*\\) at \\([^ \n]+\\) line \\([0-9]+\\)[,.\n]" 2 3 nil 1)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1241 ; LaTeX warnings (fileless) ("\\(LaTeX \\(Warning\\|Error\\): .*\\) on input line \\([0-9]+\\)" 20 3 nil 1)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1242 ; ant/javac
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1243 (" *\\(\\[javac\\]\\)? *\\(\\([a-zA-Z]:\\)?[^:(\t\n]+\\)\:\\([0-9]+\\)\:[ \t\n]*\\(.+\\)"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1244 2 4 nil 5)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1245 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1246 compilation-error-regexp-alist)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1247 "patterns for matching error/warning lines, (regexp file-idx line-idx err-text-idx)"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1248 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1249 ;(defcustom flymake-err-line-patterns
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1250 ; '(
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1251 ; ; MS Visual C++ 6.0
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1252 ; ("\\(\\([a-zA-Z]:\\)?[^:(\t\n]+\\)(\\([0-9]+\\)) \: \\(\\(error\\|warning\\|fatal error\\) \\(C[0-9]+\\):[ \t\n]*\\(.+\\)\\)"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1253 ; 1 3 4)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1254 ; ; jikes
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1255 ; ("\\(\\([a-zA-Z]:\\)?[^:(\t\n]+\\)\:\\([0-9]+\\)\:[0-9]+\:[0-9]+\:[0-9]+\: \\(\\(Error\\|Warning\\|Caution\\):[ \t\n]*\\(.+\\)\\)"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1256 ; 1 3 4))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1257 ; "patterns for matching error/warning lines, (regexp file-idx line-idx err-text-idx)"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1258 ; :group 'flymake
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1259 ; :type '(repeat (string number number number))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1260 ;)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1261
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1262 (defun flymake-parse-line(line)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1263 "parse line to see whether it's an error of warning, return it's components or nil for no match"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1264 (let ((raw-file-name nil)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1265 (line-no 0)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1266 (err-type "e")
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1267 (err-text nil)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1268 (count (length flymake-err-line-patterns))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1269 (idx 0)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1270 (matched nil))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1271 (while (and (< idx count) (not matched))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1272 (when (string-match (car (nth idx flymake-err-line-patterns)) line)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1273 (let* ((file-idx (nth 1 (nth idx flymake-err-line-patterns)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1274 (line-idx (nth 2 (nth idx flymake-err-line-patterns))))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1275
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1276 (setq raw-file-name (if file-idx (match-string file-idx line) nil))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1277 (setq line-no (if line-idx (string-to-int (match-string line-idx line)) 0))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1278 (setq err-text (if (> (length (nth idx flymake-err-line-patterns)) 4)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1279 (match-string (nth 4 (nth idx flymake-err-line-patterns)) line)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1280 (flymake-patch-err-text (substring line (match-end 0)))))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1281 (or err-text (setq err-text "<no error text>"))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1282 (if (and err-text (string-match "^[wW]arning" err-text))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1283 (setq err-type "w")
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1284 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1285 (flymake-log 3 "parse line: file-idx=%s line-idx=%s file=%s line=%s text=%s" file-idx line-idx
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1286 raw-file-name line-no err-text)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1287 (setq matched t)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1288 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1289 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1290 (setq idx (1+ idx))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1291 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1292 (if matched
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1293 (flymake-ler-make-ler raw-file-name line-no err-type err-text)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1294 ; else
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1295 ()
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1296 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1297 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1298 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1299
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1300 (defun flymake-find-err-info(err-info-list line-no)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1301 "find (line-err-info-list pos) for specified line-no"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1302 (if err-info-list
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1303 (let* ((line-err-info-list nil)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1304 (pos 0)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1305 (count (length err-info-list)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1306
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1307 (while (and (< pos count) (< (car (nth pos err-info-list)) line-no))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1308 (setq pos (1+ pos))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1309 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1310 (when (and (< pos count) (equal (car (nth pos err-info-list)) line-no))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1311 (setq line-err-info-list (flymake-er-get-line-err-info-list (nth pos err-info-list)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1312 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1313 (list line-err-info-list pos)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1314 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1315 ;else
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1316 '(nil 0)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1317 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1318 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1319
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1320 (defun flymake-line-err-info-is-less-or-equal(line-one line-two)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1321 (or (string< (flymake-ler-get-type line-one) (flymake-ler-get-type line-two))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1322 (and (string= (flymake-ler-get-type line-one) (flymake-ler-get-type line-two))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1323 (not (flymake-ler-get-file line-one)) (flymake-ler-get-file line-two)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1324 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1325 (and (string= (flymake-ler-get-type line-one) (flymake-ler-get-type line-two))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1326 (or (and (flymake-ler-get-file line-one) (flymake-ler-get-file line-two))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1327 (and (not (flymake-ler-get-file line-one)) (not (flymake-ler-get-file line-two)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1328 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1329 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1330 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1331 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1332
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1333 (defun flymake-add-line-err-info(line-err-info-list line-err-info)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1334 "insert new err info favoring sorting: err-type e/w, filename nil/non-nill"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1335 (if (not line-err-info-list)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1336 (list line-err-info)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1337 ;else
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1338 (let* ((count (length line-err-info-list))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1339 (idx 0))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1340 (while (and (< idx count) (flymake-line-err-info-is-less-or-equal (nth idx line-err-info-list) line-err-info))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1341 (setq idx (1+ idx))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1342 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1343 (cond ((equal 0 idx) (setq line-err-info-list (cons line-err-info line-err-info-list)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1344 (t (setq line-err-info-list (flymake-ins-after line-err-info-list (1- idx) line-err-info)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1345 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1346 line-err-info-list
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1347 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1348 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1349 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1350
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1351 (defun flymake-add-err-info(err-info-list line-err-info)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1352 "add error info (file line type text) to err info list preserving sort order"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1353 (let* ((count (length err-info-list))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1354 (line-no (if (flymake-ler-get-file line-err-info) 1 (flymake-ler-get-line line-err-info)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1355 (info-and-pos (flymake-find-err-info err-info-list line-no))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1356 (exists (car info-and-pos))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1357 (pos (nth 1 info-and-pos))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1358 (line-err-info-list nil)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1359 (err-info nil))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1360
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1361 (if exists
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1362 (setq line-err-info-list (flymake-er-get-line-err-info-list (car (nthcdr pos err-info-list))))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1363 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1364 (setq line-err-info-list (flymake-add-line-err-info line-err-info-list line-err-info))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1365
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1366 (setq err-info (flymake-er-make-er line-no line-err-info-list))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1367 (cond (exists (setq err-info-list (flymake-set-at err-info-list pos err-info)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1368 ((equal 0 pos) (setq err-info-list (cons err-info err-info-list)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1369 (t (setq err-info-list (flymake-ins-after err-info-list (1- pos) err-info)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1370 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1371 err-info-list
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1372 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1373 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1374
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1375 (defun flymake-get-project-include-dirs-imp(basedir)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1376 "include dirs for the project current file belongs to"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1377 (if (flymake-get-project-include-dirs-from-cache basedir)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1378 (progn
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1379 (flymake-get-project-include-dirs-from-cache basedir)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1380 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1381 ;else
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1382 (let* ((command-line (concat "make -C\"" basedir "\" DUMPVARS=INCLUDE_DIRS dumpvars"))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1383 (output (shell-command-to-string command-line))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1384 (lines (flymake-split-string output "\n"))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1385 (count (length lines))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1386 (idx 0)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1387 (inc-dirs nil))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1388 (while (and (< idx count) (not (string-match "^INCLUDE_DIRS=.*" (nth idx lines))))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1389 (setq idx (1+ idx))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1390 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1391 (when (< idx count)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1392 (let* ((inc-lines (flymake-split-string (nth idx lines) " *-I"))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1393 (inc-count (length inc-lines)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1394 (while (> inc-count 0)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1395 (when (not (string-match "^INCLUDE_DIRS=.*" (nth (1- inc-count) inc-lines)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1396 (setq inc-dirs (cons (flymake-replace-regexp-in-string "\"" "" (nth (1- inc-count) inc-lines)) inc-dirs))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1397 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1398 (setq inc-count (1- inc-count))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1399 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1400 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1401 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1402 (flymake-add-project-include-dirs-to-cache basedir inc-dirs)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1403 inc-dirs
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1404 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1405 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1406 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1407
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1408 (defcustom flymake-get-project-include-dirs-function 'flymake-get-project-include-dirs-imp
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1409 "function used to get project inc dirs, one paramater: basedir name"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1410 :group 'flymake
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1411 :type 'function
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1412 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1413
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1414 (defun flymake-get-project-include-dirs(basedir)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1415 (funcall flymake-get-project-include-dirs-function basedir)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1416 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1417
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1418 (defun flymake-get-system-include-dirs()
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1419 "system include dirs - from the 'INCLUDE' env setting"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1420 (let* ((includes (getenv "INCLUDE")))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1421 (if includes (flymake-split-string includes path-separator) nil)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1422 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1423 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1424
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1425 (defvar flymake-project-include-dirs-cache (flymake-makehash 'equal))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1426 (defun flymake-get-project-include-dirs-from-cache(base-dir)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1427 (gethash base-dir flymake-project-include-dirs-cache)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1428 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1429 (defun flymake-add-project-include-dirs-to-cache(base-dir include-dirs)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1430 (puthash base-dir include-dirs flymake-project-include-dirs-cache)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1431 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1432 (defun flymake-clear-project-include-dirs-cache()
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1433 (clrhash flymake-project-include-dirs-cache)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1434 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1435
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1436 (defun flymake-get-include-dirs(base-dir)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1437 "dirs to use when resolving local filenames"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1438 (let* ((include-dirs (append '(".") (flymake-get-project-include-dirs base-dir) (flymake-get-system-include-dirs))))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1439 include-dirs
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1440 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1441 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1442
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1443 (defun flymake-find-file(rel-file-name include-dirs)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1444 "iterate through include-dirs, return first 'include-dir/rel-file-name' that exists, or just rel-file-name if not"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1445 (let* ((count (length include-dirs))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1446 (idx 0)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1447 (found nil)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1448 (full-file-name rel-file-name))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1449
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1450 (while (and (not found) (< idx count))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1451 (let* ((dir (nth idx include-dirs)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1452 (setq full-file-name (concat dir "/" rel-file-name))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1453 (when (file-exists-p full-file-name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1454 (setq done t)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1455 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1456 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1457 (setq idx (1+ idx))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1458 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1459 (if found
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1460 full-file-name
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1461 ;else
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1462 rel-file-name
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1463 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1464 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1465 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1466
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1467 (defun flymake-restore-formatting(source-buffer)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1468 "Remove any formatting made by flymake"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1469 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1470
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1471 (defun flymake-get-program-dir(buffer)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1472 "dir to start profram in"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1473 (unless (bufferp buffer)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1474 (error "invlid buffer")
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1475 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1476 (save-excursion
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1477 (set-buffer buffer)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1478 default-directory
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1479 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1480 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1481
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1482 (defun flymake-safe-delete-file(file-name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1483 (when (and file-name (file-exists-p file-name))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1484 (delete-file file-name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1485 (flymake-log 1 "deleted file %s" file-name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1486 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1487 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1488
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1489 (defun flymake-safe-delete-directory(dir-name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1490 (condition-case err
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1491 (progn
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1492 (delete-directory dir-name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1493 (flymake-log 1 "deleted dir %s" dir-name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1494 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1495 (error
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1496 (flymake-log 1 "failed to delete dir %s, error ignored" dir-name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1497 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1498 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1499 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1500
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1501 (defcustom flymake-compilation-prevents-syntax-check t
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1502 "if non-nil, syntax check won't be started in case compilation is running"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1503 :group 'flymake
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1504 :type 'boolean
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1505 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1506
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1507 (defun flymake-start-syntax-check(buffer)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1508 "start syntax checking for buffer"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1509 (unless (bufferp buffer)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1510 (error "expected a buffer")
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1511 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1512 (save-excursion
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1513 (set-buffer buffer)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1514 (flymake-log 3 "flymake is running: %s" (flymake-get-buffer-is-running buffer))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1515 (when (and (not (flymake-get-buffer-is-running buffer))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1516 (flymake-can-syntax-check-file (buffer-file-name buffer)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1517 (when (or (not flymake-compilation-prevents-syntax-check)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1518 (not (flymake-compilation-is-running))) ;+ (flymake-rep-ort-status buffer "COMP")
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1519 (flymake-clear-buildfile-cache)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1520 (flymake-clear-project-include-dirs-cache)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1521
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1522 (flymake-set-buffer-check-was-interrupted buffer nil)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1523 (flymake-set-buffer-data buffer (flymake-makehash 'equal))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1524
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1525 (let* ((source-file-name (buffer-file-name buffer))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1526 (init-f (flymake-get-init-function source-file-name))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1527 (cleanup-f (flymake-get-cleanup-function source-file-name))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1528 (cmd-and-args (funcall init-f buffer))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1529 (cmd (nth 0 cmd-and-args))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1530 (args (nth 1 cmd-and-args))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1531 (dir (nth 2 cmd-and-args)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1532 (if (not cmd-and-args)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1533 (progn
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1534 (flymake-log 0 "init function %s for %s failed, cleaning up" init-f source-file-name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1535 (funcall cleanup-f buffer)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1536 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1537 ;else
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1538 (progn
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1539 (flymake-set-buffer-last-change-time buffer nil)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1540 (flymake-start-syntax-check-process buffer cmd args dir)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1541 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1542 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1543 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1544 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1545 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1546 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1547 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1548
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1549 (defun flymake-start-syntax-check-process(buffer cmd args dir)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1550 "start syntax check-process"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1551
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1552 (let* ((process nil))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1553 (condition-case err
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1554 (progn
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1555 (when dir
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1556 (let ((default-directory dir))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1557 (flymake-log 3 "starting process on dir %s" default-directory)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1558 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1559 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1560 (setq process (get-process (apply 'start-process "flymake-proc" nil cmd args)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1561 (set-process-sentinel process 'flymake-process-sentinel)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1562 (set-process-filter process 'flymake-process-filter)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1563
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1564 (flymake-reg-names (process-id process) (buffer-name buffer))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1565
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1566 (flymake-set-buffer-is-running buffer t)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1567 (flymake-set-buffer-last-change-time buffer nil)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1568 (flymake-set-buffer-check-start-time buffer (flymake-float-time))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1569
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1570 (flymake-report-status buffer nil "*")
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1571 (flymake-log 2 "started process %d, command=%s, dir=%s"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1572 (process-id process) (process-command process) default-directory)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1573 process
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1574 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1575 (error
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1576 (let ((err-str (format "Failed to launch syntax check process '%s' with args %s: %s"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1577 cmd args (error-message-string err)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1578 (source-file-name (buffer-file-name buffer))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1579 (cleanup-f (flymake-get-cleanup-function source-file-name)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1580 (flymake-log 0 err-str)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1581 (funcall cleanup-f buffer)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1582 (flymake-report-fatal-status buffer "PROCERR" err-str)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1583 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1584 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1585 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1586 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1587 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1588
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1589 (defun flymake-kill-process(pid &optional rest)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1590 "kill process pid"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1591 (signal-process pid 9)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1592 (let* ((buffer-name (flymake-get-source-buffer-name pid)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1593 (when (and buffer-name (get-buffer buffer-name))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1594 (flymake-set-buffer-check-was-interrupted (get-buffer buffer-name) t)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1595 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1596 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1597 (flymake-log 1 "killed process %d" pid)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1598 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1599
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1600 (defun flymake-stop-all-syntax-checks()
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1601 "kill all syntax check processes"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1602 (interactive)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1603 (let ((pids (copy-hash-table flymake-pid-to-names)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1604 (maphash 'flymake-kill-process pids)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1605 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1606 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1607
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1608 (defun flymake-compilation-is-running()
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1609 (and (boundp 'compilation-in-progress)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1610 compilation-in-progress)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1611 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1612
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1613 (defun flymake-compile()
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1614 "kill all flymake syntax checks, start compilation"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1615 (interactive)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1616 (flymake-stop-all-syntax-checks)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1617 (call-interactively 'compile)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1618 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1619
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1620 (defvar flymake-is-running nil
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1621 "t if flymake syntax check process is running for the current buffer"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1622 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1623 (make-variable-buffer-local 'flymake-is-running)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1624 (defun flymake-get-buffer-is-running(buffer)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1625 (flymake-get-buffer-var buffer 'flymake-is-running)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1626 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1627 (defun flymake-set-buffer-is-running(buffer is-running)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1628 (flymake-set-buffer-var buffer 'flymake-is-running is-running)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1629 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1630
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1631 (defvar flymake-timer nil
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1632 "timer for starting syntax checks"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1633 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1634 (make-variable-buffer-local 'flymake-timer)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1635 (defun flymake-get-buffer-timer(buffer)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1636 (flymake-get-buffer-var buffer 'flymake-timer)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1637 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1638 (defun flymake-set-buffer-timer(buffer timer)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1639 (flymake-set-buffer-var buffer 'flymake-timer timer)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1640 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1641
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1642 (defvar flymake-last-change-time nil
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1643 "time of last buffer change"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1644 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1645 (make-variable-buffer-local 'flymake-last-change-time)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1646 (defun flymake-get-buffer-last-change-time(buffer)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1647 (flymake-get-buffer-var buffer 'flymake-last-change-time)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1648 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1649 (defun flymake-set-buffer-last-change-time(buffer change-time)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1650 (flymake-set-buffer-var buffer 'flymake-last-change-time change-time)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1651 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1652
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1653 (defvar flymake-check-start-time nil
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1654 "time at which syntax check was started")
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1655 (make-variable-buffer-local 'flymake-check-start-time)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1656 (defun flymake-get-buffer-check-start-time(buffer)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1657 (flymake-get-buffer-var buffer 'flymake-check-start-time)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1658 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1659 (defun flymake-set-buffer-check-start-time(buffer check-start-time)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1660 (flymake-set-buffer-var buffer 'flymake-check-start-time check-start-time)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1661 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1662
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1663 (defvar flymake-check-was-interrupted nil
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1664 "t if syntax check was killed by flymake-compile"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1665 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1666 (make-variable-buffer-local 'flymake-check-was-interrupted)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1667 (defun flymake-get-buffer-check-was-interrupted(buffer)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1668 (flymake-get-buffer-var buffer 'flymake-check-was-interrupted)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1669 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1670 (defun flymake-set-buffer-check-was-interrupted(buffer interrupted)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1671 (flymake-set-buffer-var buffer 'flymake-check-was-interrupted interrupted)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1672 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1673
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1674 (defcustom flymake-no-changes-timeout 0.5
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1675 "time to wait after last change before starting compilation"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1676 :group 'flymake
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1677 :type 'number
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1678 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1679
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1680 (defun flymake-on-timer-event(buffer)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1681 "start a syntax check for buffer if necessary"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1682 ;+(flymake-log 3 "timer: running=%s, time=%s, cur-time=%s" (flymake-get-buffer-is-running buffer) (flymake-get-buffer-last-change-time buffer) (flymake-float-time))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1683
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1684 (when (and (bufferp buffer) (not (flymake-get-buffer-is-running buffer)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1685 (save-excursion
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1686 (set-buffer buffer)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1687 (when (and (flymake-get-buffer-last-change-time buffer)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1688 (> (flymake-float-time) (+ flymake-no-changes-timeout (flymake-get-buffer-last-change-time buffer))))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1689 (flymake-set-buffer-last-change-time buffer nil)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1690 (flymake-log 3 "starting syntax check as more than 1 second passed since last change")
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1691 (flymake-start-syntax-check buffer)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1692 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1693 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1694 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1695 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1696
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1697 (defun flymake-start-syntax-check-for-current-buffer()
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1698 "run flymake-start-syntax-check for current buffer if it isn't already running"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1699 (interactive)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1700 (flymake-start-syntax-check (current-buffer))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1701 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1702
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1703 (defun flymake-current-line-no()
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1704 "return number of current line in current buffer"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1705 (interactive)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1706 (let ((beg (point-min))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1707 (end (if (= (point) (point-max)) (point) (1+ (point)))))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1708 (count-lines beg end)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1709 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1710 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1711
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1712 (defun flymake-get-line-count(buffer)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1713 "return number of lines in buffer"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1714 (unless (bufferp buffer)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1715 (error "invalid buffer")
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1716 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1717 (save-excursion
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1718 (set-buffer buffer)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1719 (count-lines (point-min) (point-max))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1720 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1721 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1722
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1723 (defun flymake-count-lines(buffer)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1724 "return number of lines in buffer"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1725 (save-excursion
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1726 (set-buffer buffer)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1727 (count-lines (point-min) (point-max))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1728 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1729 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1730
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1731 (defun flymake-get-point-pixel-pos()
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1732 "return point position in pixels: (x, y)"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1733 (let ((mouse-pos (mouse-position))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1734 (pixel-pos nil)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1735 (ret nil))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1736 (if (car (cdr mouse-pos))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1737 (progn
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1738 (set-mouse-position (flymake-selected-frame) (current-column) (flymake-current-row))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1739 (setq pixel-pos (mouse-pixel-position))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1740 (set-mouse-position (car mouse-pos) (car (cdr mouse-pos)) (cdr (cdr mouse-pos)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1741 (setq ret (list (car (cdr pixel-pos)) (cdr (cdr pixel-pos))))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1742 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1743 ;else
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1744 (progn
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1745 (setq ret '(0 0))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1746 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1747 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1748 (flymake-log 3 "mouse pos is %s" ret)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1749 ret
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1750 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1751 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1752
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1753 (defun flymake-display-err-menu-for-current-line()
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1754 "Display a menu with errors/warnings for current line if it has errors and/or warnings"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1755 (interactive)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1756 (let* ((line-no (flymake-current-line-no))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1757 (line-err-info-list (nth 0 (flymake-find-err-info (flymake-get-buffer-err-info (current-buffer)) line-no)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1758 (menu-data (flymake-make-err-menu-data line-no line-err-info-list))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1759 (choice nil)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1760 (mouse-pos (flymake-get-point-pixel-pos))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1761 (moved-mouse-pos (list (car mouse-pos) (+ 10 (car (cdr mouse-pos)))))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1762 (menu-pos (list (flymake-get-point-pixel-pos) (selected-window))))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1763 (if menu-data
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1764 (progn
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1765 (setq choice (flymake-popup-menu menu-pos menu-data))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1766 (flymake-log 3 "choice=%s" choice)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1767 (when choice
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1768 (eval choice)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1769 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1770 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1771 ;else
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1772 (flymake-log 1 "no errors for line %d" line-no)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1773 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1774 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1775 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1776
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1777 (defun flymake-make-err-menu-data(line-no line-err-info-list)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1778 "Make a (menu-title (item-title item-action)*) list with errors/warnings from line-err-info"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1779 (let* ((menu-items nil))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1780 (when line-err-info-list
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1781 (let* ((count (length line-err-info-list))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1782 (menu-item-text nil))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1783 (while (> count 0)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1784 (setq menu-item-text (flymake-ler-get-text (nth (1- count) line-err-info-list)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1785 (let* ((file (flymake-ler-get-file (nth (1- count) line-err-info-list)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1786 (full-file (flymake-ler-get-full-file (nth (1- count) line-err-info-list)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1787 (line (flymake-ler-get-line (nth (1- count) line-err-info-list))))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1788 (if file
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1789 (setq menu-item-text (concat menu-item-text " - " file "(" (format "%d" line) ")"))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1790 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1791 (setq menu-items (cons (list menu-item-text
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1792 (if file (list 'flymake-goto-file-and-line full-file line) nil))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1793 menu-items))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1794 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1795 (setq count (1- count))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1796 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1797 (flymake-log 3 "created menu-items with %d item(s)" (length menu-items))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1798 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1799 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1800 (if menu-items
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1801 (let* ((menu-title (format "Line %d: %d error(s), %d warning(s)" line-no
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1802 (flymake-get-line-err-count line-err-info-list "e")
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1803 (flymake-get-line-err-count line-err-info-list "w"))))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1804 (list menu-title menu-items)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1805 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1806 ;else
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1807 nil
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1808 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1809 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1810 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1811
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1812 (defun flymake-goto-file-and-line(file line)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1813 "try to get buffer for file and goto line line in it"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1814 (if (not (file-exists-p file))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1815 (flymake-log 1 "file %s does not exists" file)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1816 ;else
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1817 (progn
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1818 (find-file file)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1819 (goto-line line)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1820 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1821 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1822 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1823 ;; flymake minor mode declarations
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1824
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1825 (defvar flymake-mode nil)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1826 (make-variable-buffer-local 'flymake-mode)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1827
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1828 (defvar flymake-mode-line nil
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1829 ""
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1830 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1831 (make-variable-buffer-local 'flymake-mode-line)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1832 (defun flymake-get-buffer-mode-line(buffer)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1833 (flymake-get-buffer-var buffer 'flymake-mode-line)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1834 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1835 (defun flymake-set-buffer-mode-line(buffer mode-line-string)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1836 (flymake-set-buffer-var buffer 'flymake-mode-line mode-line-string)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1837 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1838
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1839 (defvar flymake-mode-line-e-w nil)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1840 (make-variable-buffer-local 'flymake-mode-line-e-w)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1841 (defun flymake-get-buffer-mode-line-e-w(buffer)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1842 (flymake-get-buffer-var buffer 'flymake-mode-line-e-w)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1843 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1844 (defun flymake-set-buffer-mode-line-e-w(buffer e-w)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1845 (flymake-set-buffer-var buffer 'flymake-mode-line-e-w e-w)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1846 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1847
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1848 (defvar flymake-mode-line-status nil)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1849 (make-variable-buffer-local 'flymake-mode-line-status)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1850 (defun flymake-get-buffer-mode-line-status(buffer)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1851 (flymake-get-buffer-var buffer 'flymake-mode-line-status)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1852 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1853 (defun flymake-set-buffer-mode-line-status(buffer status)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1854 (flymake-set-buffer-var buffer 'flymake-mode-line-status status)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1855 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1856
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1857 (defun flymake-report-status(buffer e-w &optional status)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1858 "show status in the mode line"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1859 (when (bufferp buffer)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1860 (save-excursion
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1861 (set-buffer buffer)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1862 (when e-w
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1863 (flymake-set-buffer-mode-line-e-w buffer e-w)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1864 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1865 (when status
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1866 (flymake-set-buffer-mode-line-status buffer status)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1867 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1868 (let* ((mode-line " Flymake"))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1869 (when (> (length (flymake-get-buffer-mode-line-e-w buffer)) 0)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1870 (setq mode-line (concat mode-line ":" (flymake-get-buffer-mode-line-e-w buffer)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1871 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1872 (setq mode-line (concat mode-line (flymake-get-buffer-mode-line-status buffer)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1873 (flymake-set-buffer-mode-line buffer mode-line)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1874 (force-mode-line-update)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1875 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1876 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1877 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1878 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1879
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1880 (defun flymake-display-warning(warning)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1881 "display a warning to the user"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1882 (message-box warning)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1883 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1884
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1885 (defcustom flymake-gui-warnings-enabled t
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1886 "enables/disables gui warnings"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1887 :group 'flymake
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1888 :type 'boolean
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1889 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1890
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1891 (defun flymake-report-fatal-status(buffer status warning)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1892 "display a warning and switch flymake mode OFF"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1893 (when flymake-gui-warnings-enabled
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1894 (flymake-display-warning (format "Flymake: %s. Flymake will be switched OFF" warning))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1895 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1896 (save-excursion
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1897 (set-buffer buffer)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1898 (flymake-mode 0)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1899 (flymake-log 0 "switched OFF Flymake mode for buffer %s due to fatal status %s, warning %s"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1900 (buffer-name buffer) status warning)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1901 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1902 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1903
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1904 (defun flymake-mode(&optional arg)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1905 "toggle flymake-mode"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1906 (interactive)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1907 (let ((old-flymake-mode flymake-mode))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1908
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1909 (setq turn-on
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1910 (if (null arg)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1911 (not flymake-mode)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1912 ;else
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1913 (> (prefix-numeric-value arg) 0))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1914 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1915
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1916 (if turn-on
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1917 (if (flymake-can-syntax-check-file (buffer-file-name))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1918 (flymake-mode-on)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1919 ;else
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1920 (flymake-log 2 "flymake cannot check syntax in buffer %s" (buffer-name))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1921 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1922 ;else
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1923 (flymake-mode-off)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1924 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1925 (force-mode-line-update)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1926 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1927 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1928
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1929 ;;;###autoload
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1930 (unless (assq 'flymake-mode minor-mode-alist)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1931 (setq minor-mode-alist (cons '(flymake-mode flymake-mode-line) minor-mode-alist))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1932 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1933
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1934 ;;;###autoload
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1935 (defun flymake-mode-on()
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1936 "turn flymake mode on"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1937 (when (not flymake-mode)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1938 (make-local-variable 'after-change-functions)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1939 (setq after-change-functions (cons 'flymake-after-change-function after-change-functions))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1940 (add-hook 'after-save-hook 'flymake-after-save-hook)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1941 (add-hook 'kill-buffer-hook 'flymake-kill-buffer-hook)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1942 ;+(add-hook 'find-file-hooks 'flymake-find-file-hook)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1943
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1944 (flymake-report-status (current-buffer) "" "")
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1945
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1946 (flymake-set-buffer-timer (current-buffer) (run-at-time nil 1 'flymake-on-timer-event (current-buffer)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1947
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1948 (setq flymake-mode t)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1949 (flymake-log 1 "flymake mode turned ON for buffer %s" (buffer-name (current-buffer)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1950 (when flymake-start-syntax-check-on-find-file
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1951 (flymake-start-syntax-check-for-current-buffer) ; will be started by on-load hook
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1952 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1953 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1954 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1955
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1956 ;;;###autoload
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1957 (defun flymake-mode-off()
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1958 "turn flymake mode off"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1959 (when flymake-mode
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1960 (setq after-change-functions (delq 'flymake-after-change-function after-change-functions))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1961 (remove-hook 'after-save-hook (function flymake-after-save-hook) t)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1962 (remove-hook 'kill-buffer-hook (function flymake-kill-buffer-hook) t)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1963 ;+(remove-hook 'find-file-hooks (function flymake-find-file-hook) t)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1964
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1965 (flymake-delete-own-overlays (current-buffer))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1966
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1967 (when (flymake-get-buffer-timer (current-buffer))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1968 (cancel-timer (flymake-get-buffer-timer (current-buffer)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1969 (flymake-set-buffer-timer (current-buffer) nil)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1970 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1971
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1972 (flymake-set-buffer-is-running (current-buffer) nil)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1973
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1974 (setq flymake-mode nil)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1975 (flymake-log 1 "flymake mode turned OFF for buffer %s" (buffer-name (current-buffer)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1976 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1977 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1978
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1979 (defcustom flymake-start-syntax-check-on-newline t
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1980 "start syntax check if newline char was added/removed from the buffer"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1981 :group 'flymake
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1982 :type 'boolean
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1983 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1984
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1985 (defun flymake-after-change-function(start stop len)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1986 "Start syntax check for current buffer if it isn't already running"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1987 ;+(flymake-log 0 "setting change time to %s" (flymake-float-time))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1988 (let((new-text (buffer-substring start stop)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1989 (when (and flymake-start-syntax-check-on-newline (equal new-text "\n"))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1990 (flymake-log 3 "starting syntax check as new-line has been seen")
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1991 (flymake-start-syntax-check-for-current-buffer)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1992 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1993 (flymake-set-buffer-last-change-time (current-buffer) (flymake-float-time))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1994 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1995 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1996
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1997 (defun flymake-after-save-hook()
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1998 (if (local-variable-p 'flymake-mode (current-buffer)) ; (???) other way to determine whether flymake is active in buffer being saved?
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1999 (progn
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2000 (flymake-log 3 "starting syntax check as buffer was saved")
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2001 (flymake-start-syntax-check-for-current-buffer) ; no more mode 3. cannot start check if mode 3 (to temp copies) is active - (???)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2002 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2003 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2004 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2005
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2006 (defun flymake-kill-buffer-hook()
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2007 (when (flymake-get-buffer-timer (current-buffer))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2008 (cancel-timer (flymake-get-buffer-timer (current-buffer)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2009 (flymake-set-buffer-timer (current-buffer) nil)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2010 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2011 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2012
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2013 (defcustom flymake-start-syntax-check-on-find-file t
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2014 "statr syntax check on find file"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2015 :group 'flymake
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2016 :type 'boolean
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2017 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2018
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2019 (defun flymake-find-file-hook()
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2020 ;+(when flymake-start-syntax-check-on-find-file
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2021 ;+ (flymake-log 3 "starting syntax check on file open")
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2022 ;+ (flymake-start-syntax-check-for-current-buffer)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2023 ;+)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2024 (when (and (not (local-variable-p 'flymake-mode (current-buffer)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2025 (flymake-can-syntax-check-file (buffer-file-name (current-buffer))))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2026 (flymake-mode)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2027 (flymake-log 3 "automatically turned ON flymake mode")
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2028 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2029 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2030
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2031 (defun flymake-get-first-err-line-no(err-info-list)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2032 "return first line-no with error"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2033 (when err-info-list
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2034 (flymake-er-get-line (car err-info-list))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2035 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2036 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2037
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2038 (defun flymake-get-last-err-line-no(err-info-list)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2039 "return last line-no with error"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2040 (when err-info-list
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2041 (flymake-er-get-line (nth (1- (length err-info-list)) err-info-list))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2042 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2043 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2044
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2045 (defun flymake-get-next-err-line-no(err-info-list line-no)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2046 "return next line with erroe"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2047 (when err-info-list
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2048 (let* ((count (length err-info-list))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2049 (idx 0))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2050 (while (and (< idx count) (>= line-no (flymake-er-get-line (nth idx err-info-list))))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2051 (setq idx (1+ idx))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2052 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2053 (if (< idx count)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2054 (flymake-er-get-line (nth idx err-info-list))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2055 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2056 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2057 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2058 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2059
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2060 (defun flymake-get-prev-err-line-no(err-info-list line-no)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2061 "return prev line with error"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2062 (when err-info-list
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2063 (let* ((count (length err-info-list)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2064 (while (and (> count 0) (<= line-no (flymake-er-get-line (nth (1- count) err-info-list))))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2065 (setq count (1- count))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2066 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2067 (if (> count 0)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2068 (flymake-er-get-line (nth (1- count) err-info-list))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2069 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2070 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2071 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2072 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2073
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2074 (defun flymake-skip-whitespace()
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2075 "move forward until nonwhitespace is reached"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2076 (while (looking-at "[ \t]")
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2077 (forward-char)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2078 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2079 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2080
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2081 (defun flymake-goto-line(line-no)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2082 "goto-line, then skip whitespace"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2083 (goto-line line-no)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2084 (flymake-skip-whitespace)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2085 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2086
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2087 (defun flymake-goto-next-error()
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2088 "go to next error in err ring"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2089 (interactive)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2090 (let ((line-no (flymake-get-next-err-line-no (flymake-get-buffer-err-info (current-buffer)) (flymake-current-line-no))))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2091 (when (not line-no)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2092 (setq line-no (flymake-get-first-err-line-no (flymake-get-buffer-err-info (current-buffer))))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2093 (flymake-log 1 "passed end of file")
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2094 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2095 (if line-no
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2096 (flymake-goto-line line-no)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2097 ;else
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2098 (flymake-log 1 "no errors in current buffer")
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2099 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2100 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2101 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2102
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2103 (defun flymake-goto-prev-error()
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2104 "go to prev error in err ring"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2105 (interactive)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2106 (let ((line-no (flymake-get-prev-err-line-no (flymake-get-buffer-err-info (current-buffer)) (flymake-current-line-no))))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2107 (when (not line-no)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2108 (setq line-no (flymake-get-last-err-line-no (flymake-get-buffer-err-info (current-buffer))))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2109 (flymake-log 1 "passed beginning of file")
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2110 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2111 (if line-no
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2112 (flymake-goto-line line-no)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2113 ;else
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2114 (flymake-log 1 "no errors in current buffer")
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2115 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2116 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2117 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2118
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2119 (defun flymake-patch-err-text(string)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2120 (if (string-match "^[\n\t :0-9]*\\(.*\\)$" string)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2121 (match-string 1 string)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2122 ;else
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2123 string
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2124 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2125 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2126
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2127 ;;;; general init-cleanup and helper routines
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2128
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2129 (defun flymake-create-temp-inplace(file-name prefix)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2130 (unless (stringp file-name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2131 (error "invalid file-name")
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2132 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2133 (or prefix
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2134 (setq prefix "flymake")
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2135 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2136 (let* ((temp-name (concat (file-name-sans-extension file-name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2137 "_" prefix
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2138 (and (file-name-extension file-name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2139 (concat "." (file-name-extension file-name))))))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2140 (flymake-log 3 "create-temp-inplace: file=%s temp=%s" file-name temp-name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2141 temp-name
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2142 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2143 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2144
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2145 (defun flymake-create-temp-with-folder-structure(file-name prefix)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2146 (unless (stringp file-name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2147 (error "invalid file-name")
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2148 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2149
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2150 (let* ((dir (file-name-directory file-name))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2151 (slash-pos (string-match "/" dir))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2152 (temp-dir (concat (flymake-ensure-ends-with-slash (flymake-get-temp-dir)) (substring dir (1+ slash-pos)))))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2153
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2154 (file-truename (concat (flymake-ensure-ends-with-slash temp-dir)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2155 (file-name-nondirectory file-name)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2156 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2157 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2158
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2159 (defun flymake-strrchr(str ch)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2160 (let* ((count (length str))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2161 (pos nil))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2162 (while (and (not pos) (> count 0))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2163 (if (= ch (elt str (1- count)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2164 (setq pos (1- count))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2165 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2166 (setq count (1- count))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2167 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2168 pos
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2169 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2170 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2171
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2172 (defun flymake-delete-temp-directory(dir-name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2173 "attempt to delete temp dir created by flymake-create-temp-with-folder-structure, do not fail on error"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2174 (let* ((temp-dir (flymake-get-temp-dir))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2175 (suffix (substring dir-name (1+ (length temp-dir))))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2176 (slash-pos nil))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2177
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2178 (while (> (length suffix) 0)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2179 ;+(flymake-log 0 "suffix=%s" suffix)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2180 (flymake-safe-delete-directory (file-truename (concat (flymake-ensure-ends-with-slash temp-dir) suffix)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2181 (setq slash-pos (flymake-strrchr suffix (string-to-char "/")))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2182 (if slash-pos
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2183 (setq suffix (substring suffix 0 slash-pos))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2184 ;else
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2185 (setq suffix "")
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2186 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2187 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2188 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2189 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2190
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2191 (defun flymake-init-create-temp-buffer-copy(buffer create-temp-f)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2192 "make a temporary copy of the current buffer, save its name in buffer data and return the name"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2193 (let* ((source-file-name (buffer-file-name buffer))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2194 (temp-source-file-name (funcall create-temp-f source-file-name "flymake")))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2195
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2196 (flymake-save-buffer-in-file buffer temp-source-file-name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2197 (flymake-set-buffer-value buffer "temp-source-file-name" temp-source-file-name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2198
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2199 temp-source-file-name
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2200 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2201 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2202
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2203 (defun flymake-simple-cleanup(buffer)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2204 "cleanup after flymake-init-create-temp-buffer-copy -- delete temp file"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2205 (let* ((temp-source-file-name (flymake-get-buffer-value buffer "temp-source-file-name")))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2206 (flymake-safe-delete-file temp-source-file-name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2207 (flymake-set-buffer-last-change-time buffer nil)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2208 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2209 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2210
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2211 (defun flymake-get-real-file-name(buffer file-name-from-err-msg)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2212 "Translate file name from error message to `real' file name. Return full-name. Names are real, not patched"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2213 (let* ((real-name nil)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2214 (source-file-name (buffer-file-name buffer))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2215 (master-file-name (flymake-get-buffer-value buffer "master-file-name"))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2216 (temp-source-file-name (flymake-get-buffer-value buffer "temp-source-file-name"))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2217 (temp-master-file-name (flymake-get-buffer-value buffer "temp-master-file-name"))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2218 (base-dirs (list (flymake-get-buffer-value buffer "base-dir")
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2219 (file-name-directory source-file-name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2220 (if master-file-name (file-name-directory master-file-name) nil)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2221 (files (list (list source-file-name source-file-name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2222 (list temp-source-file-name source-file-name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2223 (list master-file-name master-file-name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2224 (list temp-master-file-name master-file-name))))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2225
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2226 (when (equal 0 (length file-name-from-err-msg))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2227 (setq file-name-from-err-msg source-file-name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2228 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2229
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2230 (setq real-name (flymake-get-full-patched-file-name file-name-from-err-msg base-dirs files))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2231 ; if real-name is nil, than file name from err msg is none of the files we've patched
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2232 (if (not real-name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2233 (setq real-name (flymake-get-full-nonpatched-file-name file-name-from-err-msg base-dirs))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2234 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2235 (if (not real-name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2236 (setq real-name file-name-from-err-msg)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2237 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2238 (setq real-name (flymake-fix-path-name real-name))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2239 (flymake-log 3 "get-real-file-name: file-name=%s real-name=%s" file-name-from-err-msg real-name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2240 real-name
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2241 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2242 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2243
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2244 (defun flymake-get-full-patched-file-name(file-name-from-err-msg base-dirs files)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2245 (let* ((base-dirs-count (length base-dirs))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2246 (file-count (length files))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2247 (real-name nil))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2248
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2249 (while (and (not real-name) (> base-dirs-count 0))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2250 (setq file-count (length files))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2251 (while (and (not real-name) (> file-count 0))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2252 (let* ((this-dir (nth (1- base-dirs-count) base-dirs))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2253 (this-file (nth 0 (nth (1- file-count) files)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2254 (this-real-name (nth 1 (nth (1- file-count) files))))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2255 ;+(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)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2256 (when (and this-dir this-file (flymake-same-files
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2257 (flymake-get-absolute-file-name-basedir file-name-from-err-msg this-dir)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2258 this-file))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2259 (setq real-name this-real-name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2260 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2261 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2262 (setq file-count (1- file-count))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2263 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2264 (setq base-dirs-count (1- base-dirs-count))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2265 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2266 real-name
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2267 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2268 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2269
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2270 (defun flymake-get-full-nonpatched-file-name(file-name-from-err-msg base-dirs)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2271 (let* ((real-name nil))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2272 (if (file-name-absolute-p file-name-from-err-msg)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2273 (setq real-name file-name-from-err-msg)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2274 ;else
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2275 (let* ((base-dirs-count (length base-dirs)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2276 (while (and (not real-name) (> base-dirs-count 0))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2277 (let* ((full-name (flymake-get-absolute-file-name-basedir file-name-from-err-msg
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2278 (nth (1- base-dirs-count) base-dirs))))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2279 (if (file-exists-p full-name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2280 (setq real-name full-name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2281 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2282 (setq base-dirs-count (1- base-dirs-count))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2283 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2284 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2285 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2286 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2287 real-name
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2288 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2289 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2290
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2291 (defun flymake-get-absolute-file-name-basedir(file-name dir-name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2292 (if (file-name-absolute-p file-name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2293 file-name
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2294 ;else
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2295 (concat dir-name "/" file-name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2296 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2297 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2298
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2299 (defun flymake-init-find-buildfile-dir(buffer source-file-name buildfile-name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2300 "find buildfile, store its dir in buffer data and return its dir, if found"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2301 (let* ((buildfile-dir (flymake-find-buildfile buildfile-name
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2302 (file-name-directory source-file-name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2303 flymake-buildfile-dirs)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2304 (if (not buildfile-dir)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2305 (progn
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2306 (flymake-log 1 "no buildfile (%s) for %s" buildfile-name source-file-name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2307 (flymake-report-fatal-status buffer "NOMK" (format "No buildfile (%s) found for %s" buildfile-name source-file-name))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2308 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2309 ;else
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2310 (progn
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2311 (flymake-set-buffer-value buffer "base-dir" buildfile-dir)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2312 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2313 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2314 buildfile-dir
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2315 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2316 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2317
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2318 (defun flymake-init-create-temp-source-and-master-buffer-copy(buffer get-incl-dirs-f create-temp-f master-file-masks include-regexp-list)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2319 "find master file (or buffer), create it's copy along with a copy of the source file"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2320 (let* ((source-file-name (buffer-file-name buffer))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2321 (temp-source-file-name (flymake-init-create-temp-buffer-copy buffer create-temp-f))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2322 (master-file-name nil)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2323 (temp-master-file-name nil)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2324 (master-and-temp-master (flymake-create-master-file
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2325 source-file-name temp-source-file-name
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2326 get-incl-dirs-f create-temp-f
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2327 master-file-masks include-regexp-list)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2328
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2329 (if (not master-and-temp-master)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2330 (progn
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2331 (flymake-log 1 "cannot find master file for %s" source-file-name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2332 (flymake-report-status buffer "!" "") ; NOMASTER
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2333 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2334 ;else
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2335 (progn
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2336 (setq master-file-name (nth 0 master-and-temp-master))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2337 (setq temp-master-file-name (nth 1 master-and-temp-master))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2338 (flymake-set-buffer-value buffer "master-file-name" master-file-name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2339 (flymake-set-buffer-value buffer "temp-master-file-name" temp-master-file-name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2340 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2341 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2342 temp-master-file-name
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2343 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2344 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2345
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2346 (defun flymake-master-cleanup(buffer)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2347 (flymake-simple-cleanup buffer)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2348 (flymake-safe-delete-file (flymake-get-buffer-value buffer "temp-master-file-name"))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2349 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2350
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2351 ;;;; make-specific init-cleanup routines
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2352
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2353 (defun flymake-get-syntax-check-program-args(source-file-name base-dir use-relative-base-dir use-relative-source get-cmd-line-f)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2354 "create a command line for the syntax check command, using get-cmd-line-f"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2355 (let* ((my-base-dir base-dir)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2356 (my-source source-file-name))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2357
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2358 (when use-relative-base-dir
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2359 (setq my-base-dir (flymake-build-relative-path (file-name-directory source-file-name) base-dir))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2360 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2361
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2362 (when use-relative-source
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2363 (setq my-source (concat (flymake-build-relative-path base-dir (file-name-directory source-file-name))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2364 (file-name-nondirectory source-file-name)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2365 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2366
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2367 (funcall get-cmd-line-f my-source my-base-dir)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2368 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2369 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2370
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2371 (defun flymake-get-make-cmdline(source base-dir)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2372 (list "make"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2373 (list "-s"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2374 "-C"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2375 base-dir
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2376 (concat "CHK_SOURCES=" source)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2377 "SYNTAX_CHECK_MODE=1"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2378 "check-syntax"))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2379 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2380
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2381 (defun flymake-get-ant-cmdline(source base-dir)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2382 (list "ant"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2383 (list "-buildfile"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2384 (concat base-dir "/" "build.xml")
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2385 (concat "-DCHK_SOURCES=" source)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2386 "check-syntax"))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2387 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2388
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2389 (defun flymake-simple-make-init-impl(buffer create-temp-f use-relative-base-dir use-relative-source build-file-name get-cmdline-f)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2390 "create syntax check command line for a directly checked source file, use create-temp-f for creating temp copy"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2391 (let* ((args nil)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2392 (source-file-name (buffer-file-name buffer))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2393 (buildfile-dir (flymake-init-find-buildfile-dir buffer source-file-name build-file-name)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2394 (if buildfile-dir
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2395 (let* ((temp-source-file-name (flymake-init-create-temp-buffer-copy buffer create-temp-f)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2396 (setq args (flymake-get-syntax-check-program-args temp-source-file-name buildfile-dir
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2397 use-relative-base-dir use-relative-source
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2398 get-cmdline-f))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2399 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2400 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2401
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2402 args
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2403 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2404 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2405
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2406 (defun flymake-simple-make-init(buffer)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2407 (flymake-simple-make-init-impl buffer 'flymake-create-temp-inplace t t "Makefile" 'flymake-get-make-cmdline)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2408 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2409
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2410 (defun flymake-master-make-init(buffer get-incl-dirs-f master-file-masks include-regexp-list)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2411 "create make command line for a source file checked via master file compilation"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2412 (let* ((make-args nil)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2413 (temp-master-file-name (flymake-init-create-temp-source-and-master-buffer-copy
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2414 buffer get-incl-dirs-f 'flymake-create-temp-inplace
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2415 master-file-masks include-regexp-list)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2416 (when temp-master-file-name
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2417 (let* ((buildfile-dir (flymake-init-find-buildfile-dir buffer temp-master-file-name "Makefile")))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2418 (if buildfile-dir
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2419 (setq make-args (flymake-get-syntax-check-program-args
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2420 temp-master-file-name buildfile-dir nil nil 'flymake-get-make-cmdline))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2421 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2422 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2423 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2424
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2425 make-args
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2426 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2427 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2428
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2429 (defun flymake-find-make-buildfile(source-dir)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2430 (flymake-find-buildfile "Makefile" source-dir flymake-buildfile-dirs)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2431 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2432
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2433 ;;;; .h/make specific
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2434 (defun flymake-master-make-header-init(buffer)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2435 (flymake-master-make-init buffer
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2436 'flymake-get-include-dirs
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2437 '(".+\\.cpp$" ".+\\.c$")
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2438 '("[ \t]*#[ \t]*include[ \t]*\"\\([\w0-9/\\_\.]*[/\\]*\\)\\(%s\\)\"" 1 2))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2439 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2440
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2441 ;;;; .java/make specific
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2442 (defun flymake-simple-make-java-init(buffer)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2443 (flymake-simple-make-init-impl buffer 'flymake-create-temp-with-folder-structure nil nil "Makefile" 'flymake-get-make-cmdline)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2444 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2445
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2446 (defun flymake-simple-ant-java-init(buffer)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2447 (flymake-simple-make-init-impl buffer 'flymake-create-temp-with-folder-structure nil nil "build.xml" 'flymake-get-ant-cmdline)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2448 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2449
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2450 (defun flymake-simple-java-cleanup(buffer)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2451 "cleanup after flymake-simple-make-java-init -- delete temp file and dirs"
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2452 (let* ((temp-source-file-name (flymake-get-buffer-value buffer "temp-source-file-name")))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2453 (flymake-safe-delete-file temp-source-file-name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2454 (when temp-source-file-name
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2455 (flymake-delete-temp-directory (file-name-directory temp-source-file-name))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2456 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2457 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2458 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2459
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2460 ;;;; perl-specific init-cleanup routines
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2461
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2462 (defun flymake-perl-init(buffer)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2463 (let* ((temp-file (flymake-init-create-temp-buffer-copy buffer 'flymake-create-temp-inplace))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2464 (local-file (concat (flymake-build-relative-path (file-name-directory (buffer-file-name (current-buffer)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2465 (file-name-directory temp-file))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2466 (file-name-nondirectory temp-file))))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2467 (list "perl" (list "-wc " local-file))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2468 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2469 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2470
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2471 ;;;; tex-specific init-cleanup routines
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2472
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2473 (defun flymake-get-tex-args(file-name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2474 ;(list "latex" (list "-c-style-errors" file-name))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2475 (list "texify" (list "--pdf" "--tex-option=-c-style-errors" file-name))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2476 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2477
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2478 (defun flymake-simple-tex-init(buffer)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2479 (flymake-get-tex-args (flymake-init-create-temp-buffer-copy buffer 'flymake-create-temp-inplace))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2480 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2481
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2482 (defun flymake-master-tex-init(buffer)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2483 (let* ((temp-master-file-name (flymake-init-create-temp-source-and-master-buffer-copy
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2484 buffer 'flymake-get-include-dirs-dot 'flymake-create-temp-inplace
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2485 '(".+\\.tex$")
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2486 '("[ \t]*\\input[ \t]*{\\(.*\\)\\(%s\\)}" 1 2))))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2487 (when temp-master-file-name
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2488 (flymake-get-tex-args temp-master-file-name)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2489 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2490 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2491 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2492
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2493 (defun flymake-get-include-dirs-dot(base-dir)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2494 '(".")
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2495 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2496
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2497 ;;;; xml-specific init-cleanup routines
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2498
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2499 (defun flymake-xml-init(buffer)
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2500 (list "xml" (list "val" (flymake-init-create-temp-buffer-copy buffer 'flymake-create-temp-inplace)))
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2501 )
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2502
55843
26e0724718e2 Changes from arch/CVS synchronization
Miles Bader <miles@gnu.org>
parents: 55822
diff changeset
2503 ;;; arch-tag: 8f0d6090-061d-4cac-8862-7c151c4a02dd
55822
ffbaa3e438cd New file.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2504 ;;; flymake.el ends here