2004-05-29 12:55:24 +00:00
|
|
|
;;; flymake.el -- a universal on-the-fly syntax checker
|
|
|
|
|
2012-02-08 02:12:24 +00:00
|
|
|
;; Copyright (C) 2003-2012 Free Software Foundation, Inc.
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2006-11-25 13:29:40 +00:00
|
|
|
;; Author: Pavel Kobyakov <pk_at_work@yahoo.com>
|
|
|
|
;; Maintainer: Pavel Kobyakov <pk_at_work@yahoo.com>
|
2004-05-29 12:55:24 +00:00
|
|
|
;; Version: 0.3
|
|
|
|
;; Keywords: c languages tools
|
|
|
|
|
|
|
|
;; This file is part of GNU Emacs.
|
|
|
|
|
2008-05-06 07:25:26 +00:00
|
|
|
;; GNU Emacs is free software: you can redistribute it and/or modify
|
2004-05-29 12:55:24 +00:00
|
|
|
;; it under the terms of the GNU General Public License as published by
|
2008-05-06 07:25:26 +00:00
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
;; (at your option) any later version.
|
2004-05-29 12:55:24 +00:00
|
|
|
|
|
|
|
;; GNU Emacs is distributed in the hope that it will be useful,
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
2008-05-06 07:25:26 +00:00
|
|
|
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
|
2004-05-29 12:55:24 +00:00
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
;;
|
|
|
|
;; Flymake is a minor Emacs mode performing on-the-fly syntax
|
|
|
|
;; checks using the external syntax check tool (for C/C++ this
|
|
|
|
;; is usually the compiler)
|
|
|
|
|
2006-01-10 19:16:02 +00:00
|
|
|
;;; Bugs/todo:
|
|
|
|
|
|
|
|
;; - Only uses "Makefile", not "makefile" or "GNUmakefile"
|
|
|
|
;; (from http://bugs.debian.org/337339).
|
|
|
|
|
2004-05-29 12:55:24 +00:00
|
|
|
;;; Code:
|
|
|
|
|
More CL cleanups and reduction of use of cl.el.
* woman.el, winner.el, vc/vc-rcs.el, vc/vc-hooks.el, vc/vc-hg.el:
* vc/vc-git.el, vc/vc-dir.el, vc/vc-bzr.el, vc/vc-annotate.el:
* textmodes/tex-mode.el, textmodes/sgml-mode.el, tar-mode.el:
* strokes.el, ses.el, server.el, progmodes/js.el, progmodes/gdb-mi.el:
* progmodes/flymake.el, progmodes/ebrowse.el, progmodes/compile.el:
* play/tetris.el, play/snake.el, play/pong.el, play/landmark.el:
* play/hanoi.el, play/decipher.el, play/5x5.el, nxml/nxml-mode.el:
* net/secrets.el, net/quickurl.el, midnight.el, mail/footnote.el:
* image-dired.el, ibuffer.el, ibuf-macs.el, ibuf-ext.el, hexl.el:
* eshell/eshell.el, eshell/esh-io.el, eshell/esh-ext.el:
* eshell/esh-cmd.el, eshell/em-ls.el, eshell/em-hist.el:
* eshell/em-cmpl.el, eshell/em-banner.el:
* url/url.el, url/url-queue.el, url/url-parse.el, url/url-http.el:
* url/url-future.el, url/url-dav.el, url/url-cookie.el:
* calendar/parse-time.el, test/eshell.el: Use cl-lib.
* wid-browse.el, wdired.el, vc/vc.el, vc/vc-mtn.el, vc/vc-cvs.el:
* vc/vc-arch.el, tree-widget.el, textmodes/texinfo.el:
* textmodes/refill.el, textmodes/css-mode.el, term/tvi970.el:
* term/ns-win.el, term.el, shell.el, ps-samp.el:
* progmodes/perl-mode.el, progmodes/pascal.el, progmodes/gud.el:
* progmodes/glasses.el, progmodes/etags.el, progmodes/cwarn.el:
* play/gamegrid.el, play/bubbles.el, novice.el, notifications.el:
* net/zeroconf.el, net/xesam.el, net/snmp-mode.el, net/mairix.el:
* net/ldap.el, net/eudc.el, net/browse-url.el, man.el:
* mail/mailheader.el, mail/feedmail.el:
* url/url-util.el, url/url-privacy.el, url/url-nfs.el, url/url-misc.el:
* url/url-methods.el, url/url-gw.el, url/url-file.el, url/url-expand.el:
Dont use CL.
* ibuf-ext.el (ibuffer-mark-old-buffers): Use float-time.
* eshell/esh-opt.el (eshell-eval-using-options): Quote code with
`lambda' rather than with `quote'.
(eshell-do-opt): Adjust accordingly.
(eshell-process-option): Simplify.
* eshell/esh-var.el:
* eshell/em-script.el: Require `esh-opt' for eshell-eval-using-options.
* emacs-pcase.el (pcase--dontcare-upats, pcase--let*)
(pcase--expand, pcase--u1): Rename pcase's internal `dontcare' pattern
to `pcase--dontcare'.
* emacs-cl.el (labels): Mark obsolete.
(cl--letf, letf): Move to cl-lib.
(cl--letf*, letf*): Remove.
* emacs-cl-lib.el (cl-nth-value): Use defalias.
* emacs-cl-macs.el (cl-dolist, cl-dotimes): Add indent rule.
(cl-progv): Rewrite.
(cl--letf, cl-letf): Move from cl.el.
(cl-letf*): New macro.
* emacs-cl-extra.el (cl--progv-before, cl--progv-after): Remove.
2012-07-11 23:13:41 +00:00
|
|
|
(eval-when-compile (require 'cl-lib))
|
2006-01-09 19:11:28 +00:00
|
|
|
(if (featurep 'xemacs) (require 'overlay))
|
|
|
|
|
2006-01-03 18:44:42 +00:00
|
|
|
(defvar flymake-is-running nil
|
|
|
|
"If t, flymake syntax check process is running for the current buffer.")
|
|
|
|
(make-variable-buffer-local 'flymake-is-running)
|
2005-07-03 23:18:19 +00:00
|
|
|
|
2006-01-03 18:44:42 +00:00
|
|
|
(defvar flymake-timer nil
|
|
|
|
"Timer for starting syntax check.")
|
|
|
|
(make-variable-buffer-local 'flymake-timer)
|
2005-07-03 23:18:19 +00:00
|
|
|
|
2006-01-03 18:44:42 +00:00
|
|
|
(defvar flymake-last-change-time nil
|
|
|
|
"Time of last buffer change.")
|
|
|
|
(make-variable-buffer-local 'flymake-last-change-time)
|
|
|
|
|
|
|
|
(defvar flymake-check-start-time nil
|
|
|
|
"Time at which syntax check was started.")
|
|
|
|
(make-variable-buffer-local 'flymake-check-start-time)
|
|
|
|
|
|
|
|
(defvar flymake-check-was-interrupted nil
|
|
|
|
"Non-nil if syntax check was killed by `flymake-compile'.")
|
|
|
|
(make-variable-buffer-local 'flymake-check-was-interrupted)
|
|
|
|
|
|
|
|
(defvar flymake-err-info nil
|
|
|
|
"Sorted list of line numbers and lists of err info in the form (file, err-text).")
|
|
|
|
(make-variable-buffer-local 'flymake-err-info)
|
|
|
|
|
|
|
|
(defvar flymake-new-err-info nil
|
|
|
|
"Same as `flymake-err-info', effective when a syntax check is in progress.")
|
|
|
|
(make-variable-buffer-local 'flymake-new-err-info)
|
2005-07-03 23:18:19 +00:00
|
|
|
|
2004-05-29 12:55:24 +00:00
|
|
|
;;;; [[ cross-emacs compatibility routines
|
2004-11-26 23:56:39 +00:00
|
|
|
(defsubst flymake-makehash (&optional test)
|
|
|
|
(if (fboundp 'make-hash-table)
|
|
|
|
(if test (make-hash-table :test test) (make-hash-table))
|
2005-05-21 04:53:14 +00:00
|
|
|
(with-no-warnings
|
|
|
|
(makehash test))))
|
2004-11-25 16:43:32 +00:00
|
|
|
|
2005-03-24 22:55:54 +00:00
|
|
|
(defalias 'flymake-float-time
|
|
|
|
(if (fboundp 'float-time)
|
|
|
|
'float-time
|
2005-07-06 19:03:21 +00:00
|
|
|
(if (featurep 'xemacs)
|
|
|
|
(lambda ()
|
2009-03-13 20:37:43 +00:00
|
|
|
(multiple-value-bind (s0 s1 s2) (values-list (current-time))
|
2005-07-06 19:03:21 +00:00
|
|
|
(+ (* (float (ash 1 16)) s0) (float s1) (* 0.0000001 s2)))))))
|
2004-11-26 23:56:39 +00:00
|
|
|
|
2006-01-03 18:44:42 +00:00
|
|
|
(defalias 'flymake-replace-regexp-in-string
|
|
|
|
(if (eval-when-compile (fboundp 'replace-regexp-in-string))
|
|
|
|
'replace-regexp-in-string
|
|
|
|
(lambda (regexp rep str)
|
|
|
|
(replace-in-string str regexp rep))))
|
|
|
|
|
|
|
|
(defalias 'flymake-split-string
|
|
|
|
(if (condition-case nil (equal (split-string " bc " " " t) '("bc"))
|
|
|
|
(error nil))
|
|
|
|
(lambda (str pattern) (split-string str pattern t))
|
|
|
|
(lambda (str pattern)
|
|
|
|
"Split STR into a list of substrings bounded by PATTERN.
|
2005-04-30 20:13:39 +00:00
|
|
|
Zero-length substrings at the beginning and end of the list are omitted."
|
2006-01-03 18:44:42 +00:00
|
|
|
(let ((split (split-string str pattern)))
|
2006-01-10 18:46:07 +00:00
|
|
|
(while (equal (car split) "") (setq split (cdr split)))
|
|
|
|
(setq split (nreverse split))
|
|
|
|
(while (equal (car split) "") (setq split (cdr split)))
|
|
|
|
(nreverse split)))))
|
2006-01-03 18:44:42 +00:00
|
|
|
|
|
|
|
(defalias 'flymake-get-temp-dir
|
2005-03-24 22:55:54 +00:00
|
|
|
(if (fboundp 'temp-directory)
|
2006-01-03 18:44:42 +00:00
|
|
|
'temp-directory
|
|
|
|
(lambda () temporary-file-directory)))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2006-11-25 13:29:40 +00:00
|
|
|
(defun flymake-posn-at-point-as-event (&optional position window dx dy)
|
|
|
|
"Return pixel position of top left corner of glyph at POSITION,
|
|
|
|
relative to top left corner of WINDOW, as a mouse-1 click
|
|
|
|
event (identical to the event that would be triggered by clicking
|
|
|
|
mouse button 1 at the top left corner of the glyph).
|
|
|
|
|
|
|
|
POSITION and WINDOW default to the position of point in the
|
|
|
|
selected window.
|
|
|
|
|
|
|
|
DX and DY specify optional offsets from the top left of the glyph."
|
|
|
|
(unless window (setq window (selected-window)))
|
|
|
|
(unless position (setq position (window-point window)))
|
|
|
|
(unless dx (setq dx 0))
|
|
|
|
(unless dy (setq dy 0))
|
|
|
|
|
|
|
|
(let* ((pos (posn-at-point position window))
|
|
|
|
(x-y (posn-x-y pos))
|
|
|
|
(edges (window-inside-pixel-edges window))
|
|
|
|
(win-x-y (window-pixel-edges window)))
|
|
|
|
;; adjust for window edges
|
|
|
|
(setcar (nthcdr 2 pos)
|
|
|
|
(cons (+ (car x-y) (car edges) (- (car win-x-y)) dx)
|
|
|
|
(+ (cdr x-y) (cadr edges) (- (cadr win-x-y)) dy)))
|
|
|
|
(list 'mouse-1 pos)))
|
2006-01-03 18:44:42 +00:00
|
|
|
|
|
|
|
(defun flymake-popup-menu (menu-data)
|
|
|
|
"Pop up the flymake menu at point, using the data MENU-DATA.
|
2005-04-30 20:13:39 +00:00
|
|
|
POS is a list of the form ((X Y) WINDOW), where X and Y are
|
|
|
|
pixels positions from the top left corner of WINDOW's frame.
|
|
|
|
MENU-DATA is a list of error and warning messages returned by
|
|
|
|
`flymake-make-err-menu-data'."
|
|
|
|
(if (featurep 'xemacs)
|
2006-01-03 18:44:42 +00:00
|
|
|
(let* ((pos (flymake-get-point-pixel-pos))
|
|
|
|
(x-pos (nth 0 pos))
|
|
|
|
(y-pos (nth 1 pos))
|
2004-11-26 23:56:39 +00:00
|
|
|
(fake-event-props '(button 1 x 1 y 1)))
|
|
|
|
(setq fake-event-props (plist-put fake-event-props 'x x-pos))
|
|
|
|
(setq fake-event-props (plist-put fake-event-props 'y y-pos))
|
2006-01-03 18:44:42 +00:00
|
|
|
(popup-menu (flymake-make-xemacs-menu menu-data)
|
|
|
|
(make-event 'button-press fake-event-props)))
|
|
|
|
(x-popup-menu (if (eval-when-compile (fboundp 'posn-at-point))
|
2006-11-25 13:29:40 +00:00
|
|
|
(flymake-posn-at-point-as-event)
|
2006-01-03 18:44:42 +00:00
|
|
|
(list (flymake-get-point-pixel-pos) (selected-window)))
|
|
|
|
(flymake-make-emacs-menu menu-data))))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2004-11-25 16:43:32 +00:00
|
|
|
(defun flymake-make-emacs-menu (menu-data)
|
2005-04-30 20:13:39 +00:00
|
|
|
"Return a menu specifier using MENU-DATA.
|
|
|
|
MENU-DATA is a list of error and warning messages returned by
|
|
|
|
`flymake-make-err-menu-data'.
|
|
|
|
See `x-popup-menu' for the menu specifier format."
|
2004-11-25 16:43:32 +00:00
|
|
|
(let* ((menu-title (nth 0 menu-data))
|
|
|
|
(menu-items (nth 1 menu-data))
|
2006-01-03 18:44:42 +00:00
|
|
|
(menu-commands (mapcar (lambda (foo)
|
|
|
|
(cons (nth 0 foo) (nth 1 foo)))
|
|
|
|
menu-items)))
|
2004-11-25 16:43:32 +00:00
|
|
|
(list menu-title (cons "" menu-commands))))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2004-11-26 23:56:39 +00:00
|
|
|
(if (featurep 'xemacs) (progn
|
|
|
|
|
2005-03-24 22:55:54 +00:00
|
|
|
(defun flymake-nop ())
|
|
|
|
|
2004-11-25 16:33:53 +00:00
|
|
|
(defun flymake-make-xemacs-menu (menu-data)
|
2005-04-30 20:13:39 +00:00
|
|
|
"Return a menu specifier using MENU-DATA."
|
2004-11-25 16:43:32 +00:00
|
|
|
(let* ((menu-title (nth 0 menu-data))
|
|
|
|
(menu-items (nth 1 menu-data))
|
|
|
|
(menu-commands nil))
|
|
|
|
(setq menu-commands (mapcar (lambda (foo)
|
|
|
|
(vector (nth 0 foo) (or (nth 1 foo) '(flymake-nop)) t))
|
|
|
|
menu-items))
|
|
|
|
(cons menu-title menu-commands)))
|
|
|
|
|
2004-11-26 23:56:39 +00:00
|
|
|
)) ;; xemacs
|
|
|
|
|
2006-01-03 18:44:42 +00:00
|
|
|
(unless (eval-when-compile (fboundp 'posn-at-point))
|
|
|
|
|
2004-11-25 16:43:32 +00:00
|
|
|
(defun flymake-current-row ()
|
|
|
|
"Return current row number in current frame."
|
2005-03-24 22:55:54 +00:00
|
|
|
(if (fboundp 'window-edges)
|
|
|
|
(+ (car (cdr (window-edges))) (count-lines (window-start) (point)))
|
|
|
|
(count-lines (window-start) (point))))
|
2004-11-25 16:43:32 +00:00
|
|
|
|
|
|
|
(defun flymake-selected-frame ()
|
2005-03-24 22:55:54 +00:00
|
|
|
(if (fboundp 'window-edges)
|
|
|
|
(selected-frame)
|
|
|
|
(selected-window)))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2006-01-03 18:44:42 +00:00
|
|
|
(defun flymake-get-point-pixel-pos ()
|
|
|
|
"Return point position in pixels: (x, y)."
|
|
|
|
(let ((mouse-pos (mouse-position))
|
|
|
|
(pixel-pos nil)
|
|
|
|
(ret nil))
|
|
|
|
(if (car (cdr mouse-pos))
|
|
|
|
(progn
|
|
|
|
(set-mouse-position (flymake-selected-frame) (current-column) (flymake-current-row))
|
|
|
|
(setq pixel-pos (mouse-pixel-position))
|
|
|
|
(set-mouse-position (car mouse-pos) (car (cdr mouse-pos)) (cdr (cdr mouse-pos)))
|
|
|
|
(setq ret (list (car (cdr pixel-pos)) (cdr (cdr pixel-pos)))))
|
|
|
|
(progn
|
|
|
|
(setq ret '(0 0))))
|
|
|
|
(flymake-log 3 "mouse pos is %s" ret)
|
|
|
|
ret))
|
|
|
|
|
|
|
|
) ;; End of (unless (fboundp 'posn-at-point)
|
|
|
|
|
2004-05-29 12:55:24 +00:00
|
|
|
;;;; ]]
|
|
|
|
|
|
|
|
(defcustom flymake-log-level -1
|
2005-03-24 22:55:54 +00:00
|
|
|
"Logging level, only messages with level lower or equal will be logged.
|
2004-05-29 12:55:24 +00:00
|
|
|
-1 = NONE, 0 = ERROR, 1 = WARNING, 2 = INFO, 3 = DEBUG"
|
2004-11-25 16:43:32 +00:00
|
|
|
:group 'flymake
|
|
|
|
:type 'integer)
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2004-11-25 16:33:53 +00:00
|
|
|
(defun flymake-log (level text &rest args)
|
2005-04-30 20:13:39 +00:00
|
|
|
"Log a message at level LEVEL.
|
|
|
|
If LEVEL is higher than `flymake-log-level', the message is
|
|
|
|
ignored. Otherwise, it is printed using `message'.
|
|
|
|
TEXT is a format control string, and the remaining arguments ARGS
|
|
|
|
are the string substitutions (see `format')."
|
2004-11-25 16:43:32 +00:00
|
|
|
(if (<= level flymake-log-level)
|
|
|
|
(let* ((msg (apply 'format text args)))
|
2005-09-18 12:31:28 +00:00
|
|
|
(message "%s" msg)
|
2004-11-25 16:43:32 +00:00
|
|
|
;;(with-temp-buffer
|
|
|
|
;; (insert msg)
|
|
|
|
;; (insert "\n")
|
(flymake-create-temp-with-folder-structure): Use expand-file-name.
(flymake-delete-temp-directory): Use expand-file-name,
file-name-directory, and directory-file-name.
(flymake-strrchr): Delete.
(flymake-start-syntax-check): Don't pass the redundant buffer argument
to the init-f function.
(flymake-init-find-buildfile-dir, flymake-init-create-temp-buffer-copy)
(flymake-init-create-temp-source-and-master-buffer-copy, flymake-perl-init)
(flymake-save-buffer-in-file, flymake-simple-make-init-impl, flymake-xml-init)
(flymake-simple-make-init, flymake-master-make-init, flymake-master-tex-init)
(flymake-master-make-header-init, flymake-simple-make-java-init)
(flymake-simple-ant-java-init, flymake-simple-tex-init):
Remove corresponding redundant buffer argument.
(flymake-allowed-file-name-masks): Remove last elems that are equal to
the default anyway. Clean up regexps.
2006-01-03 19:59:00 +00:00
|
|
|
;; (flymake-save-buffer-in-file "d:/flymake.log" t) ; make log file name customizable
|
2004-11-25 16:43:32 +00:00
|
|
|
;;)
|
2004-11-25 16:33:53 +00:00
|
|
|
)))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2004-11-25 16:33:53 +00:00
|
|
|
(defun flymake-ins-after (list pos val)
|
2004-11-25 16:43:32 +00:00
|
|
|
"Insert VAL into LIST after position POS."
|
|
|
|
(let ((tmp (copy-sequence list))) ; (???)
|
|
|
|
(setcdr (nthcdr pos tmp) (cons val (nthcdr (1+ pos) tmp)))
|
|
|
|
tmp))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2004-11-25 16:33:53 +00:00
|
|
|
(defun flymake-set-at (list pos val)
|
2005-03-24 22:42:42 +00:00
|
|
|
"Set VAL at position POS in LIST."
|
2004-11-25 16:43:32 +00:00
|
|
|
(let ((tmp (copy-sequence list))) ; (???)
|
|
|
|
(setcar (nthcdr pos tmp) val)
|
|
|
|
tmp))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2006-01-03 18:44:42 +00:00
|
|
|
(defvar flymake-processes nil
|
|
|
|
"List of currently active flymake processes.")
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2005-03-24 22:42:42 +00:00
|
|
|
(defvar flymake-output-residual nil)
|
2004-11-25 16:33:53 +00:00
|
|
|
|
2004-05-29 12:55:24 +00:00
|
|
|
(make-variable-buffer-local 'flymake-output-residual)
|
2004-11-25 16:33:53 +00:00
|
|
|
|
2009-02-18 07:41:10 +00:00
|
|
|
(defgroup flymake nil
|
2012-04-22 13:58:00 +00:00
|
|
|
"Universal on-the-fly syntax checker."
|
2009-02-18 07:41:10 +00:00
|
|
|
:version "23.1"
|
|
|
|
:group 'tools)
|
|
|
|
|
2004-11-25 16:43:32 +00:00
|
|
|
(defcustom flymake-allowed-file-name-masks
|
2010-01-28 19:53:11 +00:00
|
|
|
'(("\\.\\(?:c\\(?:pp\\|xx\\|\\+\\+\\)?\\|CC\\)\\'" flymake-simple-make-init)
|
2006-01-05 18:51:00 +00:00
|
|
|
("\\.xml\\'" flymake-xml-init)
|
|
|
|
("\\.html?\\'" flymake-xml-init)
|
|
|
|
("\\.cs\\'" flymake-simple-make-init)
|
2008-02-13 19:30:58 +00:00
|
|
|
("\\.p[ml]\\'" flymake-perl-init)
|
|
|
|
("\\.php[345]?\\'" flymake-php-init)
|
(flymake-create-temp-with-folder-structure): Use expand-file-name.
(flymake-delete-temp-directory): Use expand-file-name,
file-name-directory, and directory-file-name.
(flymake-strrchr): Delete.
(flymake-start-syntax-check): Don't pass the redundant buffer argument
to the init-f function.
(flymake-init-find-buildfile-dir, flymake-init-create-temp-buffer-copy)
(flymake-init-create-temp-source-and-master-buffer-copy, flymake-perl-init)
(flymake-save-buffer-in-file, flymake-simple-make-init-impl, flymake-xml-init)
(flymake-simple-make-init, flymake-master-make-init, flymake-master-tex-init)
(flymake-master-make-header-init, flymake-simple-make-java-init)
(flymake-simple-ant-java-init, flymake-simple-tex-init):
Remove corresponding redundant buffer argument.
(flymake-allowed-file-name-masks): Remove last elems that are equal to
the default anyway. Clean up regexps.
2006-01-03 19:59:00 +00:00
|
|
|
("\\.h\\'" flymake-master-make-header-init flymake-master-cleanup)
|
|
|
|
("\\.java\\'" flymake-simple-make-java-init flymake-simple-java-cleanup)
|
|
|
|
("[0-9]+\\.tex\\'" flymake-master-tex-init flymake-master-cleanup)
|
2006-01-05 18:51:00 +00:00
|
|
|
("\\.tex\\'" flymake-simple-tex-init)
|
|
|
|
("\\.idl\\'" flymake-simple-make-init)
|
(flymake-create-temp-with-folder-structure): Use expand-file-name.
(flymake-delete-temp-directory): Use expand-file-name,
file-name-directory, and directory-file-name.
(flymake-strrchr): Delete.
(flymake-start-syntax-check): Don't pass the redundant buffer argument
to the init-f function.
(flymake-init-find-buildfile-dir, flymake-init-create-temp-buffer-copy)
(flymake-init-create-temp-source-and-master-buffer-copy, flymake-perl-init)
(flymake-save-buffer-in-file, flymake-simple-make-init-impl, flymake-xml-init)
(flymake-simple-make-init, flymake-master-make-init, flymake-master-tex-init)
(flymake-master-make-header-init, flymake-simple-make-java-init)
(flymake-simple-ant-java-init, flymake-simple-tex-init):
Remove corresponding redundant buffer argument.
(flymake-allowed-file-name-masks): Remove last elems that are equal to
the default anyway. Clean up regexps.
2006-01-03 19:59:00 +00:00
|
|
|
;; ("\\.cpp\\'" 1)
|
|
|
|
;; ("\\.java\\'" 3)
|
|
|
|
;; ("\\.h\\'" 2 ("\\.cpp\\'" "\\.c\\'")
|
2005-03-24 22:42:42 +00:00
|
|
|
;; ("[ \t]*#[ \t]*include[ \t]*\"\\([\w0-9/\\_\.]*[/\\]*\\)\\(%s\\)\"" 1 2))
|
(flymake-create-temp-with-folder-structure): Use expand-file-name.
(flymake-delete-temp-directory): Use expand-file-name,
file-name-directory, and directory-file-name.
(flymake-strrchr): Delete.
(flymake-start-syntax-check): Don't pass the redundant buffer argument
to the init-f function.
(flymake-init-find-buildfile-dir, flymake-init-create-temp-buffer-copy)
(flymake-init-create-temp-source-and-master-buffer-copy, flymake-perl-init)
(flymake-save-buffer-in-file, flymake-simple-make-init-impl, flymake-xml-init)
(flymake-simple-make-init, flymake-master-make-init, flymake-master-tex-init)
(flymake-master-make-header-init, flymake-simple-make-java-init)
(flymake-simple-ant-java-init, flymake-simple-tex-init):
Remove corresponding redundant buffer argument.
(flymake-allowed-file-name-masks): Remove last elems that are equal to
the default anyway. Clean up regexps.
2006-01-03 19:59:00 +00:00
|
|
|
;; ("\\.idl\\'" 1)
|
|
|
|
;; ("\\.odl\\'" 1)
|
|
|
|
;; ("[0-9]+\\.tex\\'" 2 ("\\.tex\\'")
|
2005-03-24 22:42:42 +00:00
|
|
|
;; ("[ \t]*\\input[ \t]*{\\(.*\\)\\(%s\\)}" 1 2 ))
|
(flymake-create-temp-with-folder-structure): Use expand-file-name.
(flymake-delete-temp-directory): Use expand-file-name,
file-name-directory, and directory-file-name.
(flymake-strrchr): Delete.
(flymake-start-syntax-check): Don't pass the redundant buffer argument
to the init-f function.
(flymake-init-find-buildfile-dir, flymake-init-create-temp-buffer-copy)
(flymake-init-create-temp-source-and-master-buffer-copy, flymake-perl-init)
(flymake-save-buffer-in-file, flymake-simple-make-init-impl, flymake-xml-init)
(flymake-simple-make-init, flymake-master-make-init, flymake-master-tex-init)
(flymake-master-make-header-init, flymake-simple-make-java-init)
(flymake-simple-ant-java-init, flymake-simple-tex-init):
Remove corresponding redundant buffer argument.
(flymake-allowed-file-name-masks): Remove last elems that are equal to
the default anyway. Clean up regexps.
2006-01-03 19:59:00 +00:00
|
|
|
;; ("\\.tex\\'" 1)
|
2004-11-25 16:43:32 +00:00
|
|
|
)
|
2010-01-28 19:53:11 +00:00
|
|
|
"Files syntax checking is allowed for."
|
2004-11-25 16:43:32 +00:00
|
|
|
:group 'flymake
|
|
|
|
:type '(repeat (string symbol symbol symbol)))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2004-11-25 16:33:53 +00:00
|
|
|
(defun flymake-get-file-name-mode-and-masks (file-name)
|
2005-03-24 22:42:42 +00:00
|
|
|
"Return the corresponding entry from `flymake-allowed-file-name-masks'."
|
2004-11-25 16:43:32 +00:00
|
|
|
(unless (stringp file-name)
|
|
|
|
(error "Invalid file-name"))
|
2005-03-25 00:17:42 +00:00
|
|
|
(let ((fnm flymake-allowed-file-name-masks)
|
2004-11-25 16:43:32 +00:00
|
|
|
(mode-and-masks nil))
|
2005-03-25 00:17:42 +00:00
|
|
|
(while (and (not mode-and-masks) fnm)
|
|
|
|
(if (string-match (car (car fnm)) file-name)
|
|
|
|
(setq mode-and-masks (cdr (car fnm))))
|
|
|
|
(setq fnm (cdr fnm)))
|
2004-11-25 16:43:32 +00:00
|
|
|
(flymake-log 3 "file %s, init=%s" file-name (car mode-and-masks))
|
|
|
|
mode-and-masks))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2004-11-25 16:33:53 +00:00
|
|
|
(defun flymake-can-syntax-check-file (file-name)
|
2004-11-25 16:43:32 +00:00
|
|
|
"Determine whether we can syntax check FILE-NAME.
|
2004-11-25 16:33:53 +00:00
|
|
|
Return nil if we cannot, non-nil if we can."
|
2004-11-25 16:43:32 +00:00
|
|
|
(if (flymake-get-init-function file-name) t nil))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2004-11-25 16:33:53 +00:00
|
|
|
(defun flymake-get-init-function (file-name)
|
2004-11-25 16:43:32 +00:00
|
|
|
"Return init function to be used for the file."
|
|
|
|
(let* ((init-f (nth 0 (flymake-get-file-name-mode-and-masks file-name))))
|
2005-03-24 22:42:42 +00:00
|
|
|
;;(flymake-log 0 "calling %s" init-f)
|
|
|
|
;;(funcall init-f (current-buffer))
|
2004-11-25 16:43:32 +00:00
|
|
|
init-f))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2004-11-25 16:33:53 +00:00
|
|
|
(defun flymake-get-cleanup-function (file-name)
|
2004-11-25 16:43:32 +00:00
|
|
|
"Return cleanup function to be used for the file."
|
2006-01-05 18:51:00 +00:00
|
|
|
(or (nth 1 (flymake-get-file-name-mode-and-masks file-name))
|
|
|
|
'flymake-simple-cleanup))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2004-11-25 16:33:53 +00:00
|
|
|
(defun flymake-get-real-file-name-function (file-name)
|
(flymake-create-temp-with-folder-structure): Use expand-file-name.
(flymake-delete-temp-directory): Use expand-file-name,
file-name-directory, and directory-file-name.
(flymake-strrchr): Delete.
(flymake-start-syntax-check): Don't pass the redundant buffer argument
to the init-f function.
(flymake-init-find-buildfile-dir, flymake-init-create-temp-buffer-copy)
(flymake-init-create-temp-source-and-master-buffer-copy, flymake-perl-init)
(flymake-save-buffer-in-file, flymake-simple-make-init-impl, flymake-xml-init)
(flymake-simple-make-init, flymake-master-make-init, flymake-master-tex-init)
(flymake-master-make-header-init, flymake-simple-make-java-init)
(flymake-simple-ant-java-init, flymake-simple-tex-init):
Remove corresponding redundant buffer argument.
(flymake-allowed-file-name-masks): Remove last elems that are equal to
the default anyway. Clean up regexps.
2006-01-03 19:59:00 +00:00
|
|
|
(or (nth 2 (flymake-get-file-name-mode-and-masks file-name))
|
|
|
|
'flymake-get-real-file-name))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
|
|
|
(defvar flymake-find-buildfile-cache (flymake-makehash 'equal))
|
|
|
|
|
2004-11-25 16:33:53 +00:00
|
|
|
(defun flymake-get-buildfile-from-cache (dir-name)
|
2004-11-25 16:43:32 +00:00
|
|
|
(gethash dir-name flymake-find-buildfile-cache))
|
2004-11-25 16:33:53 +00:00
|
|
|
|
|
|
|
(defun flymake-add-buildfile-to-cache (dir-name buildfile)
|
2004-11-25 16:43:32 +00:00
|
|
|
(puthash dir-name buildfile flymake-find-buildfile-cache))
|
2004-11-25 16:33:53 +00:00
|
|
|
|
|
|
|
(defun flymake-clear-buildfile-cache ()
|
2004-11-25 16:43:32 +00:00
|
|
|
(clrhash flymake-find-buildfile-cache))
|
2004-11-25 16:33:53 +00:00
|
|
|
|
2006-01-10 04:05:46 +00:00
|
|
|
(defun flymake-find-buildfile (buildfile-name source-dir-name)
|
2004-11-25 16:43:32 +00:00
|
|
|
"Find buildfile starting from current directory.
|
2004-11-25 16:33:53 +00:00
|
|
|
Buildfile includes Makefile, build.xml etc.
|
2004-11-25 16:43:32 +00:00
|
|
|
Return its file name if found, or nil if not found."
|
2006-01-10 04:05:46 +00:00
|
|
|
(or (flymake-get-buildfile-from-cache source-dir-name)
|
2008-10-25 15:18:53 +00:00
|
|
|
(let* ((file (locate-dominating-file source-dir-name buildfile-name)))
|
2007-07-20 04:09:08 +00:00
|
|
|
(if file
|
2006-01-10 04:05:46 +00:00
|
|
|
(progn
|
2007-07-20 04:09:08 +00:00
|
|
|
(flymake-log 3 "found buildfile at %s" file)
|
|
|
|
(flymake-add-buildfile-to-cache source-dir-name file)
|
|
|
|
file)
|
2006-01-10 04:05:46 +00:00
|
|
|
(progn
|
|
|
|
(flymake-log 3 "buildfile for %s not found" source-dir-name)
|
|
|
|
nil)))))
|
2004-11-25 16:43:32 +00:00
|
|
|
|
|
|
|
(defun flymake-fix-file-name (name)
|
2006-02-16 11:40:51 +00:00
|
|
|
"Replace all occurrences of '\' with '/'."
|
2004-11-25 16:43:32 +00:00
|
|
|
(when name
|
2006-01-10 18:46:07 +00:00
|
|
|
(setq name (expand-file-name name))
|
|
|
|
(setq name (abbreviate-file-name name))
|
|
|
|
(setq name (directory-file-name name))
|
|
|
|
name))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2004-11-25 16:33:53 +00:00
|
|
|
(defun flymake-same-files (file-name-one file-name-two)
|
2004-11-25 16:43:32 +00:00
|
|
|
"Check if FILE-NAME-ONE and FILE-NAME-TWO point to same file.
|
2004-11-25 16:33:53 +00:00
|
|
|
Return t if so, nil if not."
|
2004-11-25 16:43:32 +00:00
|
|
|
(equal (flymake-fix-file-name file-name-one)
|
|
|
|
(flymake-fix-file-name file-name-two)))
|
|
|
|
|
2004-05-29 12:55:24 +00:00
|
|
|
(defcustom flymake-master-file-dirs '("." "./src" "./UnitTest")
|
2005-03-24 22:42:42 +00:00
|
|
|
"Dirs where to look for master files."
|
2004-11-25 16:43:32 +00:00
|
|
|
:group 'flymake
|
|
|
|
:type '(repeat (string)))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
|
|
|
(defcustom flymake-master-file-count-limit 32
|
2004-11-25 16:43:32 +00:00
|
|
|
"Max number of master files to check."
|
|
|
|
:group 'flymake
|
|
|
|
:type 'integer)
|
2004-11-25 16:33:53 +00:00
|
|
|
|
2004-11-26 23:56:39 +00:00
|
|
|
;; This is bound dynamically to pass a parameter to a sort predicate below
|
|
|
|
(defvar flymake-included-file-name)
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2004-11-25 16:33:53 +00:00
|
|
|
(defun flymake-find-possible-master-files (file-name master-file-dirs masks)
|
2005-03-24 22:42:42 +00:00
|
|
|
"Find (by name and location) all possible master files.
|
2010-01-28 19:53:11 +00:00
|
|
|
Master files include .cpp and .c for .h. Files are searched for
|
2004-11-25 16:33:53 +00:00
|
|
|
starting from the .h directory and max max-level parent dirs.
|
2004-05-29 12:55:24 +00:00
|
|
|
File contents are not checked."
|
2005-03-25 00:17:42 +00:00
|
|
|
(let* ((dirs master-file-dirs)
|
2004-11-25 16:43:32 +00:00
|
|
|
(files nil)
|
2005-03-25 00:17:42 +00:00
|
|
|
(done nil))
|
|
|
|
|
|
|
|
(while (and (not done) dirs)
|
2006-01-10 18:46:07 +00:00
|
|
|
(let* ((dir (expand-file-name (car dirs) (file-name-directory file-name)))
|
2005-03-25 00:17:42 +00:00
|
|
|
(masks masks))
|
|
|
|
(while (and (file-exists-p dir) (not done) masks)
|
|
|
|
(let* ((mask (car masks))
|
|
|
|
(dir-files (directory-files dir t mask)))
|
|
|
|
|
|
|
|
(flymake-log 3 "dir %s, %d file(s) for mask %s"
|
|
|
|
dir (length dir-files) mask)
|
|
|
|
(while (and (not done) dir-files)
|
|
|
|
(when (not (file-directory-p (car dir-files)))
|
|
|
|
(setq files (cons (car dir-files) files))
|
2004-11-25 16:43:32 +00:00
|
|
|
(when (>= (length files) flymake-master-file-count-limit)
|
|
|
|
(flymake-log 3 "master file count limit (%d) reached" flymake-master-file-count-limit)
|
|
|
|
(setq done t)))
|
2005-03-25 00:17:42 +00:00
|
|
|
(setq dir-files (cdr dir-files))))
|
|
|
|
(setq masks (cdr masks))))
|
|
|
|
(setq dirs (cdr dirs)))
|
2004-11-25 16:43:32 +00:00
|
|
|
(when files
|
2004-11-26 23:56:39 +00:00
|
|
|
(let ((flymake-included-file-name (file-name-nondirectory file-name)))
|
|
|
|
(setq files (sort files 'flymake-master-file-compare))))
|
2004-11-25 16:43:32 +00:00
|
|
|
(flymake-log 3 "found %d possible master file(s)" (length files))
|
|
|
|
files))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2004-11-25 16:33:53 +00:00
|
|
|
(defun flymake-master-file-compare (file-one file-two)
|
2005-07-01 14:13:12 +00:00
|
|
|
"Compare two files specified by FILE-ONE and FILE-TWO.
|
2004-11-25 16:33:53 +00:00
|
|
|
This function is used in sort to move most possible file names
|
2005-07-01 14:13:12 +00:00
|
|
|
to the beginning of the list (File.h -> File.cpp moved to top)."
|
2004-11-25 16:43:32 +00:00
|
|
|
(and (equal (file-name-sans-extension flymake-included-file-name)
|
* lisp/files.el (file-name-base): New convenience function.
* lisp/autoinsert.el, lisp/cus-dep.el, lisp/doc-view.el, lisp/image-dired.el,
* lisp/woman.el, lisp/eshell/esh-cmd.el, lisp/progmodes/ada-xref.el,
* lisp/progmodes/cc-defs.el, lisp/progmodes/cperl-mode.el,
* lisp/progmodes/flymake.el, lisp/progmodes/gud.el, lisp/progmodes/idlwave.el,
* lisp/textmodes/ispell.el, lisp/textmodes/reftex-ref.el,
* lisp/textmodes/tex-mode.el: Use it.
Did not touch cedet and org because they are maintained elsewhere.
2012-06-26 16:23:01 +00:00
|
|
|
(file-name-base file-one))
|
2004-11-25 16:43:32 +00:00
|
|
|
(not (equal file-one file-two))))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
|
|
|
(defcustom flymake-check-file-limit 8192
|
2010-12-02 17:34:35 +00:00
|
|
|
"Maximum number of chars to look at when checking possible master file.
|
|
|
|
Nil means search the entire file."
|
2004-11-25 16:43:32 +00:00
|
|
|
:group 'flymake
|
2010-12-02 17:34:35 +00:00
|
|
|
:type '(choice (const :tag "No limit" nil)
|
|
|
|
(integer :tag "Characters")))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2006-01-10 18:46:07 +00:00
|
|
|
(defun flymake-check-patch-master-file-buffer
|
|
|
|
(master-file-temp-buffer
|
|
|
|
master-file-name patched-master-file-name
|
|
|
|
source-file-name patched-source-file-name
|
|
|
|
include-dirs regexp)
|
2004-11-25 16:43:32 +00:00
|
|
|
"Check if MASTER-FILE-NAME is a master file for SOURCE-FILE-NAME.
|
2004-11-25 16:33:53 +00:00
|
|
|
If yes, patch a copy of MASTER-FILE-NAME to include PATCHED-SOURCE-FILE-NAME
|
|
|
|
instead of SOURCE-FILE-NAME.
|
2010-01-28 19:53:11 +00:00
|
|
|
|
|
|
|
For example, foo.cpp is a master file if it includes foo.h.
|
|
|
|
|
2004-11-25 16:33:53 +00:00
|
|
|
Whether a buffer for MATER-FILE-NAME exists, use it as a source
|
|
|
|
instead of reading master file from disk."
|
2006-01-10 18:46:07 +00:00
|
|
|
(let* ((source-file-nondir (file-name-nondirectory source-file-name))
|
2010-12-02 17:34:35 +00:00
|
|
|
(source-file-extension (file-name-extension source-file-nondir))
|
|
|
|
(source-file-nonext (file-name-sans-extension source-file-nondir))
|
2006-01-10 18:46:07 +00:00
|
|
|
(found nil)
|
2004-11-25 16:43:32 +00:00
|
|
|
(inc-name nil)
|
|
|
|
(search-limit flymake-check-file-limit))
|
2006-01-10 18:46:07 +00:00
|
|
|
(setq regexp
|
|
|
|
(format regexp ; "[ \t]*#[ \t]*include[ \t]*\"\\(.*%s\\)\""
|
2010-12-02 17:34:35 +00:00
|
|
|
;; Hack for tex files, where \include often excludes .tex.
|
|
|
|
;; Maybe this is safe generally.
|
|
|
|
(if (and (> (length source-file-extension) 1)
|
|
|
|
(string-equal source-file-extension "tex"))
|
|
|
|
(format "%s\\(?:\\.%s\\)?"
|
|
|
|
(regexp-quote source-file-nonext)
|
|
|
|
(regexp-quote source-file-extension))
|
|
|
|
(regexp-quote source-file-nondir))))
|
2006-01-10 18:46:07 +00:00
|
|
|
(unwind-protect
|
|
|
|
(with-current-buffer master-file-temp-buffer
|
2010-12-02 17:34:35 +00:00
|
|
|
(if (or (not search-limit)
|
|
|
|
(> search-limit (point-max)))
|
|
|
|
(setq search-limit (point-max)))
|
2006-01-10 18:46:07 +00:00
|
|
|
(flymake-log 3 "checking %s against regexp %s"
|
|
|
|
master-file-name regexp)
|
|
|
|
(goto-char (point-min))
|
|
|
|
(while (and (< (point) search-limit)
|
|
|
|
(re-search-forward regexp search-limit t))
|
|
|
|
(let ((match-beg (match-beginning 1))
|
|
|
|
(match-end (match-end 1)))
|
|
|
|
|
|
|
|
(flymake-log 3 "found possible match for %s" source-file-nondir)
|
|
|
|
(setq inc-name (match-string 1))
|
2010-12-02 17:34:35 +00:00
|
|
|
(and (> (length source-file-extension) 1)
|
|
|
|
(string-equal source-file-extension "tex")
|
|
|
|
(not (string-match (format "\\.%s\\'" source-file-extension)
|
|
|
|
inc-name))
|
|
|
|
(setq inc-name (concat inc-name "." source-file-extension)))
|
2006-01-10 18:46:07 +00:00
|
|
|
(when (eq t (compare-strings
|
|
|
|
source-file-nondir nil nil
|
|
|
|
inc-name (- (length inc-name)
|
|
|
|
(length source-file-nondir)) nil))
|
|
|
|
(flymake-log 3 "inc-name=%s" inc-name)
|
|
|
|
(when (flymake-check-include source-file-name inc-name
|
|
|
|
include-dirs)
|
|
|
|
(setq found t)
|
|
|
|
;; replace-match is not used here as it fails in
|
|
|
|
;; XEmacs with 'last match not a buffer' error as
|
|
|
|
;; check-includes calls replace-in-string
|
|
|
|
(flymake-replace-region
|
|
|
|
match-beg match-end
|
|
|
|
(file-name-nondirectory patched-source-file-name))))
|
|
|
|
(forward-line 1)))
|
|
|
|
(when found
|
|
|
|
(flymake-save-buffer-in-file patched-master-file-name)))
|
|
|
|
;;+(flymake-log 3 "killing buffer %s"
|
|
|
|
;; (buffer-name master-file-temp-buffer))
|
|
|
|
(kill-buffer master-file-temp-buffer))
|
2005-03-24 22:42:42 +00:00
|
|
|
;;+(flymake-log 3 "check-patch master file %s: %s" master-file-name found)
|
2004-11-25 16:43:32 +00:00
|
|
|
(when found
|
|
|
|
(flymake-log 2 "found master file %s" master-file-name))
|
|
|
|
found))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2005-03-25 00:06:07 +00:00
|
|
|
(defun flymake-replace-region (beg end rep)
|
2004-11-25 16:43:32 +00:00
|
|
|
"Replace text in BUFFER in region (BEG END) with REP."
|
|
|
|
(save-excursion
|
2005-03-25 00:06:07 +00:00
|
|
|
(goto-char end)
|
|
|
|
;; Insert before deleting, so as to better preserve markers's positions.
|
|
|
|
(insert rep)
|
|
|
|
(delete-region beg end)))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2004-11-25 16:33:53 +00:00
|
|
|
(defun flymake-read-file-to-temp-buffer (file-name)
|
2004-11-25 16:43:32 +00:00
|
|
|
"Insert contents of FILE-NAME into newly created temp buffer."
|
|
|
|
(let* ((temp-buffer (get-buffer-create (generate-new-buffer-name (concat "flymake:" (file-name-nondirectory file-name))))))
|
2005-03-24 22:55:54 +00:00
|
|
|
(with-current-buffer temp-buffer
|
2004-11-25 16:43:32 +00:00
|
|
|
(insert-file-contents file-name))
|
|
|
|
temp-buffer))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2004-11-25 16:33:53 +00:00
|
|
|
(defun flymake-copy-buffer-to-temp-buffer (buffer)
|
2004-11-25 16:43:32 +00:00
|
|
|
"Copy contents of BUFFER into newly created temp buffer."
|
2005-12-30 17:28:30 +00:00
|
|
|
(with-current-buffer
|
|
|
|
(get-buffer-create (generate-new-buffer-name
|
|
|
|
(concat "flymake:" (buffer-name buffer))))
|
|
|
|
(insert-buffer-substring buffer)
|
|
|
|
(current-buffer)))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2006-01-10 18:46:07 +00:00
|
|
|
(defun flymake-check-include (source-file-name inc-name include-dirs)
|
2004-11-25 16:43:32 +00:00
|
|
|
"Check if SOURCE-FILE-NAME can be found in include path.
|
2006-01-10 18:46:07 +00:00
|
|
|
Return t if it can be found via include path using INC-NAME."
|
|
|
|
(if (file-name-absolute-p inc-name)
|
|
|
|
(flymake-same-files source-file-name inc-name)
|
|
|
|
(while (and include-dirs
|
|
|
|
(not (flymake-same-files
|
|
|
|
source-file-name
|
|
|
|
(concat (file-name-directory source-file-name)
|
|
|
|
"/" (car include-dirs)
|
|
|
|
"/" inc-name))))
|
|
|
|
(setq include-dirs (cdr include-dirs)))
|
|
|
|
include-dirs))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2004-11-25 16:33:53 +00:00
|
|
|
(defun flymake-find-buffer-for-file (file-name)
|
2004-11-25 16:43:32 +00:00
|
|
|
"Check if there exists a buffer visiting FILE-NAME.
|
2004-11-25 16:33:53 +00:00
|
|
|
Return t if so, nil if not."
|
2004-11-25 16:43:32 +00:00
|
|
|
(let ((buffer-name (get-file-buffer file-name)))
|
|
|
|
(if buffer-name
|
|
|
|
(get-buffer buffer-name))))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2006-01-10 18:46:07 +00:00
|
|
|
(defun flymake-create-master-file (source-file-name patched-source-file-name get-incl-dirs-f create-temp-f masks include-regexp)
|
2004-11-25 16:43:32 +00:00
|
|
|
"Save SOURCE-FILE-NAME with a different name.
|
2004-11-25 16:33:53 +00:00
|
|
|
Find master file, patch and save it."
|
2004-11-25 16:43:32 +00:00
|
|
|
(let* ((possible-master-files (flymake-find-possible-master-files source-file-name flymake-master-file-dirs masks))
|
|
|
|
(master-file-count (length possible-master-files))
|
|
|
|
(idx 0)
|
|
|
|
(temp-buffer nil)
|
|
|
|
(master-file-name nil)
|
|
|
|
(patched-master-file-name nil)
|
|
|
|
(found nil))
|
|
|
|
|
|
|
|
(while (and (not found) (< idx master-file-count))
|
|
|
|
(setq master-file-name (nth idx possible-master-files))
|
|
|
|
(setq patched-master-file-name (funcall create-temp-f master-file-name "flymake_master"))
|
|
|
|
(if (flymake-find-buffer-for-file master-file-name)
|
|
|
|
(setq temp-buffer (flymake-copy-buffer-to-temp-buffer (flymake-find-buffer-for-file master-file-name)))
|
|
|
|
(setq temp-buffer (flymake-read-file-to-temp-buffer master-file-name)))
|
|
|
|
(setq found
|
|
|
|
(flymake-check-patch-master-file-buffer
|
|
|
|
temp-buffer
|
|
|
|
master-file-name
|
|
|
|
patched-master-file-name
|
|
|
|
source-file-name
|
|
|
|
patched-source-file-name
|
|
|
|
(funcall get-incl-dirs-f (file-name-directory master-file-name))
|
2006-01-10 18:46:07 +00:00
|
|
|
include-regexp))
|
2004-11-25 16:43:32 +00:00
|
|
|
(setq idx (1+ idx)))
|
|
|
|
(if found
|
|
|
|
(list master-file-name patched-master-file-name)
|
|
|
|
(progn
|
|
|
|
(flymake-log 3 "none of %d master file(s) checked includes %s" master-file-count
|
|
|
|
(file-name-nondirectory source-file-name))
|
|
|
|
nil))))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
(flymake-create-temp-with-folder-structure): Use expand-file-name.
(flymake-delete-temp-directory): Use expand-file-name,
file-name-directory, and directory-file-name.
(flymake-strrchr): Delete.
(flymake-start-syntax-check): Don't pass the redundant buffer argument
to the init-f function.
(flymake-init-find-buildfile-dir, flymake-init-create-temp-buffer-copy)
(flymake-init-create-temp-source-and-master-buffer-copy, flymake-perl-init)
(flymake-save-buffer-in-file, flymake-simple-make-init-impl, flymake-xml-init)
(flymake-simple-make-init, flymake-master-make-init, flymake-master-tex-init)
(flymake-master-make-header-init, flymake-simple-make-java-init)
(flymake-simple-ant-java-init, flymake-simple-tex-init):
Remove corresponding redundant buffer argument.
(flymake-allowed-file-name-masks): Remove last elems that are equal to
the default anyway. Clean up regexps.
2006-01-03 19:59:00 +00:00
|
|
|
(defun flymake-save-buffer-in-file (file-name)
|
2008-05-28 17:35:34 +00:00
|
|
|
(make-directory (file-name-directory file-name) 1)
|
|
|
|
(write-region nil nil file-name nil 566)
|
(flymake-create-temp-with-folder-structure): Use expand-file-name.
(flymake-delete-temp-directory): Use expand-file-name,
file-name-directory, and directory-file-name.
(flymake-strrchr): Delete.
(flymake-start-syntax-check): Don't pass the redundant buffer argument
to the init-f function.
(flymake-init-find-buildfile-dir, flymake-init-create-temp-buffer-copy)
(flymake-init-create-temp-source-and-master-buffer-copy, flymake-perl-init)
(flymake-save-buffer-in-file, flymake-simple-make-init-impl, flymake-xml-init)
(flymake-simple-make-init, flymake-master-make-init, flymake-master-tex-init)
(flymake-master-make-header-init, flymake-simple-make-java-init)
(flymake-simple-ant-java-init, flymake-simple-tex-init):
Remove corresponding redundant buffer argument.
(flymake-allowed-file-name-masks): Remove last elems that are equal to
the default anyway. Clean up regexps.
2006-01-03 19:59:00 +00:00
|
|
|
(flymake-log 3 "saved buffer %s in file %s" (buffer-name) file-name))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2004-11-25 16:33:53 +00:00
|
|
|
(defun flymake-save-string-to-file (file-name data)
|
2004-11-25 16:43:32 +00:00
|
|
|
"Save string DATA to file FILE-NAME."
|
|
|
|
(write-region data nil file-name nil 566))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2004-11-25 16:33:53 +00:00
|
|
|
(defun flymake-read-file-to-string (file-name)
|
2004-11-25 16:43:32 +00:00
|
|
|
"Read contents of file FILE-NAME and return as a string."
|
|
|
|
(with-temp-buffer
|
|
|
|
(insert-file-contents file-name)
|
|
|
|
(buffer-substring (point-min) (point-max))))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2004-11-25 16:33:53 +00:00
|
|
|
(defun flymake-process-filter (process output)
|
2004-11-25 16:43:32 +00:00
|
|
|
"Parse OUTPUT and highlight error lines.
|
2004-11-25 16:33:53 +00:00
|
|
|
It's flymake process filter."
|
2006-01-03 18:44:42 +00:00
|
|
|
(let ((source-buffer (process-buffer process)))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2006-01-03 18:44:42 +00:00
|
|
|
(flymake-log 3 "received %d byte(s) of output from process %d"
|
|
|
|
(length output) (process-id process))
|
2008-06-03 08:12:02 +00:00
|
|
|
(when (buffer-live-p source-buffer)
|
2005-12-30 17:28:30 +00:00
|
|
|
(with-current-buffer source-buffer
|
|
|
|
(flymake-parse-output-and-residual output)))))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2011-04-22 18:44:26 +00:00
|
|
|
(defun flymake-process-sentinel (process _event)
|
2004-11-25 16:43:32 +00:00
|
|
|
"Sentinel for syntax check buffers."
|
2006-01-05 18:51:00 +00:00
|
|
|
(when (memq (process-status process) '(signal exit))
|
|
|
|
(let* ((exit-status (process-exit-status process))
|
|
|
|
(command (process-command process))
|
|
|
|
(source-buffer (process-buffer process))
|
|
|
|
(cleanup-f (flymake-get-cleanup-function (buffer-file-name source-buffer))))
|
|
|
|
|
|
|
|
(flymake-log 2 "process %d exited with code %d"
|
|
|
|
(process-id process) exit-status)
|
|
|
|
(condition-case err
|
|
|
|
(progn
|
|
|
|
(flymake-log 3 "cleaning up using %s" cleanup-f)
|
|
|
|
(when (buffer-live-p source-buffer)
|
|
|
|
(with-current-buffer source-buffer
|
|
|
|
(funcall cleanup-f)))
|
|
|
|
|
|
|
|
(delete-process process)
|
|
|
|
(setq flymake-processes (delq process flymake-processes))
|
|
|
|
|
|
|
|
(when (buffer-live-p source-buffer)
|
|
|
|
(with-current-buffer source-buffer
|
|
|
|
|
|
|
|
(flymake-parse-residual)
|
|
|
|
(flymake-post-syntax-check exit-status command)
|
|
|
|
(setq flymake-is-running nil))))
|
|
|
|
(error
|
|
|
|
(let ((err-str (format "Error in process sentinel for buffer %s: %s"
|
|
|
|
source-buffer (error-message-string err))))
|
|
|
|
(flymake-log 0 err-str)
|
|
|
|
(with-current-buffer source-buffer
|
|
|
|
(setq flymake-is-running nil))))))))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2005-12-30 17:28:30 +00:00
|
|
|
(defun flymake-post-syntax-check (exit-status command)
|
|
|
|
(setq flymake-err-info flymake-new-err-info)
|
|
|
|
(setq flymake-new-err-info nil)
|
|
|
|
(setq flymake-err-info
|
|
|
|
(flymake-fix-line-numbers
|
|
|
|
flymake-err-info 1 (flymake-count-lines)))
|
|
|
|
(flymake-delete-own-overlays)
|
|
|
|
(flymake-highlight-err-lines flymake-err-info)
|
2005-04-30 20:13:39 +00:00
|
|
|
(let (err-count warn-count)
|
2005-12-30 17:28:30 +00:00
|
|
|
(setq err-count (flymake-get-err-count flymake-err-info "e"))
|
|
|
|
(setq warn-count (flymake-get-err-count flymake-err-info "w"))
|
|
|
|
(flymake-log 2 "%s: %d error(s), %d warning(s) in %.2f second(s)"
|
|
|
|
(buffer-name) err-count warn-count
|
2005-04-30 20:13:39 +00:00
|
|
|
(- (flymake-float-time) flymake-check-start-time))
|
2005-12-30 17:28:30 +00:00
|
|
|
(setq flymake-check-start-time nil)
|
2005-04-30 20:13:39 +00:00
|
|
|
|
2004-11-25 16:43:32 +00:00
|
|
|
(if (and (equal 0 err-count) (equal 0 warn-count))
|
|
|
|
(if (equal 0 exit-status)
|
2005-12-30 17:28:30 +00:00
|
|
|
(flymake-report-status "" "") ; PASSED
|
|
|
|
(if (not flymake-check-was-interrupted)
|
|
|
|
(flymake-report-fatal-status "CFGERR"
|
2010-01-14 18:49:53 +00:00
|
|
|
(format "Configuration error has occurred while running %s" command))
|
2005-12-30 17:28:30 +00:00
|
|
|
(flymake-report-status nil ""))) ; "STOPPED"
|
|
|
|
(flymake-report-status (format "%d/%d" err-count warn-count) ""))))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2005-12-30 17:28:30 +00:00
|
|
|
(defun flymake-parse-output-and-residual (output)
|
2004-11-25 16:43:32 +00:00
|
|
|
"Split OUTPUT into lines, merge in residual if necessary."
|
2005-12-30 17:28:30 +00:00
|
|
|
(let* ((buffer-residual flymake-output-residual)
|
|
|
|
(total-output (if buffer-residual (concat buffer-residual output) output))
|
|
|
|
(lines-and-residual (flymake-split-output total-output))
|
|
|
|
(lines (nth 0 lines-and-residual))
|
|
|
|
(new-residual (nth 1 lines-and-residual)))
|
|
|
|
(setq flymake-output-residual new-residual)
|
|
|
|
(setq flymake-new-err-info
|
|
|
|
(flymake-parse-err-lines
|
|
|
|
flymake-new-err-info lines))))
|
|
|
|
|
|
|
|
(defun flymake-parse-residual ()
|
2004-11-25 16:43:32 +00:00
|
|
|
"Parse residual if it's non empty."
|
2005-12-30 17:28:30 +00:00
|
|
|
(when flymake-output-residual
|
|
|
|
(setq flymake-new-err-info
|
|
|
|
(flymake-parse-err-lines
|
|
|
|
flymake-new-err-info
|
|
|
|
(list flymake-output-residual)))
|
|
|
|
(setq flymake-output-residual nil)))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2004-11-25 16:33:53 +00:00
|
|
|
(defun flymake-er-make-er (line-no line-err-info-list)
|
2004-11-25 16:43:32 +00:00
|
|
|
(list line-no line-err-info-list))
|
2004-11-25 16:33:53 +00:00
|
|
|
|
|
|
|
(defun flymake-er-get-line (err-info)
|
2004-11-25 16:43:32 +00:00
|
|
|
(nth 0 err-info))
|
2004-11-25 16:33:53 +00:00
|
|
|
|
|
|
|
(defun flymake-er-get-line-err-info-list (err-info)
|
2004-11-25 16:43:32 +00:00
|
|
|
(nth 1 err-info))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
More CL cleanups and reduction of use of cl.el.
* woman.el, winner.el, vc/vc-rcs.el, vc/vc-hooks.el, vc/vc-hg.el:
* vc/vc-git.el, vc/vc-dir.el, vc/vc-bzr.el, vc/vc-annotate.el:
* textmodes/tex-mode.el, textmodes/sgml-mode.el, tar-mode.el:
* strokes.el, ses.el, server.el, progmodes/js.el, progmodes/gdb-mi.el:
* progmodes/flymake.el, progmodes/ebrowse.el, progmodes/compile.el:
* play/tetris.el, play/snake.el, play/pong.el, play/landmark.el:
* play/hanoi.el, play/decipher.el, play/5x5.el, nxml/nxml-mode.el:
* net/secrets.el, net/quickurl.el, midnight.el, mail/footnote.el:
* image-dired.el, ibuffer.el, ibuf-macs.el, ibuf-ext.el, hexl.el:
* eshell/eshell.el, eshell/esh-io.el, eshell/esh-ext.el:
* eshell/esh-cmd.el, eshell/em-ls.el, eshell/em-hist.el:
* eshell/em-cmpl.el, eshell/em-banner.el:
* url/url.el, url/url-queue.el, url/url-parse.el, url/url-http.el:
* url/url-future.el, url/url-dav.el, url/url-cookie.el:
* calendar/parse-time.el, test/eshell.el: Use cl-lib.
* wid-browse.el, wdired.el, vc/vc.el, vc/vc-mtn.el, vc/vc-cvs.el:
* vc/vc-arch.el, tree-widget.el, textmodes/texinfo.el:
* textmodes/refill.el, textmodes/css-mode.el, term/tvi970.el:
* term/ns-win.el, term.el, shell.el, ps-samp.el:
* progmodes/perl-mode.el, progmodes/pascal.el, progmodes/gud.el:
* progmodes/glasses.el, progmodes/etags.el, progmodes/cwarn.el:
* play/gamegrid.el, play/bubbles.el, novice.el, notifications.el:
* net/zeroconf.el, net/xesam.el, net/snmp-mode.el, net/mairix.el:
* net/ldap.el, net/eudc.el, net/browse-url.el, man.el:
* mail/mailheader.el, mail/feedmail.el:
* url/url-util.el, url/url-privacy.el, url/url-nfs.el, url/url-misc.el:
* url/url-methods.el, url/url-gw.el, url/url-file.el, url/url-expand.el:
Dont use CL.
* ibuf-ext.el (ibuffer-mark-old-buffers): Use float-time.
* eshell/esh-opt.el (eshell-eval-using-options): Quote code with
`lambda' rather than with `quote'.
(eshell-do-opt): Adjust accordingly.
(eshell-process-option): Simplify.
* eshell/esh-var.el:
* eshell/em-script.el: Require `esh-opt' for eshell-eval-using-options.
* emacs-pcase.el (pcase--dontcare-upats, pcase--let*)
(pcase--expand, pcase--u1): Rename pcase's internal `dontcare' pattern
to `pcase--dontcare'.
* emacs-cl.el (labels): Mark obsolete.
(cl--letf, letf): Move to cl-lib.
(cl--letf*, letf*): Remove.
* emacs-cl-lib.el (cl-nth-value): Use defalias.
* emacs-cl-macs.el (cl-dolist, cl-dotimes): Add indent rule.
(cl-progv): Rewrite.
(cl--letf, cl-letf): Move from cl.el.
(cl-letf*): New macro.
* emacs-cl-extra.el (cl--progv-before, cl--progv-after): Remove.
2012-07-11 23:13:41 +00:00
|
|
|
(cl-defstruct (flymake-ler
|
2006-01-10 18:46:07 +00:00
|
|
|
(:constructor nil)
|
|
|
|
(:constructor flymake-ler-make-ler (file line type text &optional full-file)))
|
|
|
|
file line type text full-file)
|
2004-11-25 16:33:53 +00:00
|
|
|
|
|
|
|
(defun flymake-ler-set-file (line-err-info file)
|
2004-11-25 16:43:32 +00:00
|
|
|
(flymake-ler-make-ler file
|
2006-01-10 18:46:07 +00:00
|
|
|
(flymake-ler-line line-err-info)
|
|
|
|
(flymake-ler-type line-err-info)
|
|
|
|
(flymake-ler-text line-err-info)
|
|
|
|
(flymake-ler-full-file line-err-info)))
|
2004-11-25 16:33:53 +00:00
|
|
|
|
|
|
|
(defun flymake-ler-set-full-file (line-err-info full-file)
|
2006-01-10 18:46:07 +00:00
|
|
|
(flymake-ler-make-ler (flymake-ler-file line-err-info)
|
|
|
|
(flymake-ler-line line-err-info)
|
|
|
|
(flymake-ler-type line-err-info)
|
|
|
|
(flymake-ler-text line-err-info)
|
2004-11-25 16:33:53 +00:00
|
|
|
full-file))
|
|
|
|
|
|
|
|
(defun flymake-ler-set-line (line-err-info line)
|
2006-01-10 18:46:07 +00:00
|
|
|
(flymake-ler-make-ler (flymake-ler-file line-err-info)
|
2004-05-29 12:55:24 +00:00
|
|
|
line
|
2006-01-10 18:46:07 +00:00
|
|
|
(flymake-ler-type line-err-info)
|
|
|
|
(flymake-ler-text line-err-info)
|
|
|
|
(flymake-ler-full-file line-err-info)))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2004-11-25 16:33:53 +00:00
|
|
|
(defun flymake-get-line-err-count (line-err-info-list type)
|
2004-11-25 16:43:32 +00:00
|
|
|
"Return number of errors of specified TYPE.
|
2005-07-01 14:13:12 +00:00
|
|
|
Value of TYPE is either \"e\" or \"w\"."
|
2004-11-25 16:43:32 +00:00
|
|
|
(let* ((idx 0)
|
|
|
|
(count (length line-err-info-list))
|
|
|
|
(err-count 0))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2004-11-25 16:43:32 +00:00
|
|
|
(while (< idx count)
|
2006-01-10 18:46:07 +00:00
|
|
|
(when (equal type (flymake-ler-type (nth idx line-err-info-list)))
|
2004-11-25 16:43:32 +00:00
|
|
|
(setq err-count (1+ err-count)))
|
|
|
|
(setq idx (1+ idx)))
|
|
|
|
err-count))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2004-11-25 16:33:53 +00:00
|
|
|
(defun flymake-get-err-count (err-info-list type)
|
2004-11-25 16:43:32 +00:00
|
|
|
"Return number of errors of specified TYPE for ERR-INFO-LIST."
|
|
|
|
(let* ((idx 0)
|
|
|
|
(count (length err-info-list))
|
|
|
|
(err-count 0))
|
|
|
|
(while (< idx count)
|
|
|
|
(setq err-count (+ err-count (flymake-get-line-err-count (nth 1 (nth idx err-info-list)) type)))
|
|
|
|
(setq idx (1+ idx)))
|
|
|
|
err-count))
|
2004-11-25 16:33:53 +00:00
|
|
|
|
|
|
|
(defun flymake-fix-line-numbers (err-info-list min-line max-line)
|
2004-11-25 16:43:32 +00:00
|
|
|
"Replace line numbers with fixed value.
|
2004-11-25 16:33:53 +00:00
|
|
|
If line-numbers is less than MIN-LINE, set line numbers to MIN-LINE.
|
|
|
|
If line numbers is greater than MAX-LINE, set line numbers to MAX-LINE.
|
2004-11-26 23:56:39 +00:00
|
|
|
The reason for this fix is because some compilers might report
|
2004-11-25 16:33:53 +00:00
|
|
|
line number outside the file being compiled."
|
2004-11-25 16:43:32 +00:00
|
|
|
(let* ((count (length err-info-list))
|
|
|
|
(err-info nil)
|
|
|
|
(line 0))
|
|
|
|
(while (> count 0)
|
|
|
|
(setq err-info (nth (1- count) err-info-list))
|
|
|
|
(setq line (flymake-er-get-line err-info))
|
|
|
|
(when (or (< line min-line) (> line max-line))
|
|
|
|
(setq line (if (< line min-line) min-line max-line))
|
|
|
|
(setq err-info-list (flymake-set-at err-info-list (1- count)
|
|
|
|
(flymake-er-make-er line
|
|
|
|
(flymake-er-get-line-err-info-list err-info)))))
|
|
|
|
(setq count (1- count))))
|
|
|
|
err-info-list)
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2005-12-30 17:28:30 +00:00
|
|
|
(defun flymake-highlight-err-lines (err-info-list)
|
2004-11-25 16:43:32 +00:00
|
|
|
"Highlight error lines in BUFFER using info from ERR-INFO-LIST."
|
2005-12-30 17:28:30 +00:00
|
|
|
(save-excursion
|
|
|
|
(dolist (err err-info-list)
|
|
|
|
(flymake-highlight-line (car err) (nth 1 err)))))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2004-11-25 16:33:53 +00:00
|
|
|
(defun flymake-overlay-p (ov)
|
2004-11-25 16:43:32 +00:00
|
|
|
"Determine whether overlay OV was created by flymake."
|
|
|
|
(and (overlayp ov) (overlay-get ov 'flymake-overlay)))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2012-07-14 12:02:22 +00:00
|
|
|
(defcustom flymake-error-bitmap '(exclamation-mark error)
|
|
|
|
"Bitmap used in the fringe for indicating errors.
|
|
|
|
The value may also be a list of two elements where the second
|
|
|
|
element specifies the face for the bitmap."
|
|
|
|
:group 'flymake
|
2012-10-06 20:30:26 +00:00
|
|
|
:version "24.3"
|
2012-07-14 12:02:22 +00:00
|
|
|
:type 'symbol)
|
|
|
|
|
|
|
|
(defcustom flymake-warning-bitmap 'question-mark
|
|
|
|
"Bitmap used in the fringe for indicating warnings.
|
|
|
|
The value may also be a list of two elements where the second
|
|
|
|
element specifies the face for the bitmap."
|
|
|
|
:group 'flymake
|
2012-10-06 20:30:26 +00:00
|
|
|
:version "24.3"
|
2012-07-14 12:02:22 +00:00
|
|
|
:type 'symbol)
|
|
|
|
|
|
|
|
(defcustom flymake-fringe-indicator-position 'left-fringe
|
|
|
|
"The position to put flymake fringe indicator.
|
|
|
|
The value can be nil, left-fringe or right-fringe.
|
|
|
|
Fringe indicators are disabled if nil."
|
|
|
|
:group 'flymake
|
2012-10-06 20:30:26 +00:00
|
|
|
:version "24.3"
|
2012-07-14 12:02:22 +00:00
|
|
|
:type '(choice (const left-fringe)
|
|
|
|
(const right-fringe)
|
|
|
|
(const :tag "No fringe indicators" nil)))
|
|
|
|
|
|
|
|
(defun flymake-make-overlay (beg end tooltip-text face bitmap mouse-face)
|
2004-11-25 16:43:32 +00:00
|
|
|
"Allocate a flymake overlay in range BEG and END."
|
|
|
|
(when (not (flymake-region-has-flymake-overlays beg end))
|
2012-07-14 12:02:22 +00:00
|
|
|
(let ((ov (make-overlay beg end nil t t))
|
|
|
|
(fringe (and flymake-fringe-indicator-position
|
|
|
|
(propertize "!" 'display
|
|
|
|
(cons flymake-fringe-indicator-position
|
|
|
|
(if (listp bitmap)
|
|
|
|
bitmap
|
|
|
|
(list bitmap)))))))
|
2004-11-25 16:43:32 +00:00
|
|
|
(overlay-put ov 'face face)
|
|
|
|
(overlay-put ov 'mouse-face mouse-face)
|
|
|
|
(overlay-put ov 'help-echo tooltip-text)
|
|
|
|
(overlay-put ov 'flymake-overlay t)
|
|
|
|
(overlay-put ov 'priority 100)
|
2012-07-14 12:02:22 +00:00
|
|
|
(overlay-put ov 'evaporate t)
|
|
|
|
(overlay-put ov 'before-string fringe)
|
2005-03-24 22:42:42 +00:00
|
|
|
;;+(flymake-log 3 "created overlay %s" ov)
|
2004-11-25 16:43:32 +00:00
|
|
|
ov)
|
|
|
|
(flymake-log 3 "created an overlay at (%d-%d)" beg end)))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2005-12-30 17:28:30 +00:00
|
|
|
(defun flymake-delete-own-overlays ()
|
2004-11-25 16:43:32 +00:00
|
|
|
"Delete all flymake overlays in BUFFER."
|
2005-12-30 17:28:30 +00:00
|
|
|
(dolist (ol (overlays-in (point-min) (point-max)))
|
|
|
|
(when (flymake-overlay-p ol)
|
|
|
|
(delete-overlay ol)
|
|
|
|
;;+(flymake-log 3 "deleted overlay %s" ol)
|
|
|
|
)))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2004-11-25 16:33:53 +00:00
|
|
|
(defun flymake-region-has-flymake-overlays (beg end)
|
2004-11-25 16:43:32 +00:00
|
|
|
"Check if region specified by BEG and END has overlay.
|
2004-11-25 16:33:53 +00:00
|
|
|
Return t if it has at least one flymake overlay, nil if no overlay."
|
2004-11-25 16:43:32 +00:00
|
|
|
(let ((ov (overlays-in beg end))
|
|
|
|
(has-flymake-overlays nil))
|
|
|
|
(while (consp ov)
|
|
|
|
(when (flymake-overlay-p (car ov))
|
|
|
|
(setq has-flymake-overlays t))
|
2005-03-24 22:55:54 +00:00
|
|
|
(setq ov (cdr ov)))
|
|
|
|
has-flymake-overlays))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2005-06-14 23:20:37 +00:00
|
|
|
(defface flymake-errline
|
Face cleanups. Remove some uses of old-style face spec and :bold/:italic.
* faces.el (set-face-attribute): Doc fix.
(modify-face): Don't use :bold and :italic.
(error, warning, success): Tweak definitions.
* cus-edit.el (custom-modified, custom-invalid, custom-rogue)
(custom-modified, custom-set, custom-changed, custom-themed)
(custom-saved, custom-button, custom-button-mouse)
(custom-button-pressed, custom-state, custom-comment-tag)
(custom-variable-tag, custom-group-tag-1, custom-group-tag)
(custom-group-subtitle): Use new-style face specs.
(custom-invalid-face, custom-rogue-face, custom-modified-face)
(custom-set-face, custom-changed-face, custom-saved-face)
(custom-button-face, custom-button-pressed-face)
(custom-documentation-face, custom-state-face)
(custom-comment-face, custom-comment-tag-face)
(custom-variable-tag-face, custom-variable-button-face)
(custom-face-tag-face, custom-group-tag-face-1)
(custom-group-tag-face): Remove obsolete face alias.
* epa.el (epa-validity-high, epa-validity-medium)
(epa-validity-low, epa-mark, epa-field-name, epa-string)
(epa-field-name, epa-field-body):
* font-lock.el (font-lock-comment-face, font-lock-string-face)
(font-lock-keyword-face, font-lock-builtin-face)
(font-lock-function-name-face, font-lock-variable-name-face)
(font-lock-type-face, font-lock-constant-face):
* ido.el (ido-first-match, ido-only-match, ido-subdir)
(ido-virtual, ido-indicator, ido-incomplete-regexp):
* speedbar.el (speedbar-button-face, speedbar-file-face)
(speedbar-directory-face, speedbar-tag-face)
(speedbar-selected-face, speedbar-highlight-face)
(speedbar-separator-face):
* whitespace.el (whitespace-newline, whitespace-space)
(whitespace-hspace, whitespace-tab, whitespace-trailing)
(whitespace-line, whitespace-space-before-tab)
(whitespace-space-after-tab, whitespace-indentation)
(whitespace-empty):
* emulation/cua-base.el (cua-global-mark):
* eshell/em-prompt.el (eshell-prompt):
* net/newst-plainview.el (newsticker-new-item-face)
(newsticker-old-item-face, newsticker-immortal-item-face)
(newsticker-obsolete-item-face, newsticker-date-face)
(newsticker-statistics-face, newsticker-default-face):
* net/newst-reader.el (newsticker-feed-face)
(newsticker-extra-face, newsticker-enclosure-face):
* net/newst-treeview.el (newsticker-treeview-face)
(newsticker-treeview-new-face, newsticker-treeview-old-face)
(newsticker-treeview-immortal-face)
(newsticker-treeview-obsolete-face)
(newsticker-treeview-selection-face):
* net/rcirc.el (rcirc-my-nick, rcirc-other-nick)
(rcirc-bright-nick, rcirc-server, rcirc-timestamp)
(rcirc-nick-in-message, rcirc-nick-in-message-full-line)
(rcirc-prompt, rcirc-track-keyword, rcirc-url, rcirc-keyword):
* nxml/nxml-outln.el (nxml-heading, nxml-outline-indicator)
(nxml-outline-active-indicator, nxml-outline-ellipsis):
* play/mpuz.el (mpuz-unsolved, mpuz-solved, mpuz-trivial)
(mpuz-text):
* progmodes/vera-mode.el (vera-font-lock-number)
(vera-font-lock-function, vera-font-lock-interface):
* textmodes/table.el (table-cell): Use new-style face specs, and
don't use the old :bold and :italic attributes.
* erc-button.el (erc-button):
* erc-goodies.el (erc-bold-face, erc-inverse-face)
(erc-underline-face, fg:erc-color-*):
* erc-match.el (erc-current-nick-face, erc-dangerous-host-face)
(erc-pal-face, erc-fool-face, erc-keyword-face):
* erc-stamp.el (erc-timestamp-face): Likewise.
* erc.el (erc-direct-msg-face, erc-header-line, erc-input-face)
(erc-command-indicator-face, erc-notice-face, erc-action-face)
(erc-error-face, erc-my-nick-face, erc-nick-default-face)
(erc-nick-msg-face): Use new-style face specs, and avoid :bold.
* progmodes/ebrowse.el (ebrowse-tree-mark, ebrowse-root-class)
(ebrowse-member-attribute, ebrowse-default, ebrowse-file-name)
(ebrowse-member-class, ebrowse-progress): Likewise.
(ebrowse-tree-mark-face, ebrowse-root-class-face)
(ebrowse-file-name-face, ebrowse-default-face)
(ebrowse-member-attribute-face, ebrowse-member-class-face)
(ebrowse-progress-face): Remove obsolete faces.
* progmodes/flymake.el (flymake-errline, flymake-warnline):
Inherit from error and warning faces respectively.
* textmodes/flyspell.el (flyspell-incorrect, flyspell-duplicate):
Likewise.
(flyspell-incorrect-face, flyspell-duplicate-face): Remove
obsolete aliases.
* display.texi (Face Attributes): Font family does not accept
wildcards. De-document obsolete :bold and :italic attributes.
(Defining Faces): Use new-style face spec format.
2012-06-08 16:39:49 +00:00
|
|
|
'((t :inherit error))
|
2004-11-25 16:43:32 +00:00
|
|
|
"Face used for marking error lines."
|
|
|
|
:group 'flymake)
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2005-06-14 23:20:37 +00:00
|
|
|
(defface flymake-warnline
|
Face cleanups. Remove some uses of old-style face spec and :bold/:italic.
* faces.el (set-face-attribute): Doc fix.
(modify-face): Don't use :bold and :italic.
(error, warning, success): Tweak definitions.
* cus-edit.el (custom-modified, custom-invalid, custom-rogue)
(custom-modified, custom-set, custom-changed, custom-themed)
(custom-saved, custom-button, custom-button-mouse)
(custom-button-pressed, custom-state, custom-comment-tag)
(custom-variable-tag, custom-group-tag-1, custom-group-tag)
(custom-group-subtitle): Use new-style face specs.
(custom-invalid-face, custom-rogue-face, custom-modified-face)
(custom-set-face, custom-changed-face, custom-saved-face)
(custom-button-face, custom-button-pressed-face)
(custom-documentation-face, custom-state-face)
(custom-comment-face, custom-comment-tag-face)
(custom-variable-tag-face, custom-variable-button-face)
(custom-face-tag-face, custom-group-tag-face-1)
(custom-group-tag-face): Remove obsolete face alias.
* epa.el (epa-validity-high, epa-validity-medium)
(epa-validity-low, epa-mark, epa-field-name, epa-string)
(epa-field-name, epa-field-body):
* font-lock.el (font-lock-comment-face, font-lock-string-face)
(font-lock-keyword-face, font-lock-builtin-face)
(font-lock-function-name-face, font-lock-variable-name-face)
(font-lock-type-face, font-lock-constant-face):
* ido.el (ido-first-match, ido-only-match, ido-subdir)
(ido-virtual, ido-indicator, ido-incomplete-regexp):
* speedbar.el (speedbar-button-face, speedbar-file-face)
(speedbar-directory-face, speedbar-tag-face)
(speedbar-selected-face, speedbar-highlight-face)
(speedbar-separator-face):
* whitespace.el (whitespace-newline, whitespace-space)
(whitespace-hspace, whitespace-tab, whitespace-trailing)
(whitespace-line, whitespace-space-before-tab)
(whitespace-space-after-tab, whitespace-indentation)
(whitespace-empty):
* emulation/cua-base.el (cua-global-mark):
* eshell/em-prompt.el (eshell-prompt):
* net/newst-plainview.el (newsticker-new-item-face)
(newsticker-old-item-face, newsticker-immortal-item-face)
(newsticker-obsolete-item-face, newsticker-date-face)
(newsticker-statistics-face, newsticker-default-face):
* net/newst-reader.el (newsticker-feed-face)
(newsticker-extra-face, newsticker-enclosure-face):
* net/newst-treeview.el (newsticker-treeview-face)
(newsticker-treeview-new-face, newsticker-treeview-old-face)
(newsticker-treeview-immortal-face)
(newsticker-treeview-obsolete-face)
(newsticker-treeview-selection-face):
* net/rcirc.el (rcirc-my-nick, rcirc-other-nick)
(rcirc-bright-nick, rcirc-server, rcirc-timestamp)
(rcirc-nick-in-message, rcirc-nick-in-message-full-line)
(rcirc-prompt, rcirc-track-keyword, rcirc-url, rcirc-keyword):
* nxml/nxml-outln.el (nxml-heading, nxml-outline-indicator)
(nxml-outline-active-indicator, nxml-outline-ellipsis):
* play/mpuz.el (mpuz-unsolved, mpuz-solved, mpuz-trivial)
(mpuz-text):
* progmodes/vera-mode.el (vera-font-lock-number)
(vera-font-lock-function, vera-font-lock-interface):
* textmodes/table.el (table-cell): Use new-style face specs, and
don't use the old :bold and :italic attributes.
* erc-button.el (erc-button):
* erc-goodies.el (erc-bold-face, erc-inverse-face)
(erc-underline-face, fg:erc-color-*):
* erc-match.el (erc-current-nick-face, erc-dangerous-host-face)
(erc-pal-face, erc-fool-face, erc-keyword-face):
* erc-stamp.el (erc-timestamp-face): Likewise.
* erc.el (erc-direct-msg-face, erc-header-line, erc-input-face)
(erc-command-indicator-face, erc-notice-face, erc-action-face)
(erc-error-face, erc-my-nick-face, erc-nick-default-face)
(erc-nick-msg-face): Use new-style face specs, and avoid :bold.
* progmodes/ebrowse.el (ebrowse-tree-mark, ebrowse-root-class)
(ebrowse-member-attribute, ebrowse-default, ebrowse-file-name)
(ebrowse-member-class, ebrowse-progress): Likewise.
(ebrowse-tree-mark-face, ebrowse-root-class-face)
(ebrowse-file-name-face, ebrowse-default-face)
(ebrowse-member-attribute-face, ebrowse-member-class-face)
(ebrowse-progress-face): Remove obsolete faces.
* progmodes/flymake.el (flymake-errline, flymake-warnline):
Inherit from error and warning faces respectively.
* textmodes/flyspell.el (flyspell-incorrect, flyspell-duplicate):
Likewise.
(flyspell-incorrect-face, flyspell-duplicate-face): Remove
obsolete aliases.
* display.texi (Face Attributes): Font family does not accept
wildcards. De-document obsolete :bold and :italic attributes.
(Defining Faces): Use new-style face spec format.
2012-06-08 16:39:49 +00:00
|
|
|
'((t :inherit warning))
|
2004-11-25 16:43:32 +00:00
|
|
|
"Face used for marking warning lines."
|
|
|
|
:group 'flymake)
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2004-11-25 16:33:53 +00:00
|
|
|
(defun flymake-highlight-line (line-no line-err-info-list)
|
2004-11-25 16:43:32 +00:00
|
|
|
"Highlight line LINE-NO in current buffer.
|
2005-07-01 14:13:12 +00:00
|
|
|
Perhaps use text from LINE-ERR-INFO-LIST to enhance highlighting."
|
2009-09-01 03:18:44 +00:00
|
|
|
(goto-char (point-min))
|
|
|
|
(forward-line (1- line-no))
|
Replace unneeded compatibility definitions with point-at-bol, point-at-eol.
* lisp/progmodes/verilog-mode.el (verilog-get-beg-of-line)
(verilog-get-end-of-line): Remove.
(verilog-within-string, verilog-re-search-forward-substr)
(verilog-re-search-backward-substr, verilog-set-auto-endcomments)
(verilog-surelint-off, verilog-getopt-file, verilog-highlight-region):
Use point-at-bol, point-at-eol.
* lisp/progmodes/pascal.el (pascal-get-beg-of-line, pascal-get-end-of-line):
Remove.
(pascal-declaration-end, pascal-declaration-beg, pascal-within-string)
(electric-pascal-terminate-line, pascal-set-auto-comments)
(pascal-indent-paramlist, pascal-indent-declaration)
(pascal-get-lineup-indent, pascal-func-completion)
(pascal-get-completion-decl, pascal-var-completion, pascal-completion):
Use point-at-bol, point-at-eol.
* lisp/progmodes/flymake.el (flymake-line-beginning-position)
(flymake-line-end-position): Remove.
(flymake-highlight-line): Use point-at-bol, point-at-eol.
* lisp/eshell/esh-util.el (line-end-position, line-beginning-position):
Remove compat definitions.
* net/tramp/tramp-compat.el: Comment.
2010-11-07 01:50:52 +00:00
|
|
|
(let* ((line-beg (point-at-bol))
|
2010-11-07 02:02:54 +00:00
|
|
|
(line-end (point-at-eol))
|
2004-11-25 16:43:32 +00:00
|
|
|
(beg line-beg)
|
|
|
|
(end line-end)
|
2006-01-10 18:46:07 +00:00
|
|
|
(tooltip-text (flymake-ler-text (nth 0 line-err-info-list)))
|
2012-07-14 12:02:22 +00:00
|
|
|
(face nil)
|
|
|
|
(bitmap nil))
|
2004-11-25 16:43:32 +00:00
|
|
|
|
|
|
|
(goto-char line-beg)
|
|
|
|
(while (looking-at "[ \t]")
|
|
|
|
(forward-char))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2004-11-25 16:43:32 +00:00
|
|
|
(setq beg (point))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2004-11-25 16:43:32 +00:00
|
|
|
(goto-char line-end)
|
|
|
|
(while (and (looking-at "[ \t\r\n]") (> (point) 1))
|
|
|
|
(backward-char))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2004-11-25 16:43:32 +00:00
|
|
|
(setq end (1+ (point)))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2004-11-25 16:43:32 +00:00
|
|
|
(when (<= end beg)
|
|
|
|
(setq beg line-beg)
|
|
|
|
(setq end line-end))
|
2004-11-25 16:33:53 +00:00
|
|
|
|
2004-11-25 16:43:32 +00:00
|
|
|
(when (= end beg)
|
|
|
|
(goto-char end)
|
|
|
|
(forward-line)
|
|
|
|
(setq end (point)))
|
2004-11-25 16:33:53 +00:00
|
|
|
|
2004-11-25 16:43:32 +00:00
|
|
|
(if (> (flymake-get-line-err-count line-err-info-list "e") 0)
|
2012-07-14 12:02:22 +00:00
|
|
|
(setq face 'flymake-errline
|
|
|
|
bitmap flymake-error-bitmap)
|
|
|
|
(setq face 'flymake-warnline
|
|
|
|
bitmap flymake-warning-bitmap))
|
2004-11-25 16:33:53 +00:00
|
|
|
|
2012-07-14 12:02:22 +00:00
|
|
|
(flymake-make-overlay beg end tooltip-text face bitmap nil)))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2005-12-30 17:28:30 +00:00
|
|
|
(defun flymake-parse-err-lines (err-info-list lines)
|
2004-11-25 16:43:32 +00:00
|
|
|
"Parse err LINES, store info in ERR-INFO-LIST."
|
|
|
|
(let* ((count (length lines))
|
|
|
|
(idx 0)
|
|
|
|
(line-err-info nil)
|
|
|
|
(real-file-name nil)
|
2005-12-30 17:28:30 +00:00
|
|
|
(source-file-name buffer-file-name)
|
2004-11-25 16:43:32 +00:00
|
|
|
(get-real-file-name-f (flymake-get-real-file-name-function source-file-name)))
|
|
|
|
|
|
|
|
(while (< idx count)
|
|
|
|
(setq line-err-info (flymake-parse-line (nth idx lines)))
|
|
|
|
(when line-err-info
|
2006-01-05 18:51:00 +00:00
|
|
|
(setq real-file-name (funcall get-real-file-name-f
|
2006-01-10 18:46:07 +00:00
|
|
|
(flymake-ler-file line-err-info)))
|
2004-11-25 16:43:32 +00:00
|
|
|
(setq line-err-info (flymake-ler-set-full-file line-err-info real-file-name))
|
|
|
|
|
2008-09-07 19:05:05 +00:00
|
|
|
(when (flymake-same-files real-file-name source-file-name)
|
|
|
|
(setq line-err-info (flymake-ler-set-file line-err-info nil))
|
|
|
|
(setq err-info-list (flymake-add-err-info err-info-list line-err-info))))
|
2004-11-25 16:43:32 +00:00
|
|
|
(flymake-log 3 "parsed '%s', %s line-err-info" (nth idx lines) (if line-err-info "got" "no"))
|
|
|
|
(setq idx (1+ idx)))
|
|
|
|
err-info-list))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2004-11-25 16:33:53 +00:00
|
|
|
(defun flymake-split-output (output)
|
2004-11-25 16:43:32 +00:00
|
|
|
"Split OUTPUT into lines.
|
2005-03-24 22:42:42 +00:00
|
|
|
Return last one as residual if it does not end with newline char.
|
|
|
|
Returns ((LINES) RESIDUAL)."
|
2004-11-25 16:43:32 +00:00
|
|
|
(when (and output (> (length output) 0))
|
|
|
|
(let* ((lines (flymake-split-string output "[\n\r]+"))
|
|
|
|
(complete (equal "\n" (char-to-string (aref output (1- (length output))))))
|
|
|
|
(residual nil))
|
|
|
|
(when (not complete)
|
|
|
|
(setq residual (car (last lines)))
|
|
|
|
(setq lines (butlast lines)))
|
|
|
|
(list lines residual))))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2004-11-25 16:33:53 +00:00
|
|
|
(defun flymake-reformat-err-line-patterns-from-compile-el (original-list)
|
2004-11-25 16:43:32 +00:00
|
|
|
"Grab error line patterns from ORIGINAL-LIST in compile.el format.
|
2004-11-25 16:33:53 +00:00
|
|
|
Convert it to flymake internal format."
|
2004-11-25 16:43:32 +00:00
|
|
|
(let* ((converted-list '()))
|
2005-03-24 22:55:54 +00:00
|
|
|
(dolist (item original-list)
|
|
|
|
(setq item (cdr item))
|
|
|
|
(let ((regexp (nth 0 item))
|
|
|
|
(file (nth 1 item))
|
|
|
|
(line (nth 2 item))
|
|
|
|
(col (nth 3 item)))
|
|
|
|
(if (consp file) (setq file (car file)))
|
|
|
|
(if (consp line) (setq line (car line)))
|
|
|
|
(if (consp col) (setq col (car col)))
|
2005-04-04 09:22:59 +00:00
|
|
|
|
2005-03-24 22:55:54 +00:00
|
|
|
(when (not (functionp line))
|
|
|
|
(setq converted-list (cons (list regexp file line col) converted-list)))))
|
2004-11-25 16:43:32 +00:00
|
|
|
converted-list))
|
2004-11-25 16:33:53 +00:00
|
|
|
|
2005-09-09 01:24:15 +00:00
|
|
|
(require 'compile)
|
2004-11-25 16:43:32 +00:00
|
|
|
|
|
|
|
(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
|
|
|
|
(append
|
|
|
|
'(
|
2005-03-24 22:42:42 +00:00
|
|
|
;; MS Visual C++ 6.0
|
2004-11-25 16:43:32 +00:00
|
|
|
("\\(\\([a-zA-Z]:\\)?[^:(\t\n]+\\)(\\([0-9]+\\)) \: \\(\\(error\\|warning\\|fatal error\\) \\(C[0-9]+\\):[ \t\n]*\\(.+\\)\\)"
|
|
|
|
1 3 nil 4)
|
2005-03-24 22:42:42 +00:00
|
|
|
;; jikes
|
2004-11-25 16:43:32 +00:00
|
|
|
("\\(\\([a-zA-Z]:\\)?[^:(\t\n]+\\)\:\\([0-9]+\\)\:[0-9]+\:[0-9]+\:[0-9]+\: \\(\\(Error\\|Warning\\|Caution\\|Semantic Error\\):[ \t\n]*\\(.+\\)\\)"
|
|
|
|
1 3 nil 4)
|
2005-03-24 22:42:42 +00:00
|
|
|
;; MS midl
|
2004-11-25 16:43:32 +00:00
|
|
|
("midl[ ]*:[ ]*\\(command line error .*\\)"
|
|
|
|
nil nil nil 1)
|
2005-03-24 22:42:42 +00:00
|
|
|
;; MS C#
|
2004-11-25 16:43:32 +00:00
|
|
|
("\\(\\([a-zA-Z]:\\)?[^:(\t\n]+\\)(\\([0-9]+\\),[0-9]+)\: \\(\\(error\\|warning\\|fatal error\\) \\(CS[0-9]+\\):[ \t\n]*\\(.+\\)\\)"
|
|
|
|
1 3 nil 4)
|
2005-03-24 22:42:42 +00:00
|
|
|
;; perl
|
2004-11-25 16:43:32 +00:00
|
|
|
("\\(.*\\) at \\([^ \n]+\\) line \\([0-9]+\\)[,.\n]" 2 3 nil 1)
|
2008-02-13 19:30:58 +00:00
|
|
|
;; PHP
|
|
|
|
("\\(?:Parse\\|Fatal\\) error: \\(.*\\) in \\(.*\\) on line \\([0-9]+\\)" 2 3 nil 1)
|
2005-03-24 22:42:42 +00:00
|
|
|
;; LaTeX warnings (fileless) ("\\(LaTeX \\(Warning\\|Error\\): .*\\) on input line \\([0-9]+\\)" 20 3 nil 1)
|
2011-06-27 07:23:27 +00:00
|
|
|
;; ant/javac. Note this also matches gcc warnings!
|
|
|
|
(" *\\(\\[javac\\] *\\)?\\(\\([a-zA-Z]:\\)?[^:(\t\n]+\\)\:\\([0-9]+\\)\\(?:\:[0-9]+\\)?\:[ \t\n]*\\(.+\\)"
|
2004-11-25 16:43:32 +00:00
|
|
|
2 4 nil 5))
|
|
|
|
;; compilation-error-regexp-alist)
|
2004-11-26 23:56:39 +00:00
|
|
|
(flymake-reformat-err-line-patterns-from-compile-el compilation-error-regexp-alist-alist))
|
2007-03-31 09:37:59 +00:00
|
|
|
"Patterns for matching error/warning lines. Each pattern has the form
|
|
|
|
\(REGEXP FILE-IDX LINE-IDX COL-IDX ERR-TEXT-IDX).
|
2005-03-24 22:42:42 +00:00
|
|
|
Use `flymake-reformat-err-line-patterns-from-compile-el' to add patterns
|
|
|
|
from compile.el")
|
|
|
|
|
|
|
|
;;(defcustom flymake-err-line-patterns
|
|
|
|
;; '(
|
|
|
|
;; ; MS Visual C++ 6.0
|
|
|
|
;; ("\\(\\([a-zA-Z]:\\)?[^:(\t\n]+\\)(\\([0-9]+\\)) \: \\(\\(error\\|warning\\|fatal error\\) \\(C[0-9]+\\):[ \t\n]*\\(.+\\)\\)"
|
|
|
|
;; 1 3 4)
|
|
|
|
;; ; jikes
|
|
|
|
;; ("\\(\\([a-zA-Z]:\\)?[^:(\t\n]+\\)\:\\([0-9]+\\)\:[0-9]+\:[0-9]+\:[0-9]+\: \\(\\(Error\\|Warning\\|Caution\\):[ \t\n]*\\(.+\\)\\)"
|
|
|
|
;; 1 3 4))
|
|
|
|
;; "patterns for matching error/warning lines, (regexp file-idx line-idx err-text-idx)"
|
|
|
|
;; :group 'flymake
|
|
|
|
;; :type '(repeat (string number number number))
|
|
|
|
;;)
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2012-08-30 11:41:40 +00:00
|
|
|
(defvar flymake-warning-re "^[wW]arning"
|
|
|
|
"Regexp matching against err-text to detect a warning.")
|
|
|
|
|
2004-11-25 16:33:53 +00:00
|
|
|
(defun flymake-parse-line (line)
|
2005-07-01 14:13:12 +00:00
|
|
|
"Parse LINE to see if it is an error or warning.
|
|
|
|
Return its components if so, nil otherwise."
|
2004-11-25 16:43:32 +00:00
|
|
|
(let ((raw-file-name nil)
|
|
|
|
(line-no 0)
|
|
|
|
(err-type "e")
|
|
|
|
(err-text nil)
|
2005-03-25 00:17:42 +00:00
|
|
|
(patterns flymake-err-line-patterns)
|
2004-11-25 16:43:32 +00:00
|
|
|
(matched nil))
|
2005-03-25 00:17:42 +00:00
|
|
|
(while (and patterns (not matched))
|
|
|
|
(when (string-match (car (car patterns)) line)
|
|
|
|
(let* ((file-idx (nth 1 (car patterns)))
|
|
|
|
(line-idx (nth 2 (car patterns))))
|
2004-11-25 16:43:32 +00:00
|
|
|
|
|
|
|
(setq raw-file-name (if file-idx (match-string file-idx line) nil))
|
2005-05-16 11:34:49 +00:00
|
|
|
(setq line-no (if line-idx (string-to-number (match-string line-idx line)) 0))
|
2005-03-25 00:17:42 +00:00
|
|
|
(setq err-text (if (> (length (car patterns)) 4)
|
|
|
|
(match-string (nth 4 (car patterns)) line)
|
2004-11-25 16:43:32 +00:00
|
|
|
(flymake-patch-err-text (substring line (match-end 0)))))
|
|
|
|
(or err-text (setq err-text "<no error text>"))
|
2012-08-30 11:41:40 +00:00
|
|
|
(if (and err-text (string-match flymake-warning-re err-text))
|
2004-11-25 16:43:32 +00:00
|
|
|
(setq err-type "w")
|
|
|
|
)
|
|
|
|
(flymake-log 3 "parse line: file-idx=%s line-idx=%s file=%s line=%s text=%s" file-idx line-idx
|
|
|
|
raw-file-name line-no err-text)
|
|
|
|
(setq matched t)))
|
2005-03-25 00:17:42 +00:00
|
|
|
(setq patterns (cdr patterns)))
|
2004-11-25 16:43:32 +00:00
|
|
|
(if matched
|
|
|
|
(flymake-ler-make-ler raw-file-name line-no err-type err-text)
|
|
|
|
())))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2004-11-25 16:33:53 +00:00
|
|
|
(defun flymake-find-err-info (err-info-list line-no)
|
2004-11-25 16:43:32 +00:00
|
|
|
"Find (line-err-info-list pos) for specified LINE-NO."
|
|
|
|
(if err-info-list
|
|
|
|
(let* ((line-err-info-list nil)
|
|
|
|
(pos 0)
|
|
|
|
(count (length err-info-list)))
|
|
|
|
|
|
|
|
(while (and (< pos count) (< (car (nth pos err-info-list)) line-no))
|
|
|
|
(setq pos (1+ pos)))
|
|
|
|
(when (and (< pos count) (equal (car (nth pos err-info-list)) line-no))
|
|
|
|
(setq line-err-info-list (flymake-er-get-line-err-info-list (nth pos err-info-list))))
|
|
|
|
(list line-err-info-list pos))
|
|
|
|
'(nil 0)))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2004-11-25 16:33:53 +00:00
|
|
|
(defun flymake-line-err-info-is-less-or-equal (line-one line-two)
|
2006-01-10 18:46:07 +00:00
|
|
|
(or (string< (flymake-ler-type line-one) (flymake-ler-type line-two))
|
|
|
|
(and (string= (flymake-ler-type line-one) (flymake-ler-type line-two))
|
|
|
|
(not (flymake-ler-file line-one)) (flymake-ler-file line-two))
|
|
|
|
(and (string= (flymake-ler-type line-one) (flymake-ler-type line-two))
|
|
|
|
(or (and (flymake-ler-file line-one) (flymake-ler-file line-two))
|
|
|
|
(and (not (flymake-ler-file line-one)) (not (flymake-ler-file line-two)))))))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2004-11-25 16:33:53 +00:00
|
|
|
(defun flymake-add-line-err-info (line-err-info-list line-err-info)
|
2005-04-30 20:13:39 +00:00
|
|
|
"Update LINE-ERR-INFO-LIST with the error LINE-ERR-INFO.
|
|
|
|
For the format of LINE-ERR-INFO, see `flymake-ler-make-ler'.
|
|
|
|
The new element is inserted in the proper position, according to
|
|
|
|
the predicate `flymake-line-err-info-is-less-or-equal'.
|
|
|
|
The updated value of LINE-ERR-INFO-LIST is returned."
|
2004-11-25 16:43:32 +00:00
|
|
|
(if (not line-err-info-list)
|
|
|
|
(list line-err-info)
|
|
|
|
(let* ((count (length line-err-info-list))
|
|
|
|
(idx 0))
|
|
|
|
(while (and (< idx count) (flymake-line-err-info-is-less-or-equal (nth idx line-err-info-list) line-err-info))
|
|
|
|
(setq idx (1+ idx)))
|
|
|
|
(cond ((equal 0 idx) (setq line-err-info-list (cons line-err-info line-err-info-list)))
|
|
|
|
(t (setq line-err-info-list (flymake-ins-after line-err-info-list (1- idx) line-err-info))))
|
|
|
|
line-err-info-list)))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2004-11-25 16:33:53 +00:00
|
|
|
(defun flymake-add-err-info (err-info-list line-err-info)
|
2005-04-30 20:13:39 +00:00
|
|
|
"Update ERR-INFO-LIST with the error LINE-ERR-INFO, preserving sort order.
|
|
|
|
Returns the updated value of ERR-INFO-LIST.
|
|
|
|
For the format of ERR-INFO-LIST, see `flymake-err-info'.
|
|
|
|
For the format of LINE-ERR-INFO, see `flymake-ler-make-ler'."
|
2006-01-10 18:46:07 +00:00
|
|
|
(let* ((line-no (if (flymake-ler-file line-err-info) 1 (flymake-ler-line line-err-info)))
|
2004-11-25 16:43:32 +00:00
|
|
|
(info-and-pos (flymake-find-err-info err-info-list line-no))
|
|
|
|
(exists (car info-and-pos))
|
|
|
|
(pos (nth 1 info-and-pos))
|
|
|
|
(line-err-info-list nil)
|
|
|
|
(err-info nil))
|
|
|
|
|
|
|
|
(if exists
|
|
|
|
(setq line-err-info-list (flymake-er-get-line-err-info-list (car (nthcdr pos err-info-list)))))
|
|
|
|
(setq line-err-info-list (flymake-add-line-err-info line-err-info-list line-err-info))
|
|
|
|
|
|
|
|
(setq err-info (flymake-er-make-er line-no line-err-info-list))
|
|
|
|
(cond (exists (setq err-info-list (flymake-set-at err-info-list pos err-info)))
|
|
|
|
((equal 0 pos) (setq err-info-list (cons err-info err-info-list)))
|
|
|
|
(t (setq err-info-list (flymake-ins-after err-info-list (1- pos) err-info))))
|
|
|
|
err-info-list))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2004-11-25 16:33:53 +00:00
|
|
|
(defun flymake-get-project-include-dirs-imp (basedir)
|
2004-11-25 16:43:32 +00:00
|
|
|
"Include dirs for the project current file belongs to."
|
|
|
|
(if (flymake-get-project-include-dirs-from-cache basedir)
|
|
|
|
(progn
|
|
|
|
(flymake-get-project-include-dirs-from-cache basedir))
|
2005-03-24 22:42:42 +00:00
|
|
|
;;else
|
2006-10-15 20:42:28 +00:00
|
|
|
(let* ((command-line (concat "make -C "
|
|
|
|
(shell-quote-argument basedir)
|
|
|
|
" DUMPVARS=INCLUDE_DIRS dumpvars"))
|
2004-11-25 16:43:32 +00:00
|
|
|
(output (shell-command-to-string command-line))
|
|
|
|
(lines (flymake-split-string output "\n"))
|
|
|
|
(count (length lines))
|
|
|
|
(idx 0)
|
|
|
|
(inc-dirs nil))
|
|
|
|
(while (and (< idx count) (not (string-match "^INCLUDE_DIRS=.*" (nth idx lines))))
|
|
|
|
(setq idx (1+ idx)))
|
|
|
|
(when (< idx count)
|
|
|
|
(let* ((inc-lines (flymake-split-string (nth idx lines) " *-I"))
|
|
|
|
(inc-count (length inc-lines)))
|
|
|
|
(while (> inc-count 0)
|
|
|
|
(when (not (string-match "^INCLUDE_DIRS=.*" (nth (1- inc-count) inc-lines)))
|
2006-01-10 18:46:07 +00:00
|
|
|
(push (flymake-replace-regexp-in-string "\"" "" (nth (1- inc-count) inc-lines)) inc-dirs))
|
2004-11-25 16:43:32 +00:00
|
|
|
(setq inc-count (1- inc-count)))))
|
|
|
|
(flymake-add-project-include-dirs-to-cache basedir inc-dirs)
|
|
|
|
inc-dirs)))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
|
|
|
(defcustom flymake-get-project-include-dirs-function 'flymake-get-project-include-dirs-imp
|
2005-07-01 14:13:12 +00:00
|
|
|
"Function used to get project include dirs, one parameter: basedir name."
|
2004-11-25 16:43:32 +00:00
|
|
|
:group 'flymake
|
|
|
|
:type 'function)
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2004-11-25 16:33:53 +00:00
|
|
|
(defun flymake-get-project-include-dirs (basedir)
|
2004-11-25 16:43:32 +00:00
|
|
|
(funcall flymake-get-project-include-dirs-function basedir))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2004-11-25 16:33:53 +00:00
|
|
|
(defun flymake-get-system-include-dirs ()
|
2004-11-25 16:43:32 +00:00
|
|
|
"System include dirs - from the 'INCLUDE' env setting."
|
|
|
|
(let* ((includes (getenv "INCLUDE")))
|
|
|
|
(if includes (flymake-split-string includes path-separator) nil)))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
|
|
|
(defvar flymake-project-include-dirs-cache (flymake-makehash 'equal))
|
|
|
|
|
2004-11-25 16:33:53 +00:00
|
|
|
(defun flymake-get-project-include-dirs-from-cache (base-dir)
|
2004-11-25 16:43:32 +00:00
|
|
|
(gethash base-dir flymake-project-include-dirs-cache))
|
2004-11-25 16:33:53 +00:00
|
|
|
|
|
|
|
(defun flymake-add-project-include-dirs-to-cache (base-dir include-dirs)
|
2004-11-25 16:43:32 +00:00
|
|
|
(puthash base-dir include-dirs flymake-project-include-dirs-cache))
|
2004-11-25 16:33:53 +00:00
|
|
|
|
|
|
|
(defun flymake-clear-project-include-dirs-cache ()
|
2004-11-25 16:43:32 +00:00
|
|
|
(clrhash flymake-project-include-dirs-cache))
|
2004-11-25 16:33:53 +00:00
|
|
|
|
|
|
|
(defun flymake-get-include-dirs (base-dir)
|
2004-11-25 16:43:32 +00:00
|
|
|
"Get dirs to use when resolving local file names."
|
|
|
|
(let* ((include-dirs (append '(".") (flymake-get-project-include-dirs base-dir) (flymake-get-system-include-dirs))))
|
|
|
|
include-dirs))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2005-12-30 17:28:30 +00:00
|
|
|
;; (defun flymake-restore-formatting ()
|
|
|
|
;; "Remove any formatting made by flymake."
|
|
|
|
;; )
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2006-01-05 18:51:00 +00:00
|
|
|
;; (defun flymake-get-program-dir (buffer)
|
|
|
|
;; "Get dir to start program in."
|
|
|
|
;; (unless (bufferp buffer)
|
|
|
|
;; (error "Invalid buffer"))
|
|
|
|
;; (with-current-buffer buffer
|
|
|
|
;; default-directory))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2004-11-25 16:33:53 +00:00
|
|
|
(defun flymake-safe-delete-file (file-name)
|
2004-11-25 16:43:32 +00:00
|
|
|
(when (and file-name (file-exists-p file-name))
|
|
|
|
(delete-file file-name)
|
|
|
|
(flymake-log 1 "deleted file %s" file-name)))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2004-11-25 16:33:53 +00:00
|
|
|
(defun flymake-safe-delete-directory (dir-name)
|
2011-04-22 18:44:26 +00:00
|
|
|
(condition-case nil
|
2004-11-25 16:43:32 +00:00
|
|
|
(progn
|
|
|
|
(delete-directory dir-name)
|
|
|
|
(flymake-log 1 "deleted dir %s" dir-name))
|
|
|
|
(error
|
|
|
|
(flymake-log 1 "Failed to delete dir %s, error ignored" dir-name))))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2004-11-26 23:56:39 +00:00
|
|
|
(defcustom flymake-compilation-prevents-syntax-check t
|
2011-06-08 07:17:26 +00:00
|
|
|
"If non-nil, don't start syntax check if compilation is running."
|
2004-11-25 16:43:32 +00:00
|
|
|
:group 'flymake
|
|
|
|
:type 'boolean)
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2005-12-30 17:28:30 +00:00
|
|
|
(defun flymake-start-syntax-check ()
|
|
|
|
"Start syntax checking for current buffer."
|
|
|
|
(interactive)
|
|
|
|
(flymake-log 3 "flymake is running: %s" flymake-is-running)
|
|
|
|
(when (and (not flymake-is-running)
|
|
|
|
(flymake-can-syntax-check-file buffer-file-name))
|
|
|
|
(when (or (not flymake-compilation-prevents-syntax-check)
|
|
|
|
(not (flymake-compilation-is-running))) ;+ (flymake-rep-ort-status buffer "COMP")
|
|
|
|
(flymake-clear-buildfile-cache)
|
|
|
|
(flymake-clear-project-include-dirs-cache)
|
|
|
|
|
|
|
|
(setq flymake-check-was-interrupted nil)
|
|
|
|
|
|
|
|
(let* ((source-file-name buffer-file-name)
|
|
|
|
(init-f (flymake-get-init-function source-file-name))
|
|
|
|
(cleanup-f (flymake-get-cleanup-function source-file-name))
|
(flymake-create-temp-with-folder-structure): Use expand-file-name.
(flymake-delete-temp-directory): Use expand-file-name,
file-name-directory, and directory-file-name.
(flymake-strrchr): Delete.
(flymake-start-syntax-check): Don't pass the redundant buffer argument
to the init-f function.
(flymake-init-find-buildfile-dir, flymake-init-create-temp-buffer-copy)
(flymake-init-create-temp-source-and-master-buffer-copy, flymake-perl-init)
(flymake-save-buffer-in-file, flymake-simple-make-init-impl, flymake-xml-init)
(flymake-simple-make-init, flymake-master-make-init, flymake-master-tex-init)
(flymake-master-make-header-init, flymake-simple-make-java-init)
(flymake-simple-ant-java-init, flymake-simple-tex-init):
Remove corresponding redundant buffer argument.
(flymake-allowed-file-name-masks): Remove last elems that are equal to
the default anyway. Clean up regexps.
2006-01-03 19:59:00 +00:00
|
|
|
(cmd-and-args (funcall init-f))
|
2005-12-30 17:28:30 +00:00
|
|
|
(cmd (nth 0 cmd-and-args))
|
|
|
|
(args (nth 1 cmd-and-args))
|
|
|
|
(dir (nth 2 cmd-and-args)))
|
|
|
|
(if (not cmd-and-args)
|
|
|
|
(progn
|
|
|
|
(flymake-log 0 "init function %s for %s failed, cleaning up" init-f source-file-name)
|
2006-01-05 18:51:00 +00:00
|
|
|
(funcall cleanup-f))
|
2005-12-30 17:28:30 +00:00
|
|
|
(progn
|
|
|
|
(setq flymake-last-change-time nil)
|
|
|
|
(flymake-start-syntax-check-process cmd args dir)))))))
|
|
|
|
|
|
|
|
(defun flymake-start-syntax-check-process (cmd args dir)
|
2004-11-25 16:43:32 +00:00
|
|
|
"Start syntax check process."
|
2011-04-20 18:08:21 +00:00
|
|
|
(condition-case err
|
|
|
|
(let* ((process
|
|
|
|
(let ((default-directory (or dir default-directory)))
|
|
|
|
(when dir
|
|
|
|
(flymake-log 3 "starting process on dir %s" dir))
|
|
|
|
(apply 'start-file-process
|
|
|
|
"flymake-proc" (current-buffer) cmd args))))
|
|
|
|
(set-process-sentinel process 'flymake-process-sentinel)
|
|
|
|
(set-process-filter process 'flymake-process-filter)
|
|
|
|
(push process flymake-processes)
|
|
|
|
|
|
|
|
(setq flymake-is-running t)
|
|
|
|
(setq flymake-last-change-time nil)
|
|
|
|
(setq flymake-check-start-time (flymake-float-time))
|
|
|
|
|
|
|
|
(flymake-report-status nil "*")
|
|
|
|
(flymake-log 2 "started process %d, command=%s, dir=%s"
|
|
|
|
(process-id process) (process-command process)
|
|
|
|
default-directory)
|
|
|
|
process)
|
|
|
|
(error
|
|
|
|
(let* ((err-str (format "Failed to launch syntax check process '%s' with args %s: %s"
|
|
|
|
cmd args (error-message-string err)))
|
|
|
|
(source-file-name buffer-file-name)
|
|
|
|
(cleanup-f (flymake-get-cleanup-function source-file-name)))
|
|
|
|
(flymake-log 0 err-str)
|
|
|
|
(funcall cleanup-f)
|
|
|
|
(flymake-report-fatal-status "PROCERR" err-str)))))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2006-01-03 18:44:42 +00:00
|
|
|
(defun flymake-kill-process (proc)
|
|
|
|
"Kill process PROC."
|
|
|
|
(kill-process proc)
|
|
|
|
(let* ((buf (process-buffer proc)))
|
|
|
|
(when (buffer-live-p buf)
|
|
|
|
(with-current-buffer buf
|
2005-04-30 20:13:39 +00:00
|
|
|
(setq flymake-check-was-interrupted t))))
|
2006-01-03 18:44:42 +00:00
|
|
|
(flymake-log 1 "killed process %d" (process-id proc)))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2004-11-25 16:33:53 +00:00
|
|
|
(defun flymake-stop-all-syntax-checks ()
|
2004-11-25 16:43:32 +00:00
|
|
|
"Kill all syntax check processes."
|
|
|
|
(interactive)
|
2006-01-03 18:44:42 +00:00
|
|
|
(while flymake-processes
|
|
|
|
(flymake-kill-process (pop flymake-processes))))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2004-11-25 16:33:53 +00:00
|
|
|
(defun flymake-compilation-is-running ()
|
2004-11-25 16:43:32 +00:00
|
|
|
(and (boundp 'compilation-in-progress)
|
|
|
|
compilation-in-progress))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2004-11-25 16:33:53 +00:00
|
|
|
(defun flymake-compile ()
|
2004-11-25 16:43:32 +00:00
|
|
|
"Kill all flymake syntax checks, start compilation."
|
|
|
|
(interactive)
|
|
|
|
(flymake-stop-all-syntax-checks)
|
|
|
|
(call-interactively 'compile))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
|
|
|
(defcustom flymake-no-changes-timeout 0.5
|
2004-11-25 16:43:32 +00:00
|
|
|
"Time to wait after last change before starting compilation."
|
|
|
|
:group 'flymake
|
|
|
|
:type 'number)
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2004-11-25 16:33:53 +00:00
|
|
|
(defun flymake-on-timer-event (buffer)
|
2004-11-25 16:43:32 +00:00
|
|
|
"Start a syntax check for buffer BUFFER if necessary."
|
2006-01-10 18:46:07 +00:00
|
|
|
(when (buffer-live-p buffer)
|
2005-03-24 22:55:54 +00:00
|
|
|
(with-current-buffer buffer
|
2005-04-30 20:13:39 +00:00
|
|
|
(when (and (not flymake-is-running)
|
|
|
|
flymake-last-change-time
|
2006-01-10 18:46:07 +00:00
|
|
|
(> (- (flymake-float-time) flymake-last-change-time)
|
|
|
|
flymake-no-changes-timeout))
|
2005-04-30 20:13:39 +00:00
|
|
|
|
|
|
|
(setq flymake-last-change-time nil)
|
2004-11-25 16:43:32 +00:00
|
|
|
(flymake-log 3 "starting syntax check as more than 1 second passed since last change")
|
2005-12-30 17:28:30 +00:00
|
|
|
(flymake-start-syntax-check)))))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2004-11-25 16:33:53 +00:00
|
|
|
(defun flymake-current-line-no ()
|
2004-11-25 16:43:32 +00:00
|
|
|
"Return number of current line in current buffer."
|
2006-01-10 18:46:07 +00:00
|
|
|
(count-lines (point-min) (if (eobp) (point) (1+ (point)))))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2005-12-30 17:28:30 +00:00
|
|
|
(defun flymake-count-lines ()
|
2004-11-25 16:43:32 +00:00
|
|
|
"Return number of lines in buffer BUFFER."
|
2005-12-30 17:28:30 +00:00
|
|
|
(count-lines (point-min) (point-max)))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2004-11-25 16:33:53 +00:00
|
|
|
(defun flymake-display-err-menu-for-current-line ()
|
2004-11-25 16:43:32 +00:00
|
|
|
"Display a menu with errors/warnings for current line if it has errors and/or warnings."
|
|
|
|
(interactive)
|
|
|
|
(let* ((line-no (flymake-current-line-no))
|
2005-04-30 20:13:39 +00:00
|
|
|
(line-err-info-list (nth 0 (flymake-find-err-info flymake-err-info line-no)))
|
2004-11-25 16:43:32 +00:00
|
|
|
(menu-data (flymake-make-err-menu-data line-no line-err-info-list))
|
2006-01-03 18:44:42 +00:00
|
|
|
(choice nil))
|
2004-11-25 16:43:32 +00:00
|
|
|
(if menu-data
|
|
|
|
(progn
|
2006-01-03 18:44:42 +00:00
|
|
|
(setq choice (flymake-popup-menu menu-data))
|
2004-11-25 16:43:32 +00:00
|
|
|
(flymake-log 3 "choice=%s" choice)
|
|
|
|
(when choice
|
|
|
|
(eval choice)))
|
|
|
|
(flymake-log 1 "no errors for line %d" line-no))))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2004-11-25 16:33:53 +00:00
|
|
|
(defun flymake-make-err-menu-data (line-no line-err-info-list)
|
2005-07-01 14:13:12 +00:00
|
|
|
"Make a (menu-title (item-title item-action)*) list with errors/warnings from LINE-ERR-INFO-LIST."
|
2004-11-25 16:43:32 +00:00
|
|
|
(let* ((menu-items nil))
|
|
|
|
(when line-err-info-list
|
|
|
|
(let* ((count (length line-err-info-list))
|
|
|
|
(menu-item-text nil))
|
|
|
|
(while (> count 0)
|
2006-01-10 18:46:07 +00:00
|
|
|
(setq menu-item-text (flymake-ler-text (nth (1- count) line-err-info-list)))
|
|
|
|
(let* ((file (flymake-ler-file (nth (1- count) line-err-info-list)))
|
|
|
|
(full-file (flymake-ler-full-file (nth (1- count) line-err-info-list)))
|
|
|
|
(line (flymake-ler-line (nth (1- count) line-err-info-list))))
|
2004-11-25 16:43:32 +00:00
|
|
|
(if file
|
|
|
|
(setq menu-item-text (concat menu-item-text " - " file "(" (format "%d" line) ")")))
|
|
|
|
(setq menu-items (cons (list menu-item-text
|
|
|
|
(if file (list 'flymake-goto-file-and-line full-file line) nil))
|
|
|
|
menu-items)))
|
|
|
|
(setq count (1- count)))
|
|
|
|
(flymake-log 3 "created menu-items with %d item(s)" (length menu-items))))
|
|
|
|
(if menu-items
|
|
|
|
(let* ((menu-title (format "Line %d: %d error(s), %d warning(s)" line-no
|
|
|
|
(flymake-get-line-err-count line-err-info-list "e")
|
|
|
|
(flymake-get-line-err-count line-err-info-list "w"))))
|
|
|
|
(list menu-title menu-items))
|
|
|
|
nil)))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2004-11-25 16:33:53 +00:00
|
|
|
(defun flymake-goto-file-and-line (file line)
|
2005-03-24 22:42:42 +00:00
|
|
|
"Try to get buffer for FILE and goto line LINE in it."
|
2004-11-25 16:43:32 +00:00
|
|
|
(if (not (file-exists-p file))
|
2007-11-17 09:46:37 +00:00
|
|
|
(flymake-log 1 "File %s does not exist" file)
|
|
|
|
(find-file file)
|
2009-09-01 03:18:44 +00:00
|
|
|
(goto-char (point-min))
|
|
|
|
(forward-line (1- line))))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2004-11-25 16:33:53 +00:00
|
|
|
;; flymake minor mode declarations
|
2005-03-25 00:06:07 +00:00
|
|
|
(defvar flymake-mode-line nil)
|
2004-11-25 16:33:53 +00:00
|
|
|
|
2004-05-29 12:55:24 +00:00
|
|
|
(make-variable-buffer-local 'flymake-mode-line)
|
2004-11-25 16:33:53 +00:00
|
|
|
|
2004-05-29 12:55:24 +00:00
|
|
|
(defvar flymake-mode-line-e-w nil)
|
2004-11-25 16:33:53 +00:00
|
|
|
|
2004-05-29 12:55:24 +00:00
|
|
|
(make-variable-buffer-local 'flymake-mode-line-e-w)
|
2004-11-25 16:33:53 +00:00
|
|
|
|
2004-05-29 12:55:24 +00:00
|
|
|
(defvar flymake-mode-line-status nil)
|
2004-11-25 16:33:53 +00:00
|
|
|
|
2004-05-29 12:55:24 +00:00
|
|
|
(make-variable-buffer-local 'flymake-mode-line-status)
|
|
|
|
|
2005-12-30 17:28:30 +00:00
|
|
|
(defun flymake-report-status (e-w &optional status)
|
2004-11-25 16:43:32 +00:00
|
|
|
"Show status in mode line."
|
2005-12-30 17:28:30 +00:00
|
|
|
(when e-w
|
|
|
|
(setq flymake-mode-line-e-w e-w))
|
|
|
|
(when status
|
|
|
|
(setq flymake-mode-line-status status))
|
|
|
|
(let* ((mode-line " Flymake"))
|
|
|
|
(when (> (length flymake-mode-line-e-w) 0)
|
|
|
|
(setq mode-line (concat mode-line ":" flymake-mode-line-e-w)))
|
|
|
|
(setq mode-line (concat mode-line flymake-mode-line-status))
|
|
|
|
(setq flymake-mode-line mode-line)
|
|
|
|
(force-mode-line-update)))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2004-11-25 16:33:53 +00:00
|
|
|
(defun flymake-display-warning (warning)
|
2004-11-25 16:43:32 +00:00
|
|
|
"Display a warning to user."
|
|
|
|
(message-box warning))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
|
|
|
(defcustom flymake-gui-warnings-enabled t
|
2005-07-01 14:13:12 +00:00
|
|
|
"Enables/disables GUI warnings."
|
2004-11-25 16:43:32 +00:00
|
|
|
:group 'flymake
|
|
|
|
:type 'boolean)
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2005-12-30 17:28:30 +00:00
|
|
|
(defun flymake-report-fatal-status (status warning)
|
2004-11-25 16:43:32 +00:00
|
|
|
"Display a warning and switch flymake mode off."
|
|
|
|
(when flymake-gui-warnings-enabled
|
|
|
|
(flymake-display-warning (format "Flymake: %s. Flymake will be switched OFF" warning))
|
|
|
|
)
|
2005-12-30 17:28:30 +00:00
|
|
|
(flymake-mode 0)
|
|
|
|
(flymake-log 0 "switched OFF Flymake mode for buffer %s due to fatal status %s, warning %s"
|
|
|
|
(buffer-name) status warning))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2005-07-02 19:36:38 +00:00
|
|
|
(defcustom flymake-start-syntax-check-on-find-file t
|
|
|
|
"Start syntax check on find file."
|
|
|
|
:group 'flymake
|
|
|
|
:type 'boolean)
|
|
|
|
|
2005-03-26 15:33:33 +00:00
|
|
|
;;;###autoload
|
2005-03-25 00:06:07 +00:00
|
|
|
(define-minor-mode flymake-mode
|
2012-02-08 02:12:24 +00:00
|
|
|
"Toggle on-the-fly syntax checking.
|
|
|
|
With a prefix argument ARG, enable the mode if ARG is positive,
|
|
|
|
and disable it otherwise. If called from Lisp, enable the mode
|
|
|
|
if ARG is omitted or nil."
|
2005-04-04 09:22:59 +00:00
|
|
|
:group 'flymake :lighter flymake-mode-line
|
2005-07-02 19:36:38 +00:00
|
|
|
(cond
|
|
|
|
|
|
|
|
;; Turning the mode ON.
|
|
|
|
(flymake-mode
|
2011-07-02 22:55:41 +00:00
|
|
|
(cond
|
|
|
|
((not buffer-file-name)
|
|
|
|
(message "Flymake unable to run without a buffer file name"))
|
|
|
|
((not (flymake-can-syntax-check-file buffer-file-name))
|
|
|
|
(flymake-log 2 "flymake cannot check syntax in buffer %s" (buffer-name)))
|
|
|
|
(t
|
2005-07-02 19:36:38 +00:00
|
|
|
(add-hook 'after-change-functions 'flymake-after-change-function nil t)
|
|
|
|
(add-hook 'after-save-hook 'flymake-after-save-hook nil t)
|
|
|
|
(add-hook 'kill-buffer-hook 'flymake-kill-buffer-hook nil t)
|
|
|
|
;;+(add-hook 'find-file-hook 'flymake-find-file-hook)
|
|
|
|
|
2005-12-30 17:28:30 +00:00
|
|
|
(flymake-report-status "" "")
|
2005-07-03 23:18:19 +00:00
|
|
|
|
2005-07-02 19:36:38 +00:00
|
|
|
(setq flymake-timer
|
|
|
|
(run-at-time nil 1 'flymake-on-timer-event (current-buffer)))
|
|
|
|
|
2012-04-11 00:21:00 +00:00
|
|
|
(when (and flymake-start-syntax-check-on-find-file
|
|
|
|
;; Since we write temp files in current dir, there's no point
|
|
|
|
;; trying if the directory is read-only (bug#8954).
|
|
|
|
(file-writable-p (file-name-directory buffer-file-name)))
|
|
|
|
(with-demoted-errors
|
|
|
|
(flymake-start-syntax-check))))))
|
2005-07-02 19:36:38 +00:00
|
|
|
|
|
|
|
;; Turning the mode OFF.
|
|
|
|
(t
|
|
|
|
(remove-hook 'after-change-functions 'flymake-after-change-function t)
|
|
|
|
(remove-hook 'after-save-hook 'flymake-after-save-hook t)
|
|
|
|
(remove-hook 'kill-buffer-hook 'flymake-kill-buffer-hook t)
|
|
|
|
;;+(remove-hook 'find-file-hook (function flymake-find-file-hook) t)
|
2004-11-25 16:33:53 +00:00
|
|
|
|
2005-12-30 17:28:30 +00:00
|
|
|
(flymake-delete-own-overlays)
|
2005-07-02 19:36:38 +00:00
|
|
|
|
|
|
|
(when flymake-timer
|
|
|
|
(cancel-timer flymake-timer)
|
|
|
|
(setq flymake-timer nil))
|
|
|
|
|
2005-07-02 21:17:05 +00:00
|
|
|
(setq flymake-is-running nil))))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
|
|
|
;;;###autoload
|
2004-11-25 16:33:53 +00:00
|
|
|
(defun flymake-mode-on ()
|
2004-11-25 16:43:32 +00:00
|
|
|
"Turn flymake mode on."
|
2005-07-02 19:36:38 +00:00
|
|
|
(flymake-mode 1)
|
|
|
|
(flymake-log 1 "flymake mode turned ON for buffer %s" (buffer-name)))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
|
|
|
;;;###autoload
|
2004-11-25 16:33:53 +00:00
|
|
|
(defun flymake-mode-off ()
|
2004-11-25 16:43:32 +00:00
|
|
|
"Turn flymake mode off."
|
2005-07-02 19:36:38 +00:00
|
|
|
(flymake-mode 0)
|
2005-07-02 21:17:05 +00:00
|
|
|
(flymake-log 1 "flymake mode turned OFF for buffer %s" (buffer-name)))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
|
|
|
(defcustom flymake-start-syntax-check-on-newline t
|
2004-11-25 16:43:32 +00:00
|
|
|
"Start syntax check if newline char was added/removed from the buffer."
|
|
|
|
:group 'flymake
|
|
|
|
:type 'boolean)
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2011-04-22 18:44:26 +00:00
|
|
|
(defun flymake-after-change-function (start stop _len)
|
2005-03-24 22:42:42 +00:00
|
|
|
"Start syntax check for current buffer if it isn't already running."
|
|
|
|
;;+(flymake-log 0 "setting change time to %s" (flymake-float-time))
|
2004-11-25 16:43:32 +00:00
|
|
|
(let((new-text (buffer-substring start stop)))
|
|
|
|
(when (and flymake-start-syntax-check-on-newline (equal new-text "\n"))
|
|
|
|
(flymake-log 3 "starting syntax check as new-line has been seen")
|
2005-12-30 17:28:30 +00:00
|
|
|
(flymake-start-syntax-check))
|
2005-04-30 20:13:39 +00:00
|
|
|
(setq flymake-last-change-time (flymake-float-time))))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2004-11-25 16:33:53 +00:00
|
|
|
(defun flymake-after-save-hook ()
|
2004-11-25 16:43:32 +00:00
|
|
|
(if (local-variable-p 'flymake-mode (current-buffer)) ; (???) other way to determine whether flymake is active in buffer being saved?
|
|
|
|
(progn
|
|
|
|
(flymake-log 3 "starting syntax check as buffer was saved")
|
2005-12-30 17:28:30 +00:00
|
|
|
(flymake-start-syntax-check)))) ; no more mode 3. cannot start check if mode 3 (to temp copies) is active - (???)
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2004-11-25 16:33:53 +00:00
|
|
|
(defun flymake-kill-buffer-hook ()
|
2005-04-30 20:13:39 +00:00
|
|
|
(when flymake-timer
|
|
|
|
(cancel-timer flymake-timer)
|
|
|
|
(setq flymake-timer nil)))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2011-07-01 10:33:50 +00:00
|
|
|
;;;###autoload
|
2004-11-25 16:33:53 +00:00
|
|
|
(defun flymake-find-file-hook ()
|
2005-03-24 22:42:42 +00:00
|
|
|
;;+(when flymake-start-syntax-check-on-find-file
|
|
|
|
;;+ (flymake-log 3 "starting syntax check on file open")
|
2005-12-30 17:28:30 +00:00
|
|
|
;;+ (flymake-start-syntax-check)
|
2005-03-24 22:42:42 +00:00
|
|
|
;;+)
|
2004-11-25 16:43:32 +00:00
|
|
|
(when (and (not (local-variable-p 'flymake-mode (current-buffer)))
|
2005-07-02 19:36:38 +00:00
|
|
|
(flymake-can-syntax-check-file buffer-file-name))
|
2004-11-25 16:43:32 +00:00
|
|
|
(flymake-mode)
|
|
|
|
(flymake-log 3 "automatically turned ON flymake mode")))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2004-11-25 16:33:53 +00:00
|
|
|
(defun flymake-get-first-err-line-no (err-info-list)
|
2004-11-25 16:43:32 +00:00
|
|
|
"Return first line with error."
|
|
|
|
(when err-info-list
|
|
|
|
(flymake-er-get-line (car err-info-list))))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2004-11-25 16:33:53 +00:00
|
|
|
(defun flymake-get-last-err-line-no (err-info-list)
|
2004-11-25 16:43:32 +00:00
|
|
|
"Return last line with error."
|
|
|
|
(when err-info-list
|
|
|
|
(flymake-er-get-line (nth (1- (length err-info-list)) err-info-list))))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2004-11-25 16:33:53 +00:00
|
|
|
(defun flymake-get-next-err-line-no (err-info-list line-no)
|
2004-11-25 16:43:32 +00:00
|
|
|
"Return next line with error."
|
|
|
|
(when err-info-list
|
|
|
|
(let* ((count (length err-info-list))
|
|
|
|
(idx 0))
|
|
|
|
(while (and (< idx count) (>= line-no (flymake-er-get-line (nth idx err-info-list))))
|
|
|
|
(setq idx (1+ idx)))
|
|
|
|
(if (< idx count)
|
|
|
|
(flymake-er-get-line (nth idx err-info-list))))))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2004-11-25 16:33:53 +00:00
|
|
|
(defun flymake-get-prev-err-line-no (err-info-list line-no)
|
2005-07-01 14:13:12 +00:00
|
|
|
"Return previous line with error."
|
2004-11-25 16:43:32 +00:00
|
|
|
(when err-info-list
|
|
|
|
(let* ((count (length err-info-list)))
|
|
|
|
(while (and (> count 0) (<= line-no (flymake-er-get-line (nth (1- count) err-info-list))))
|
|
|
|
(setq count (1- count)))
|
|
|
|
(if (> count 0)
|
|
|
|
(flymake-er-get-line (nth (1- count) err-info-list))))))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2004-11-25 16:33:53 +00:00
|
|
|
(defun flymake-skip-whitespace ()
|
2004-11-25 16:43:32 +00:00
|
|
|
"Move forward until non-whitespace is reached."
|
|
|
|
(while (looking-at "[ \t]")
|
|
|
|
(forward-char)))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2004-11-25 16:33:53 +00:00
|
|
|
(defun flymake-goto-line (line-no)
|
2005-03-24 22:42:42 +00:00
|
|
|
"Go to line LINE-NO, then skip whitespace."
|
2009-09-01 03:18:44 +00:00
|
|
|
(goto-char (point-min))
|
|
|
|
(forward-line (1- line-no))
|
2004-11-25 16:43:32 +00:00
|
|
|
(flymake-skip-whitespace))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2004-11-25 16:33:53 +00:00
|
|
|
(defun flymake-goto-next-error ()
|
2005-03-24 22:42:42 +00:00
|
|
|
"Go to next error in err ring."
|
2004-11-25 16:43:32 +00:00
|
|
|
(interactive)
|
2005-04-30 20:13:39 +00:00
|
|
|
(let ((line-no (flymake-get-next-err-line-no flymake-err-info (flymake-current-line-no))))
|
2004-11-25 16:43:32 +00:00
|
|
|
(when (not line-no)
|
2005-04-30 20:13:39 +00:00
|
|
|
(setq line-no (flymake-get-first-err-line-no flymake-err-info))
|
2004-11-25 16:43:32 +00:00
|
|
|
(flymake-log 1 "passed end of file"))
|
|
|
|
(if line-no
|
|
|
|
(flymake-goto-line line-no)
|
|
|
|
(flymake-log 1 "no errors in current buffer"))))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2004-11-25 16:33:53 +00:00
|
|
|
(defun flymake-goto-prev-error ()
|
2005-07-01 14:13:12 +00:00
|
|
|
"Go to previous error in err ring."
|
2004-11-25 16:43:32 +00:00
|
|
|
(interactive)
|
2005-04-30 20:13:39 +00:00
|
|
|
(let ((line-no (flymake-get-prev-err-line-no flymake-err-info (flymake-current-line-no))))
|
2004-11-25 16:43:32 +00:00
|
|
|
(when (not line-no)
|
2005-04-30 20:13:39 +00:00
|
|
|
(setq line-no (flymake-get-last-err-line-no flymake-err-info))
|
2004-11-25 16:43:32 +00:00
|
|
|
(flymake-log 1 "passed beginning of file"))
|
|
|
|
(if line-no
|
|
|
|
(flymake-goto-line line-no)
|
|
|
|
(flymake-log 1 "no errors in current buffer"))))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2004-11-25 16:33:53 +00:00
|
|
|
(defun flymake-patch-err-text (string)
|
2004-11-25 16:43:32 +00:00
|
|
|
(if (string-match "^[\n\t :0-9]*\\(.*\\)$" string)
|
|
|
|
(match-string 1 string)
|
|
|
|
string))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
|
|
|
;;;; general init-cleanup and helper routines
|
2004-11-25 16:33:53 +00:00
|
|
|
(defun flymake-create-temp-inplace (file-name prefix)
|
2004-11-25 16:43:32 +00:00
|
|
|
(unless (stringp file-name)
|
|
|
|
(error "Invalid file-name"))
|
|
|
|
(or prefix
|
|
|
|
(setq prefix "flymake"))
|
|
|
|
(let* ((temp-name (concat (file-name-sans-extension file-name)
|
|
|
|
"_" prefix
|
|
|
|
(and (file-name-extension file-name)
|
|
|
|
(concat "." (file-name-extension file-name))))))
|
|
|
|
(flymake-log 3 "create-temp-inplace: file=%s temp=%s" file-name temp-name)
|
|
|
|
temp-name))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2011-04-22 18:44:26 +00:00
|
|
|
(defun flymake-create-temp-with-folder-structure (file-name _prefix)
|
2004-11-25 16:43:32 +00:00
|
|
|
(unless (stringp file-name)
|
|
|
|
(error "Invalid file-name"))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2004-11-25 16:43:32 +00:00
|
|
|
(let* ((dir (file-name-directory file-name))
|
(flymake-create-temp-with-folder-structure): Use expand-file-name.
(flymake-delete-temp-directory): Use expand-file-name,
file-name-directory, and directory-file-name.
(flymake-strrchr): Delete.
(flymake-start-syntax-check): Don't pass the redundant buffer argument
to the init-f function.
(flymake-init-find-buildfile-dir, flymake-init-create-temp-buffer-copy)
(flymake-init-create-temp-source-and-master-buffer-copy, flymake-perl-init)
(flymake-save-buffer-in-file, flymake-simple-make-init-impl, flymake-xml-init)
(flymake-simple-make-init, flymake-master-make-init, flymake-master-tex-init)
(flymake-master-make-header-init, flymake-simple-make-java-init)
(flymake-simple-ant-java-init, flymake-simple-tex-init):
Remove corresponding redundant buffer argument.
(flymake-allowed-file-name-masks): Remove last elems that are equal to
the default anyway. Clean up regexps.
2006-01-03 19:59:00 +00:00
|
|
|
;; Not sure what this slash-pos is all about, but I guess it's just
|
|
|
|
;; trying to remove the leading / of absolute file names.
|
2004-11-25 16:43:32 +00:00
|
|
|
(slash-pos (string-match "/" dir))
|
(flymake-create-temp-with-folder-structure): Use expand-file-name.
(flymake-delete-temp-directory): Use expand-file-name,
file-name-directory, and directory-file-name.
(flymake-strrchr): Delete.
(flymake-start-syntax-check): Don't pass the redundant buffer argument
to the init-f function.
(flymake-init-find-buildfile-dir, flymake-init-create-temp-buffer-copy)
(flymake-init-create-temp-source-and-master-buffer-copy, flymake-perl-init)
(flymake-save-buffer-in-file, flymake-simple-make-init-impl, flymake-xml-init)
(flymake-simple-make-init, flymake-master-make-init, flymake-master-tex-init)
(flymake-master-make-header-init, flymake-simple-make-java-init)
(flymake-simple-ant-java-init, flymake-simple-tex-init):
Remove corresponding redundant buffer argument.
(flymake-allowed-file-name-masks): Remove last elems that are equal to
the default anyway. Clean up regexps.
2006-01-03 19:59:00 +00:00
|
|
|
(temp-dir (expand-file-name (substring dir (1+ slash-pos))
|
|
|
|
(flymake-get-temp-dir))))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
(flymake-create-temp-with-folder-structure): Use expand-file-name.
(flymake-delete-temp-directory): Use expand-file-name,
file-name-directory, and directory-file-name.
(flymake-strrchr): Delete.
(flymake-start-syntax-check): Don't pass the redundant buffer argument
to the init-f function.
(flymake-init-find-buildfile-dir, flymake-init-create-temp-buffer-copy)
(flymake-init-create-temp-source-and-master-buffer-copy, flymake-perl-init)
(flymake-save-buffer-in-file, flymake-simple-make-init-impl, flymake-xml-init)
(flymake-simple-make-init, flymake-master-make-init, flymake-master-tex-init)
(flymake-master-make-header-init, flymake-simple-make-java-init)
(flymake-simple-ant-java-init, flymake-simple-tex-init):
Remove corresponding redundant buffer argument.
(flymake-allowed-file-name-masks): Remove last elems that are equal to
the default anyway. Clean up regexps.
2006-01-03 19:59:00 +00:00
|
|
|
(file-truename (expand-file-name (file-name-nondirectory file-name)
|
|
|
|
temp-dir))))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2004-11-25 16:33:53 +00:00
|
|
|
(defun flymake-delete-temp-directory (dir-name)
|
2005-03-24 22:42:42 +00:00
|
|
|
"Attempt to delete temp dir created by `flymake-create-temp-with-folder-structure', do not fail on error."
|
2004-11-25 16:43:32 +00:00
|
|
|
(let* ((temp-dir (flymake-get-temp-dir))
|
2006-01-10 18:46:07 +00:00
|
|
|
(suffix (substring dir-name (1+ (length temp-dir)))))
|
2004-11-25 16:43:32 +00:00
|
|
|
|
|
|
|
(while (> (length suffix) 0)
|
(flymake-create-temp-with-folder-structure): Use expand-file-name.
(flymake-delete-temp-directory): Use expand-file-name,
file-name-directory, and directory-file-name.
(flymake-strrchr): Delete.
(flymake-start-syntax-check): Don't pass the redundant buffer argument
to the init-f function.
(flymake-init-find-buildfile-dir, flymake-init-create-temp-buffer-copy)
(flymake-init-create-temp-source-and-master-buffer-copy, flymake-perl-init)
(flymake-save-buffer-in-file, flymake-simple-make-init-impl, flymake-xml-init)
(flymake-simple-make-init, flymake-master-make-init, flymake-master-tex-init)
(flymake-master-make-header-init, flymake-simple-make-java-init)
(flymake-simple-ant-java-init, flymake-simple-tex-init):
Remove corresponding redundant buffer argument.
(flymake-allowed-file-name-masks): Remove last elems that are equal to
the default anyway. Clean up regexps.
2006-01-03 19:59:00 +00:00
|
|
|
(setq suffix (directory-file-name suffix))
|
2005-03-24 22:42:42 +00:00
|
|
|
;;+(flymake-log 0 "suffix=%s" suffix)
|
(flymake-create-temp-with-folder-structure): Use expand-file-name.
(flymake-delete-temp-directory): Use expand-file-name,
file-name-directory, and directory-file-name.
(flymake-strrchr): Delete.
(flymake-start-syntax-check): Don't pass the redundant buffer argument
to the init-f function.
(flymake-init-find-buildfile-dir, flymake-init-create-temp-buffer-copy)
(flymake-init-create-temp-source-and-master-buffer-copy, flymake-perl-init)
(flymake-save-buffer-in-file, flymake-simple-make-init-impl, flymake-xml-init)
(flymake-simple-make-init, flymake-master-make-init, flymake-master-tex-init)
(flymake-master-make-header-init, flymake-simple-make-java-init)
(flymake-simple-ant-java-init, flymake-simple-tex-init):
Remove corresponding redundant buffer argument.
(flymake-allowed-file-name-masks): Remove last elems that are equal to
the default anyway. Clean up regexps.
2006-01-03 19:59:00 +00:00
|
|
|
(flymake-safe-delete-directory
|
|
|
|
(file-truename (expand-file-name suffix temp-dir)))
|
|
|
|
(setq suffix (file-name-directory suffix)))))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2006-01-03 19:05:06 +00:00
|
|
|
(defvar flymake-temp-source-file-name nil)
|
|
|
|
(make-variable-buffer-local 'flymake-temp-source-file-name)
|
|
|
|
|
|
|
|
(defvar flymake-master-file-name nil)
|
|
|
|
(make-variable-buffer-local 'flymake-master-file-name)
|
|
|
|
|
|
|
|
(defvar flymake-temp-master-file-name nil)
|
|
|
|
(make-variable-buffer-local 'flymake-temp-master-file-name)
|
|
|
|
|
|
|
|
(defvar flymake-base-dir nil)
|
|
|
|
(make-variable-buffer-local 'flymake-base-dir)
|
|
|
|
|
(flymake-create-temp-with-folder-structure): Use expand-file-name.
(flymake-delete-temp-directory): Use expand-file-name,
file-name-directory, and directory-file-name.
(flymake-strrchr): Delete.
(flymake-start-syntax-check): Don't pass the redundant buffer argument
to the init-f function.
(flymake-init-find-buildfile-dir, flymake-init-create-temp-buffer-copy)
(flymake-init-create-temp-source-and-master-buffer-copy, flymake-perl-init)
(flymake-save-buffer-in-file, flymake-simple-make-init-impl, flymake-xml-init)
(flymake-simple-make-init, flymake-master-make-init, flymake-master-tex-init)
(flymake-master-make-header-init, flymake-simple-make-java-init)
(flymake-simple-ant-java-init, flymake-simple-tex-init):
Remove corresponding redundant buffer argument.
(flymake-allowed-file-name-masks): Remove last elems that are equal to
the default anyway. Clean up regexps.
2006-01-03 19:59:00 +00:00
|
|
|
(defun flymake-init-create-temp-buffer-copy (create-temp-f)
|
2004-11-25 16:43:32 +00:00
|
|
|
"Make a temporary copy of the current buffer, save its name in buffer data and return the name."
|
(flymake-create-temp-with-folder-structure): Use expand-file-name.
(flymake-delete-temp-directory): Use expand-file-name,
file-name-directory, and directory-file-name.
(flymake-strrchr): Delete.
(flymake-start-syntax-check): Don't pass the redundant buffer argument
to the init-f function.
(flymake-init-find-buildfile-dir, flymake-init-create-temp-buffer-copy)
(flymake-init-create-temp-source-and-master-buffer-copy, flymake-perl-init)
(flymake-save-buffer-in-file, flymake-simple-make-init-impl, flymake-xml-init)
(flymake-simple-make-init, flymake-master-make-init, flymake-master-tex-init)
(flymake-master-make-header-init, flymake-simple-make-java-init)
(flymake-simple-ant-java-init, flymake-simple-tex-init):
Remove corresponding redundant buffer argument.
(flymake-allowed-file-name-masks): Remove last elems that are equal to
the default anyway. Clean up regexps.
2006-01-03 19:59:00 +00:00
|
|
|
(let* ((source-file-name buffer-file-name)
|
2004-11-25 16:43:32 +00:00
|
|
|
(temp-source-file-name (funcall create-temp-f source-file-name "flymake")))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
(flymake-create-temp-with-folder-structure): Use expand-file-name.
(flymake-delete-temp-directory): Use expand-file-name,
file-name-directory, and directory-file-name.
(flymake-strrchr): Delete.
(flymake-start-syntax-check): Don't pass the redundant buffer argument
to the init-f function.
(flymake-init-find-buildfile-dir, flymake-init-create-temp-buffer-copy)
(flymake-init-create-temp-source-and-master-buffer-copy, flymake-perl-init)
(flymake-save-buffer-in-file, flymake-simple-make-init-impl, flymake-xml-init)
(flymake-simple-make-init, flymake-master-make-init, flymake-master-tex-init)
(flymake-master-make-header-init, flymake-simple-make-java-init)
(flymake-simple-ant-java-init, flymake-simple-tex-init):
Remove corresponding redundant buffer argument.
(flymake-allowed-file-name-masks): Remove last elems that are equal to
the default anyway. Clean up regexps.
2006-01-03 19:59:00 +00:00
|
|
|
(flymake-save-buffer-in-file temp-source-file-name)
|
|
|
|
(setq flymake-temp-source-file-name temp-source-file-name)
|
2004-11-25 16:43:32 +00:00
|
|
|
temp-source-file-name))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2006-01-05 18:51:00 +00:00
|
|
|
(defun flymake-simple-cleanup ()
|
2005-06-14 11:32:58 +00:00
|
|
|
"Do cleanup after `flymake-init-create-temp-buffer-copy'.
|
2004-11-25 16:33:53 +00:00
|
|
|
Delete temp file."
|
2006-01-05 18:51:00 +00:00
|
|
|
(flymake-safe-delete-file flymake-temp-source-file-name)
|
|
|
|
(setq flymake-last-change-time nil))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2006-01-05 18:51:00 +00:00
|
|
|
(defun flymake-get-real-file-name (file-name-from-err-msg)
|
2005-03-24 22:42:42 +00:00
|
|
|
"Translate file name from error message to \"real\" file name.
|
|
|
|
Return full-name. Names are real, not patched."
|
2006-01-05 18:51:00 +00:00
|
|
|
(let* ((real-name nil)
|
|
|
|
(source-file-name buffer-file-name)
|
|
|
|
(master-file-name flymake-master-file-name)
|
|
|
|
(temp-source-file-name flymake-temp-source-file-name)
|
|
|
|
(temp-master-file-name flymake-temp-master-file-name)
|
2006-01-03 19:05:06 +00:00
|
|
|
(base-dirs
|
2006-01-05 18:51:00 +00:00
|
|
|
(list flymake-base-dir
|
2006-01-03 19:05:06 +00:00
|
|
|
(file-name-directory source-file-name)
|
|
|
|
(if master-file-name (file-name-directory master-file-name))))
|
2006-01-05 18:51:00 +00:00
|
|
|
(files (list (list source-file-name source-file-name)
|
|
|
|
(list temp-source-file-name source-file-name)
|
|
|
|
(list master-file-name master-file-name)
|
|
|
|
(list temp-master-file-name master-file-name))))
|
2004-11-25 16:43:32 +00:00
|
|
|
|
|
|
|
(when (equal 0 (length file-name-from-err-msg))
|
|
|
|
(setq file-name-from-err-msg source-file-name))
|
|
|
|
|
|
|
|
(setq real-name (flymake-get-full-patched-file-name file-name-from-err-msg base-dirs files))
|
2005-03-24 22:42:42 +00:00
|
|
|
;; if real-name is nil, than file name from err msg is none of the files we've patched
|
2004-11-25 16:43:32 +00:00
|
|
|
(if (not real-name)
|
|
|
|
(setq real-name (flymake-get-full-nonpatched-file-name file-name-from-err-msg base-dirs)))
|
|
|
|
(if (not real-name)
|
|
|
|
(setq real-name file-name-from-err-msg))
|
|
|
|
(setq real-name (flymake-fix-file-name real-name))
|
|
|
|
(flymake-log 3 "get-real-file-name: file-name=%s real-name=%s" file-name-from-err-msg real-name)
|
|
|
|
real-name))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2004-11-25 16:33:53 +00:00
|
|
|
(defun flymake-get-full-patched-file-name (file-name-from-err-msg base-dirs files)
|
2004-11-25 16:43:32 +00:00
|
|
|
(let* ((base-dirs-count (length base-dirs))
|
|
|
|
(file-count (length files))
|
|
|
|
(real-name nil))
|
|
|
|
|
|
|
|
(while (and (not real-name) (> base-dirs-count 0))
|
|
|
|
(setq file-count (length files))
|
|
|
|
(while (and (not real-name) (> file-count 0))
|
|
|
|
(let* ((this-dir (nth (1- base-dirs-count) base-dirs))
|
|
|
|
(this-file (nth 0 (nth (1- file-count) files)))
|
|
|
|
(this-real-name (nth 1 (nth (1- file-count) files))))
|
2005-03-24 22:42:42 +00:00
|
|
|
;;+(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)
|
2004-11-25 16:43:32 +00:00
|
|
|
(when (and this-dir this-file (flymake-same-files
|
2005-04-19 18:19:43 +00:00
|
|
|
(expand-file-name file-name-from-err-msg this-dir)
|
2004-11-25 16:43:32 +00:00
|
|
|
this-file))
|
|
|
|
(setq real-name this-real-name)))
|
|
|
|
(setq file-count (1- file-count)))
|
|
|
|
(setq base-dirs-count (1- base-dirs-count)))
|
|
|
|
real-name))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2004-11-25 16:33:53 +00:00
|
|
|
(defun flymake-get-full-nonpatched-file-name (file-name-from-err-msg base-dirs)
|
2004-11-25 16:43:32 +00:00
|
|
|
(let* ((real-name nil))
|
|
|
|
(if (file-name-absolute-p file-name-from-err-msg)
|
|
|
|
(setq real-name file-name-from-err-msg)
|
|
|
|
(let* ((base-dirs-count (length base-dirs)))
|
|
|
|
(while (and (not real-name) (> base-dirs-count 0))
|
2005-04-19 18:19:43 +00:00
|
|
|
(let* ((full-name (expand-file-name file-name-from-err-msg
|
|
|
|
(nth (1- base-dirs-count) base-dirs))))
|
2004-11-25 16:43:32 +00:00
|
|
|
(if (file-exists-p full-name)
|
|
|
|
(setq real-name full-name))
|
|
|
|
(setq base-dirs-count (1- base-dirs-count))))))
|
|
|
|
real-name))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
(flymake-create-temp-with-folder-structure): Use expand-file-name.
(flymake-delete-temp-directory): Use expand-file-name,
file-name-directory, and directory-file-name.
(flymake-strrchr): Delete.
(flymake-start-syntax-check): Don't pass the redundant buffer argument
to the init-f function.
(flymake-init-find-buildfile-dir, flymake-init-create-temp-buffer-copy)
(flymake-init-create-temp-source-and-master-buffer-copy, flymake-perl-init)
(flymake-save-buffer-in-file, flymake-simple-make-init-impl, flymake-xml-init)
(flymake-simple-make-init, flymake-master-make-init, flymake-master-tex-init)
(flymake-master-make-header-init, flymake-simple-make-java-init)
(flymake-simple-ant-java-init, flymake-simple-tex-init):
Remove corresponding redundant buffer argument.
(flymake-allowed-file-name-masks): Remove last elems that are equal to
the default anyway. Clean up regexps.
2006-01-03 19:59:00 +00:00
|
|
|
(defun flymake-init-find-buildfile-dir (source-file-name buildfile-name)
|
2004-11-25 16:43:32 +00:00
|
|
|
"Find buildfile, store its dir in buffer data and return its dir, if found."
|
2006-01-03 19:05:06 +00:00
|
|
|
(let* ((buildfile-dir
|
|
|
|
(flymake-find-buildfile buildfile-name
|
2006-01-10 04:05:46 +00:00
|
|
|
(file-name-directory source-file-name))))
|
2006-01-03 19:05:06 +00:00
|
|
|
(if buildfile-dir
|
(flymake-create-temp-with-folder-structure): Use expand-file-name.
(flymake-delete-temp-directory): Use expand-file-name,
file-name-directory, and directory-file-name.
(flymake-strrchr): Delete.
(flymake-start-syntax-check): Don't pass the redundant buffer argument
to the init-f function.
(flymake-init-find-buildfile-dir, flymake-init-create-temp-buffer-copy)
(flymake-init-create-temp-source-and-master-buffer-copy, flymake-perl-init)
(flymake-save-buffer-in-file, flymake-simple-make-init-impl, flymake-xml-init)
(flymake-simple-make-init, flymake-master-make-init, flymake-master-tex-init)
(flymake-master-make-header-init, flymake-simple-make-java-init)
(flymake-simple-ant-java-init, flymake-simple-tex-init):
Remove corresponding redundant buffer argument.
(flymake-allowed-file-name-masks): Remove last elems that are equal to
the default anyway. Clean up regexps.
2006-01-03 19:59:00 +00:00
|
|
|
(setq flymake-base-dir buildfile-dir)
|
2006-01-03 19:05:06 +00:00
|
|
|
(flymake-log 1 "no buildfile (%s) for %s" buildfile-name source-file-name)
|
(flymake-create-temp-with-folder-structure): Use expand-file-name.
(flymake-delete-temp-directory): Use expand-file-name,
file-name-directory, and directory-file-name.
(flymake-strrchr): Delete.
(flymake-start-syntax-check): Don't pass the redundant buffer argument
to the init-f function.
(flymake-init-find-buildfile-dir, flymake-init-create-temp-buffer-copy)
(flymake-init-create-temp-source-and-master-buffer-copy, flymake-perl-init)
(flymake-save-buffer-in-file, flymake-simple-make-init-impl, flymake-xml-init)
(flymake-simple-make-init, flymake-master-make-init, flymake-master-tex-init)
(flymake-master-make-header-init, flymake-simple-make-java-init)
(flymake-simple-ant-java-init, flymake-simple-tex-init):
Remove corresponding redundant buffer argument.
(flymake-allowed-file-name-masks): Remove last elems that are equal to
the default anyway. Clean up regexps.
2006-01-03 19:59:00 +00:00
|
|
|
(flymake-report-fatal-status
|
|
|
|
"NOMK" (format "No buildfile (%s) found for %s"
|
|
|
|
buildfile-name source-file-name)))))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2006-01-10 18:46:07 +00:00
|
|
|
(defun flymake-init-create-temp-source-and-master-buffer-copy (get-incl-dirs-f create-temp-f master-file-masks include-regexp)
|
2007-01-29 16:18:04 +00:00
|
|
|
"Find master file (or buffer), create its copy along with a copy of the source file."
|
2006-01-05 18:51:00 +00:00
|
|
|
(let* ((source-file-name buffer-file-name)
|
(flymake-create-temp-with-folder-structure): Use expand-file-name.
(flymake-delete-temp-directory): Use expand-file-name,
file-name-directory, and directory-file-name.
(flymake-strrchr): Delete.
(flymake-start-syntax-check): Don't pass the redundant buffer argument
to the init-f function.
(flymake-init-find-buildfile-dir, flymake-init-create-temp-buffer-copy)
(flymake-init-create-temp-source-and-master-buffer-copy, flymake-perl-init)
(flymake-save-buffer-in-file, flymake-simple-make-init-impl, flymake-xml-init)
(flymake-simple-make-init, flymake-master-make-init, flymake-master-tex-init)
(flymake-master-make-header-init, flymake-simple-make-java-init)
(flymake-simple-ant-java-init, flymake-simple-tex-init):
Remove corresponding redundant buffer argument.
(flymake-allowed-file-name-masks): Remove last elems that are equal to
the default anyway. Clean up regexps.
2006-01-03 19:59:00 +00:00
|
|
|
(temp-source-file-name (flymake-init-create-temp-buffer-copy create-temp-f))
|
2004-11-25 16:43:32 +00:00
|
|
|
(master-and-temp-master (flymake-create-master-file
|
|
|
|
source-file-name temp-source-file-name
|
|
|
|
get-incl-dirs-f create-temp-f
|
2006-01-10 18:46:07 +00:00
|
|
|
master-file-masks include-regexp)))
|
2004-11-25 16:43:32 +00:00
|
|
|
|
|
|
|
(if (not master-and-temp-master)
|
|
|
|
(progn
|
|
|
|
(flymake-log 1 "cannot find master file for %s" source-file-name)
|
(flymake-create-temp-with-folder-structure): Use expand-file-name.
(flymake-delete-temp-directory): Use expand-file-name,
file-name-directory, and directory-file-name.
(flymake-strrchr): Delete.
(flymake-start-syntax-check): Don't pass the redundant buffer argument
to the init-f function.
(flymake-init-find-buildfile-dir, flymake-init-create-temp-buffer-copy)
(flymake-init-create-temp-source-and-master-buffer-copy, flymake-perl-init)
(flymake-save-buffer-in-file, flymake-simple-make-init-impl, flymake-xml-init)
(flymake-simple-make-init, flymake-master-make-init, flymake-master-tex-init)
(flymake-master-make-header-init, flymake-simple-make-java-init)
(flymake-simple-ant-java-init, flymake-simple-tex-init):
Remove corresponding redundant buffer argument.
(flymake-allowed-file-name-masks): Remove last elems that are equal to
the default anyway. Clean up regexps.
2006-01-03 19:59:00 +00:00
|
|
|
(flymake-report-status "!" "") ; NOMASTER
|
2006-01-03 19:05:06 +00:00
|
|
|
nil)
|
(flymake-create-temp-with-folder-structure): Use expand-file-name.
(flymake-delete-temp-directory): Use expand-file-name,
file-name-directory, and directory-file-name.
(flymake-strrchr): Delete.
(flymake-start-syntax-check): Don't pass the redundant buffer argument
to the init-f function.
(flymake-init-find-buildfile-dir, flymake-init-create-temp-buffer-copy)
(flymake-init-create-temp-source-and-master-buffer-copy, flymake-perl-init)
(flymake-save-buffer-in-file, flymake-simple-make-init-impl, flymake-xml-init)
(flymake-simple-make-init, flymake-master-make-init, flymake-master-tex-init)
(flymake-master-make-header-init, flymake-simple-make-java-init)
(flymake-simple-ant-java-init, flymake-simple-tex-init):
Remove corresponding redundant buffer argument.
(flymake-allowed-file-name-masks): Remove last elems that are equal to
the default anyway. Clean up regexps.
2006-01-03 19:59:00 +00:00
|
|
|
(setq flymake-master-file-name (nth 0 master-and-temp-master))
|
|
|
|
(setq flymake-temp-master-file-name (nth 1 master-and-temp-master)))))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2006-01-05 18:51:00 +00:00
|
|
|
(defun flymake-master-cleanup ()
|
|
|
|
(flymake-simple-cleanup)
|
|
|
|
(flymake-safe-delete-file flymake-temp-master-file-name))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
|
|
|
;;;; make-specific init-cleanup routines
|
2004-11-25 16:33:53 +00:00
|
|
|
(defun flymake-get-syntax-check-program-args (source-file-name base-dir use-relative-base-dir use-relative-source get-cmd-line-f)
|
2004-11-25 16:43:32 +00:00
|
|
|
"Create a command line for syntax check using GET-CMD-LINE-F."
|
2006-01-09 19:11:28 +00:00
|
|
|
(funcall get-cmd-line-f
|
|
|
|
(if use-relative-source
|
|
|
|
(file-relative-name source-file-name base-dir)
|
|
|
|
source-file-name)
|
|
|
|
(if use-relative-base-dir
|
|
|
|
(file-relative-name base-dir
|
|
|
|
(file-name-directory source-file-name))
|
|
|
|
base-dir)))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2004-11-25 16:33:53 +00:00
|
|
|
(defun flymake-get-make-cmdline (source base-dir)
|
2004-11-25 16:43:32 +00:00
|
|
|
(list "make"
|
|
|
|
(list "-s"
|
|
|
|
"-C"
|
|
|
|
base-dir
|
|
|
|
(concat "CHK_SOURCES=" source)
|
|
|
|
"SYNTAX_CHECK_MODE=1"
|
|
|
|
"check-syntax")))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2004-11-25 16:33:53 +00:00
|
|
|
(defun flymake-get-ant-cmdline (source base-dir)
|
2004-11-25 16:43:32 +00:00
|
|
|
(list "ant"
|
|
|
|
(list "-buildfile"
|
|
|
|
(concat base-dir "/" "build.xml")
|
|
|
|
(concat "-DCHK_SOURCES=" source)
|
|
|
|
"check-syntax")))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
(flymake-create-temp-with-folder-structure): Use expand-file-name.
(flymake-delete-temp-directory): Use expand-file-name,
file-name-directory, and directory-file-name.
(flymake-strrchr): Delete.
(flymake-start-syntax-check): Don't pass the redundant buffer argument
to the init-f function.
(flymake-init-find-buildfile-dir, flymake-init-create-temp-buffer-copy)
(flymake-init-create-temp-source-and-master-buffer-copy, flymake-perl-init)
(flymake-save-buffer-in-file, flymake-simple-make-init-impl, flymake-xml-init)
(flymake-simple-make-init, flymake-master-make-init, flymake-master-tex-init)
(flymake-master-make-header-init, flymake-simple-make-java-init)
(flymake-simple-ant-java-init, flymake-simple-tex-init):
Remove corresponding redundant buffer argument.
(flymake-allowed-file-name-masks): Remove last elems that are equal to
the default anyway. Clean up regexps.
2006-01-03 19:59:00 +00:00
|
|
|
(defun flymake-simple-make-init-impl (create-temp-f use-relative-base-dir use-relative-source build-file-name get-cmdline-f)
|
2004-11-25 16:43:32 +00:00
|
|
|
"Create syntax check command line for a directly checked source file.
|
2004-11-25 16:33:53 +00:00
|
|
|
Use CREATE-TEMP-F for creating temp copy."
|
2004-11-25 16:43:32 +00:00
|
|
|
(let* ((args nil)
|
(flymake-create-temp-with-folder-structure): Use expand-file-name.
(flymake-delete-temp-directory): Use expand-file-name,
file-name-directory, and directory-file-name.
(flymake-strrchr): Delete.
(flymake-start-syntax-check): Don't pass the redundant buffer argument
to the init-f function.
(flymake-init-find-buildfile-dir, flymake-init-create-temp-buffer-copy)
(flymake-init-create-temp-source-and-master-buffer-copy, flymake-perl-init)
(flymake-save-buffer-in-file, flymake-simple-make-init-impl, flymake-xml-init)
(flymake-simple-make-init, flymake-master-make-init, flymake-master-tex-init)
(flymake-master-make-header-init, flymake-simple-make-java-init)
(flymake-simple-ant-java-init, flymake-simple-tex-init):
Remove corresponding redundant buffer argument.
(flymake-allowed-file-name-masks): Remove last elems that are equal to
the default anyway. Clean up regexps.
2006-01-03 19:59:00 +00:00
|
|
|
(source-file-name buffer-file-name)
|
|
|
|
(buildfile-dir (flymake-init-find-buildfile-dir source-file-name build-file-name)))
|
2004-11-25 16:43:32 +00:00
|
|
|
(if buildfile-dir
|
(flymake-create-temp-with-folder-structure): Use expand-file-name.
(flymake-delete-temp-directory): Use expand-file-name,
file-name-directory, and directory-file-name.
(flymake-strrchr): Delete.
(flymake-start-syntax-check): Don't pass the redundant buffer argument
to the init-f function.
(flymake-init-find-buildfile-dir, flymake-init-create-temp-buffer-copy)
(flymake-init-create-temp-source-and-master-buffer-copy, flymake-perl-init)
(flymake-save-buffer-in-file, flymake-simple-make-init-impl, flymake-xml-init)
(flymake-simple-make-init, flymake-master-make-init, flymake-master-tex-init)
(flymake-master-make-header-init, flymake-simple-make-java-init)
(flymake-simple-ant-java-init, flymake-simple-tex-init):
Remove corresponding redundant buffer argument.
(flymake-allowed-file-name-masks): Remove last elems that are equal to
the default anyway. Clean up regexps.
2006-01-03 19:59:00 +00:00
|
|
|
(let* ((temp-source-file-name (flymake-init-create-temp-buffer-copy create-temp-f)))
|
2004-11-25 16:43:32 +00:00
|
|
|
(setq args (flymake-get-syntax-check-program-args temp-source-file-name buildfile-dir
|
|
|
|
use-relative-base-dir use-relative-source
|
|
|
|
get-cmdline-f))))
|
|
|
|
args))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
(flymake-create-temp-with-folder-structure): Use expand-file-name.
(flymake-delete-temp-directory): Use expand-file-name,
file-name-directory, and directory-file-name.
(flymake-strrchr): Delete.
(flymake-start-syntax-check): Don't pass the redundant buffer argument
to the init-f function.
(flymake-init-find-buildfile-dir, flymake-init-create-temp-buffer-copy)
(flymake-init-create-temp-source-and-master-buffer-copy, flymake-perl-init)
(flymake-save-buffer-in-file, flymake-simple-make-init-impl, flymake-xml-init)
(flymake-simple-make-init, flymake-master-make-init, flymake-master-tex-init)
(flymake-master-make-header-init, flymake-simple-make-java-init)
(flymake-simple-ant-java-init, flymake-simple-tex-init):
Remove corresponding redundant buffer argument.
(flymake-allowed-file-name-masks): Remove last elems that are equal to
the default anyway. Clean up regexps.
2006-01-03 19:59:00 +00:00
|
|
|
(defun flymake-simple-make-init ()
|
|
|
|
(flymake-simple-make-init-impl 'flymake-create-temp-inplace t t "Makefile" 'flymake-get-make-cmdline))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2006-01-10 18:46:07 +00:00
|
|
|
(defun flymake-master-make-init (get-incl-dirs-f master-file-masks include-regexp)
|
2005-03-24 22:42:42 +00:00
|
|
|
"Create make command line for a source file checked via master file compilation."
|
2004-11-25 16:43:32 +00:00
|
|
|
(let* ((make-args nil)
|
|
|
|
(temp-master-file-name (flymake-init-create-temp-source-and-master-buffer-copy
|
(flymake-create-temp-with-folder-structure): Use expand-file-name.
(flymake-delete-temp-directory): Use expand-file-name,
file-name-directory, and directory-file-name.
(flymake-strrchr): Delete.
(flymake-start-syntax-check): Don't pass the redundant buffer argument
to the init-f function.
(flymake-init-find-buildfile-dir, flymake-init-create-temp-buffer-copy)
(flymake-init-create-temp-source-and-master-buffer-copy, flymake-perl-init)
(flymake-save-buffer-in-file, flymake-simple-make-init-impl, flymake-xml-init)
(flymake-simple-make-init, flymake-master-make-init, flymake-master-tex-init)
(flymake-master-make-header-init, flymake-simple-make-java-init)
(flymake-simple-ant-java-init, flymake-simple-tex-init):
Remove corresponding redundant buffer argument.
(flymake-allowed-file-name-masks): Remove last elems that are equal to
the default anyway. Clean up regexps.
2006-01-03 19:59:00 +00:00
|
|
|
get-incl-dirs-f 'flymake-create-temp-inplace
|
2006-01-10 18:46:07 +00:00
|
|
|
master-file-masks include-regexp)))
|
2004-11-25 16:43:32 +00:00
|
|
|
(when temp-master-file-name
|
(flymake-create-temp-with-folder-structure): Use expand-file-name.
(flymake-delete-temp-directory): Use expand-file-name,
file-name-directory, and directory-file-name.
(flymake-strrchr): Delete.
(flymake-start-syntax-check): Don't pass the redundant buffer argument
to the init-f function.
(flymake-init-find-buildfile-dir, flymake-init-create-temp-buffer-copy)
(flymake-init-create-temp-source-and-master-buffer-copy, flymake-perl-init)
(flymake-save-buffer-in-file, flymake-simple-make-init-impl, flymake-xml-init)
(flymake-simple-make-init, flymake-master-make-init, flymake-master-tex-init)
(flymake-master-make-header-init, flymake-simple-make-java-init)
(flymake-simple-ant-java-init, flymake-simple-tex-init):
Remove corresponding redundant buffer argument.
(flymake-allowed-file-name-masks): Remove last elems that are equal to
the default anyway. Clean up regexps.
2006-01-03 19:59:00 +00:00
|
|
|
(let* ((buildfile-dir (flymake-init-find-buildfile-dir temp-master-file-name "Makefile")))
|
2004-11-25 16:43:32 +00:00
|
|
|
(if buildfile-dir
|
|
|
|
(setq make-args (flymake-get-syntax-check-program-args
|
|
|
|
temp-master-file-name buildfile-dir nil nil 'flymake-get-make-cmdline)))))
|
|
|
|
make-args))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2004-11-25 16:33:53 +00:00
|
|
|
(defun flymake-find-make-buildfile (source-dir)
|
2006-01-10 04:05:46 +00:00
|
|
|
(flymake-find-buildfile "Makefile" source-dir))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
|
|
|
;;;; .h/make specific
|
(flymake-create-temp-with-folder-structure): Use expand-file-name.
(flymake-delete-temp-directory): Use expand-file-name,
file-name-directory, and directory-file-name.
(flymake-strrchr): Delete.
(flymake-start-syntax-check): Don't pass the redundant buffer argument
to the init-f function.
(flymake-init-find-buildfile-dir, flymake-init-create-temp-buffer-copy)
(flymake-init-create-temp-source-and-master-buffer-copy, flymake-perl-init)
(flymake-save-buffer-in-file, flymake-simple-make-init-impl, flymake-xml-init)
(flymake-simple-make-init, flymake-master-make-init, flymake-master-tex-init)
(flymake-master-make-header-init, flymake-simple-make-java-init)
(flymake-simple-ant-java-init, flymake-simple-tex-init):
Remove corresponding redundant buffer argument.
(flymake-allowed-file-name-masks): Remove last elems that are equal to
the default anyway. Clean up regexps.
2006-01-03 19:59:00 +00:00
|
|
|
(defun flymake-master-make-header-init ()
|
2010-01-28 19:53:11 +00:00
|
|
|
(flymake-master-make-init
|
|
|
|
'flymake-get-include-dirs
|
|
|
|
'("\\.\\(?:c\\(?:pp\\|xx\\|\\+\\+\\)?\\|CC\\)\\'")
|
|
|
|
"[ \t]*#[ \t]*include[ \t]*\"\\([[:word:]0-9/\\_.]*%s\\)\""))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
|
|
|
;;;; .java/make specific
|
(flymake-create-temp-with-folder-structure): Use expand-file-name.
(flymake-delete-temp-directory): Use expand-file-name,
file-name-directory, and directory-file-name.
(flymake-strrchr): Delete.
(flymake-start-syntax-check): Don't pass the redundant buffer argument
to the init-f function.
(flymake-init-find-buildfile-dir, flymake-init-create-temp-buffer-copy)
(flymake-init-create-temp-source-and-master-buffer-copy, flymake-perl-init)
(flymake-save-buffer-in-file, flymake-simple-make-init-impl, flymake-xml-init)
(flymake-simple-make-init, flymake-master-make-init, flymake-master-tex-init)
(flymake-master-make-header-init, flymake-simple-make-java-init)
(flymake-simple-ant-java-init, flymake-simple-tex-init):
Remove corresponding redundant buffer argument.
(flymake-allowed-file-name-masks): Remove last elems that are equal to
the default anyway. Clean up regexps.
2006-01-03 19:59:00 +00:00
|
|
|
(defun flymake-simple-make-java-init ()
|
|
|
|
(flymake-simple-make-init-impl 'flymake-create-temp-with-folder-structure nil nil "Makefile" 'flymake-get-make-cmdline))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
(flymake-create-temp-with-folder-structure): Use expand-file-name.
(flymake-delete-temp-directory): Use expand-file-name,
file-name-directory, and directory-file-name.
(flymake-strrchr): Delete.
(flymake-start-syntax-check): Don't pass the redundant buffer argument
to the init-f function.
(flymake-init-find-buildfile-dir, flymake-init-create-temp-buffer-copy)
(flymake-init-create-temp-source-and-master-buffer-copy, flymake-perl-init)
(flymake-save-buffer-in-file, flymake-simple-make-init-impl, flymake-xml-init)
(flymake-simple-make-init, flymake-master-make-init, flymake-master-tex-init)
(flymake-master-make-header-init, flymake-simple-make-java-init)
(flymake-simple-ant-java-init, flymake-simple-tex-init):
Remove corresponding redundant buffer argument.
(flymake-allowed-file-name-masks): Remove last elems that are equal to
the default anyway. Clean up regexps.
2006-01-03 19:59:00 +00:00
|
|
|
(defun flymake-simple-ant-java-init ()
|
|
|
|
(flymake-simple-make-init-impl 'flymake-create-temp-with-folder-structure nil nil "build.xml" 'flymake-get-ant-cmdline))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2006-01-05 18:51:00 +00:00
|
|
|
(defun flymake-simple-java-cleanup ()
|
2005-03-24 22:42:42 +00:00
|
|
|
"Cleanup after `flymake-simple-make-java-init' -- delete temp file and dirs."
|
2006-01-05 18:51:00 +00:00
|
|
|
(flymake-safe-delete-file flymake-temp-source-file-name)
|
|
|
|
(when flymake-temp-source-file-name
|
|
|
|
(flymake-delete-temp-directory
|
|
|
|
(file-name-directory flymake-temp-source-file-name))))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
|
|
|
;;;; perl-specific init-cleanup routines
|
(flymake-create-temp-with-folder-structure): Use expand-file-name.
(flymake-delete-temp-directory): Use expand-file-name,
file-name-directory, and directory-file-name.
(flymake-strrchr): Delete.
(flymake-start-syntax-check): Don't pass the redundant buffer argument
to the init-f function.
(flymake-init-find-buildfile-dir, flymake-init-create-temp-buffer-copy)
(flymake-init-create-temp-source-and-master-buffer-copy, flymake-perl-init)
(flymake-save-buffer-in-file, flymake-simple-make-init-impl, flymake-xml-init)
(flymake-simple-make-init, flymake-master-make-init, flymake-master-tex-init)
(flymake-master-make-header-init, flymake-simple-make-java-init)
(flymake-simple-ant-java-init, flymake-simple-tex-init):
Remove corresponding redundant buffer argument.
(flymake-allowed-file-name-masks): Remove last elems that are equal to
the default anyway. Clean up regexps.
2006-01-03 19:59:00 +00:00
|
|
|
(defun flymake-perl-init ()
|
2005-03-25 00:06:07 +00:00
|
|
|
(let* ((temp-file (flymake-init-create-temp-buffer-copy
|
(flymake-create-temp-with-folder-structure): Use expand-file-name.
(flymake-delete-temp-directory): Use expand-file-name,
file-name-directory, and directory-file-name.
(flymake-strrchr): Delete.
(flymake-start-syntax-check): Don't pass the redundant buffer argument
to the init-f function.
(flymake-init-find-buildfile-dir, flymake-init-create-temp-buffer-copy)
(flymake-init-create-temp-source-and-master-buffer-copy, flymake-perl-init)
(flymake-save-buffer-in-file, flymake-simple-make-init-impl, flymake-xml-init)
(flymake-simple-make-init, flymake-master-make-init, flymake-master-tex-init)
(flymake-master-make-header-init, flymake-simple-make-java-init)
(flymake-simple-ant-java-init, flymake-simple-tex-init):
Remove corresponding redundant buffer argument.
(flymake-allowed-file-name-masks): Remove last elems that are equal to
the default anyway. Clean up regexps.
2006-01-03 19:59:00 +00:00
|
|
|
'flymake-create-temp-inplace))
|
2006-01-09 19:11:28 +00:00
|
|
|
(local-file (file-relative-name
|
|
|
|
temp-file
|
|
|
|
(file-name-directory buffer-file-name))))
|
2004-11-25 16:43:32 +00:00
|
|
|
(list "perl" (list "-wc " local-file))))
|
2008-02-13 19:30:58 +00:00
|
|
|
|
|
|
|
;;;; php-specific init-cleanup routines
|
|
|
|
(defun flymake-php-init ()
|
|
|
|
(let* ((temp-file (flymake-init-create-temp-buffer-copy
|
|
|
|
'flymake-create-temp-inplace))
|
|
|
|
(local-file (file-relative-name
|
|
|
|
temp-file
|
|
|
|
(file-name-directory buffer-file-name))))
|
|
|
|
(list "php" (list "-f" local-file "-l"))))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
|
|
|
;;;; tex-specific init-cleanup routines
|
2004-11-25 16:33:53 +00:00
|
|
|
(defun flymake-get-tex-args (file-name)
|
2005-03-24 22:42:42 +00:00
|
|
|
;;(list "latex" (list "-c-style-errors" file-name))
|
2004-11-25 16:43:32 +00:00
|
|
|
(list "texify" (list "--pdf" "--tex-option=-c-style-errors" file-name)))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
(flymake-create-temp-with-folder-structure): Use expand-file-name.
(flymake-delete-temp-directory): Use expand-file-name,
file-name-directory, and directory-file-name.
(flymake-strrchr): Delete.
(flymake-start-syntax-check): Don't pass the redundant buffer argument
to the init-f function.
(flymake-init-find-buildfile-dir, flymake-init-create-temp-buffer-copy)
(flymake-init-create-temp-source-and-master-buffer-copy, flymake-perl-init)
(flymake-save-buffer-in-file, flymake-simple-make-init-impl, flymake-xml-init)
(flymake-simple-make-init, flymake-master-make-init, flymake-master-tex-init)
(flymake-master-make-header-init, flymake-simple-make-java-init)
(flymake-simple-ant-java-init, flymake-simple-tex-init):
Remove corresponding redundant buffer argument.
(flymake-allowed-file-name-masks): Remove last elems that are equal to
the default anyway. Clean up regexps.
2006-01-03 19:59:00 +00:00
|
|
|
(defun flymake-simple-tex-init ()
|
|
|
|
(flymake-get-tex-args (flymake-init-create-temp-buffer-copy 'flymake-create-temp-inplace)))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2010-12-02 17:34:35 +00:00
|
|
|
;; Perhaps there should be a buffer-local variable flymake-master-file
|
|
|
|
;; that people can set to override this stuff. Could inherit from
|
|
|
|
;; the similar AUCTeX variable.
|
(flymake-create-temp-with-folder-structure): Use expand-file-name.
(flymake-delete-temp-directory): Use expand-file-name,
file-name-directory, and directory-file-name.
(flymake-strrchr): Delete.
(flymake-start-syntax-check): Don't pass the redundant buffer argument
to the init-f function.
(flymake-init-find-buildfile-dir, flymake-init-create-temp-buffer-copy)
(flymake-init-create-temp-source-and-master-buffer-copy, flymake-perl-init)
(flymake-save-buffer-in-file, flymake-simple-make-init-impl, flymake-xml-init)
(flymake-simple-make-init, flymake-master-make-init, flymake-master-tex-init)
(flymake-master-make-header-init, flymake-simple-make-java-init)
(flymake-simple-ant-java-init, flymake-simple-tex-init):
Remove corresponding redundant buffer argument.
(flymake-allowed-file-name-masks): Remove last elems that are equal to
the default anyway. Clean up regexps.
2006-01-03 19:59:00 +00:00
|
|
|
(defun flymake-master-tex-init ()
|
2004-11-25 16:43:32 +00:00
|
|
|
(let* ((temp-master-file-name (flymake-init-create-temp-source-and-master-buffer-copy
|
(flymake-create-temp-with-folder-structure): Use expand-file-name.
(flymake-delete-temp-directory): Use expand-file-name,
file-name-directory, and directory-file-name.
(flymake-strrchr): Delete.
(flymake-start-syntax-check): Don't pass the redundant buffer argument
to the init-f function.
(flymake-init-find-buildfile-dir, flymake-init-create-temp-buffer-copy)
(flymake-init-create-temp-source-and-master-buffer-copy, flymake-perl-init)
(flymake-save-buffer-in-file, flymake-simple-make-init-impl, flymake-xml-init)
(flymake-simple-make-init, flymake-master-make-init, flymake-master-tex-init)
(flymake-master-make-header-init, flymake-simple-make-java-init)
(flymake-simple-ant-java-init, flymake-simple-tex-init):
Remove corresponding redundant buffer argument.
(flymake-allowed-file-name-masks): Remove last elems that are equal to
the default anyway. Clean up regexps.
2006-01-03 19:59:00 +00:00
|
|
|
'flymake-get-include-dirs-dot 'flymake-create-temp-inplace
|
|
|
|
'("\\.tex\\'")
|
2010-12-02 17:34:35 +00:00
|
|
|
"[ \t]*\\in\\(?:put\\|clude\\)[ \t]*{\\(.*%s\\)}")))
|
2004-11-25 16:43:32 +00:00
|
|
|
(when temp-master-file-name
|
|
|
|
(flymake-get-tex-args temp-master-file-name))))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
2011-04-22 18:44:26 +00:00
|
|
|
(defun flymake-get-include-dirs-dot (_base-dir)
|
2004-11-25 16:43:32 +00:00
|
|
|
'("."))
|
2004-05-29 12:55:24 +00:00
|
|
|
|
|
|
|
;;;; xml-specific init-cleanup routines
|
(flymake-create-temp-with-folder-structure): Use expand-file-name.
(flymake-delete-temp-directory): Use expand-file-name,
file-name-directory, and directory-file-name.
(flymake-strrchr): Delete.
(flymake-start-syntax-check): Don't pass the redundant buffer argument
to the init-f function.
(flymake-init-find-buildfile-dir, flymake-init-create-temp-buffer-copy)
(flymake-init-create-temp-source-and-master-buffer-copy, flymake-perl-init)
(flymake-save-buffer-in-file, flymake-simple-make-init-impl, flymake-xml-init)
(flymake-simple-make-init, flymake-master-make-init, flymake-master-tex-init)
(flymake-master-make-header-init, flymake-simple-make-java-init)
(flymake-simple-ant-java-init, flymake-simple-tex-init):
Remove corresponding redundant buffer argument.
(flymake-allowed-file-name-masks): Remove last elems that are equal to
the default anyway. Clean up regexps.
2006-01-03 19:59:00 +00:00
|
|
|
(defun flymake-xml-init ()
|
|
|
|
(list "xml" (list "val" (flymake-init-create-temp-buffer-copy 'flymake-create-temp-inplace))))
|
2004-11-25 16:33:53 +00:00
|
|
|
|
|
|
|
(provide 'flymake)
|
2004-05-29 12:55:24 +00:00
|
|
|
|
|
|
|
;;; flymake.el ends here
|