annotate lisp/progmodes/flymake.el @ 102408:2bb42d0dca71

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