annotate lisp/progmodes/flymake.el @ 65162:217750047c30

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