X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/67ab0163d67fbfeb41c37c8a259f27eeef965520..4fd9655790324ce4b0a321ddae45e98af3953fe1:/lisp/progmodes/flymake.el diff --git a/lisp/progmodes/flymake.el b/lisp/progmodes/flymake.el index 4461ec2745..07393c6954 100644 --- a/lisp/progmodes/flymake.el +++ b/lisp/progmodes/flymake.el @@ -1,6 +1,6 @@ ;;; flymake.el -- a universal on-the-fly syntax checker -;; Copyright (C) 2003-2011 Free Software Foundation, Inc. +;; Copyright (C) 2003-2012 Free Software Foundation, Inc. ;; Author: Pavel Kobyakov ;; Maintainer: Pavel Kobyakov @@ -596,7 +596,7 @@ It's flymake process filter." (with-current-buffer source-buffer (flymake-parse-output-and-residual output))))) -(defun flymake-process-sentinel (process event) +(defun flymake-process-sentinel (process _event) "Sentinel for syntax check buffers." (when (memq (process-status process) '(signal exit)) (let* ((exit-status (process-exit-status process)) @@ -924,8 +924,8 @@ Convert it to flymake internal format." ;; PHP ("\\(?:Parse\\|Fatal\\) error: \\(.*\\) in \\(.*\\) on line \\([0-9]+\\)" 2 3 nil 1) ;; LaTeX warnings (fileless) ("\\(LaTeX \\(Warning\\|Error\\): .*\\) on input line \\([0-9]+\\)" 20 3 nil 1) - ;; ant/javac - (" *\\(\\[javac\\] *\\)?\\(\\([a-zA-Z]:\\)?[^:(\t\n]+\\)\:\\([0-9]+\\)\:[ \t\n]*\\(.+\\)" + ;; ant/javac. Note this also matches gcc warnings! + (" *\\(\\[javac\\] *\\)?\\(\\([a-zA-Z]:\\)?[^:(\t\n]+\\)\:\\([0-9]+\\)\\(?:\:[0-9]+\\)?\:[ \t\n]*\\(.+\\)" 2 4 nil 5)) ;; compilation-error-regexp-alist) (flymake-reformat-err-line-patterns-from-compile-el compilation-error-regexp-alist-alist)) @@ -1110,7 +1110,7 @@ For the format of LINE-ERR-INFO, see `flymake-ler-make-ler'." (flymake-log 1 "deleted file %s" file-name))) (defun flymake-safe-delete-directory (dir-name) - (condition-case err + (condition-case nil (progn (delete-directory dir-name) (flymake-log 1 "deleted dir %s" dir-name)) @@ -1118,7 +1118,7 @@ For the format of LINE-ERR-INFO, see `flymake-ler-make-ler'." (flymake-log 1 "Failed to delete dir %s, error ignored" dir-name)))) (defcustom flymake-compilation-prevents-syntax-check t - "If non-nil, syntax check won't be started in case compilation is running." + "If non-nil, don't start syntax check if compilation is running." :group 'flymake :type 'boolean) @@ -1152,35 +1152,34 @@ For the format of LINE-ERR-INFO, see `flymake-ler-make-ler'." (defun flymake-start-syntax-check-process (cmd args dir) "Start syntax check process." - (let* ((process nil)) - (condition-case err - (progn - (when dir - (let ((default-directory dir)) - (flymake-log 3 "starting process on dir %s" default-directory))) - (setq process (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)))))) + (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))))) (defun flymake-kill-process (proc) "Kill process PROC." @@ -1332,16 +1331,21 @@ For the format of LINE-ERR-INFO, see `flymake-ler-make-ler'." ;;;###autoload (define-minor-mode flymake-mode - "Minor mode to do on-the-fly syntax checking. -When called interactively, toggles the minor mode. -With arg, turn Flymake mode on if and only if arg is positive." + "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." :group 'flymake :lighter flymake-mode-line (cond ;; Turning the mode ON. (flymake-mode - (if (not (flymake-can-syntax-check-file buffer-file-name)) - (flymake-log 2 "flymake cannot check syntax in buffer %s" (buffer-name)) + (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 (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) @@ -1353,7 +1357,7 @@ With arg, turn Flymake mode on if and only if arg is positive." (run-at-time nil 1 'flymake-on-timer-event (current-buffer))) (when flymake-start-syntax-check-on-find-file - (flymake-start-syntax-check)))) + (flymake-start-syntax-check))))) ;; Turning the mode OFF. (t @@ -1387,7 +1391,7 @@ With arg, turn Flymake mode on if and only if arg is positive." :group 'flymake :type 'boolean) -(defun flymake-after-change-function (start stop len) +(defun flymake-after-change-function (start stop _len) "Start syntax check for current buffer if it isn't already running." ;;+(flymake-log 0 "setting change time to %s" (flymake-float-time)) (let((new-text (buffer-substring start stop))) @@ -1407,6 +1411,7 @@ With arg, turn Flymake mode on if and only if arg is positive." (cancel-timer flymake-timer) (setq flymake-timer nil))) +;;;###autoload (defun flymake-find-file-hook () ;;+(when flymake-start-syntax-check-on-find-file ;;+ (flymake-log 3 "starting syntax check on file open") @@ -1497,7 +1502,7 @@ With arg, turn Flymake mode on if and only if arg is positive." (flymake-log 3 "create-temp-inplace: file=%s temp=%s" file-name temp-name) temp-name)) -(defun flymake-create-temp-with-folder-structure (file-name prefix) +(defun flymake-create-temp-with-folder-structure (file-name _prefix) (unless (stringp file-name) (error "Invalid file-name")) @@ -1764,7 +1769,7 @@ Use CREATE-TEMP-F for creating temp copy." (when temp-master-file-name (flymake-get-tex-args temp-master-file-name)))) -(defun flymake-get-include-dirs-dot (base-dir) +(defun flymake-get-include-dirs-dot (_base-dir) '(".")) ;;;; xml-specific init-cleanup routines