]> git.rkrishnan.org Git - .emacs.d.git/blob - emacs/nxhtml/related/flymake-java-1.el
submodulized .emacs.d setup
[.emacs.d.git] / emacs / nxhtml / related / flymake-java-1.el
1 ;;; flymake-java-1.el --- Flymake for single java files
2 ;;
3 ;; Author: Lennart Borgman (lennart O borgman A gmail O com)
4 ;; Created: 2009-12-02 Wed
5 ;; Version:
6 ;; Last-Updated:
7 ;; URL:
8 ;; Keywords:
9 ;; Compatibility:
10 ;;
11 ;; Features that might be required by this library:
12 ;;
13 ;;   None
14 ;;
15 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
16 ;;
17 ;;; Commentary:
18 ;;
19 ;;
20 ;;
21 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
22 ;;
23 ;;; Change log:
24 ;;
25 ;;
26 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
27 ;;
28 ;; This program is free software; you can redistribute it and/or
29 ;; modify it under the terms of the GNU General Public License as
30 ;; published by the Free Software Foundation; either version 3, or
31 ;; (at your option) any later version.
32 ;;
33 ;; This program is distributed in the hope that it will be useful,
34 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
35 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
36 ;; General Public License for more details.
37 ;;
38 ;; You should have received a copy of the GNU General Public License
39 ;; along with this program; see the file COPYING.  If not, write to
40 ;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth
41 ;; Floor, Boston, MA 02110-1301, USA.
42 ;;
43 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
44 ;;
45 ;;; Code:
46
47 (eval-and-compile (require 'flymake))
48
49 (defun flymake-init-maybe-find-buildfile-dir (source-file-name buildfile-name)
50   "Find buildfile, store its dir in buffer data and return its dir, if found."
51   (let* ((buildfile-dir
52           (flymake-find-buildfile buildfile-name
53                                   (file-name-directory source-file-name))))
54     (if buildfile-dir
55         (setq flymake-base-dir buildfile-dir)
56       (flymake-log 1 "no buildfile (%s) for %s" buildfile-name source-file-name)
57       nil)))
58
59 (defun flymake-complex-make-init-impl-1 (create-temp-f use-relative-base-dir use-relative-source build-file-name get-cmdline-f)
60   "Create syntax check command line for a directly checked source file.
61 Use CREATE-TEMP-F for creating temp copy."
62   (let* ((args nil)
63          (source-file-name   buffer-file-name)
64          (buildfile-dir      (flymake-init-maybe-find-buildfile-dir source-file-name build-file-name)))
65     (if buildfile-dir
66         (let* ((temp-source-file-name  (flymake-init-create-temp-buffer-copy create-temp-f)))
67           (setq args (flymake-get-syntax-check-program-args temp-source-file-name buildfile-dir
68                                                             use-relative-base-dir use-relative-source
69                                                             get-cmdline-f))))
70     args))
71
72 (defun flymake-complex-java-init ()
73   (or (flymake-complex-make-init-impl-1 'flymake-create-temp-with-folder-structure nil nil "Makefile" 'flymake-get-make-cmdline)
74       (flymake-complex-make-init-impl-1 'flymake-create-temp-with-folder-structure nil nil "build.xml" 'flymake-get-make-cmdline)
75       (flymake-java-1-init)))
76
77 (defcustom flymake-java-1-javac "c:/Sun/SDK/jdk/bin/javac.exe"
78   "Path to javac."
79   :group 'flymake)
80
81 (defun flymake-java-1-init ()
82   (if (not (executable-find flymake-java-1-javac))
83       (message "Can't find javac. Please customize flymake-java-1-javac")
84     (list flymake-java-1-javac
85           (list (flymake-init-create-temp-buffer-copy
86                  'flymake-create-temp-with-folder-structure)))))
87
88 ;; (defun flymake-java-1-turn-on ()
89 ;;   (interactive)
90 ;;   (if (not (executable-find flymake-java-1-javac))
91 ;;       (message "Can't find javac. Please customize flymake-java-1-javac")
92 ;;     (let ((flymake-allowed-file-name-masks
93 ;;            '(("\\.java\\'" flymake-java-1-init flymake-simple-cleanup))))
94 ;;       (when flymake-mode (flymake-mode -1))
95 ;;       (flymake-mode 1))))
96
97 ;;;###autoload
98 (defun flymake-java-1-load ()
99   (let ((jrec (assoc "\\.java\\'" flymake-allowed-file-name-masks)))
100     (setq flymake-allowed-file-name-masks
101           (delete jrec flymake-allowed-file-name-masks))
102     (setq flymake-allowed-file-name-masks
103           (cons
104            '("\\.java\\'" flymake-complex-java-init flymake-simple-java-cleanup)
105            flymake-allowed-file-name-masks))))
106
107 (provide 'flymake-java-1)
108 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
109 ;;; flymake-java-1.el ends here