flymakeã§scalaã®ææ³ããªã¢ã«ã¿ã¤ã ã«ãã§ãã¯ãã
前回ã®ã¯ãã¾ãã§ãããããã£ãã®ã¯ããããã£ã¡ã
flymakeãããããªã人ã¯こちらãåç §ã
(eval-when-compile (require 'cl)) (require 'flymake) (defvar flymake-scala-tmpdir "/tmp") (defvar flymake-scala-global-classpath ".") (push '(".+\\.scala$" flymake-scala-init) flymake-allowed-file-name-masks) (push '("^\\(.*\\):\\([0-9]+\\): error: \\(.*\\)$" 1 2 nil 3) flymake-err-line-patterns) (defun flymake-scala-string-join (sequence separator) (mapconcat #'identity sequence separator)) (defun flymake-scala-string-not-empty (str) (and (stringp str) (not (or (string-equal "" str) (string-match "^ +$" str))))) (defun flymake-scala-parent-dir (path) "return parent directory path of argument." (substring-no-properties (file-name-directory path) 0 -1)) (defun flymake-scala-find-target-file-dir (path target) (let* ((src (split-string (flymake-scala-parent-dir path) "/")) (paths (maplist #'(lambda (l) (flymake-scala-string-join (reverse l) "/")) (nreverse src)))) (loop for path in paths if (file-exists-p (concat path "/" target)) return path))) (defun flymake-scala-maven-build-cmd () (list "mvn" (list "-fn" "-Dmaven.compiler.showWarnings=true" "dependency:copy-dependencies" "scala:compile"))) (defun flymake-scala-build-cmd (target distdir classpath) (list "fsc" (list "-classpath" classpath "-d" distdir target))) (defun flymake-scala-init () (let ((dir (flymake-scala-find-target-file-dir buffer-file-name "pom.xml"))) (if (flymake-scala-string-not-empty dir) (progn (cd dir) (let ((distdir (loop for path in '("target" "build") if (file-exists-p path) return path))) (if (flymake-scala-string-not-empty distdir) (let* ((classes (concat distdir "/classes")) (dependency (concat distdir "/dependency")) (jars (directory-files dependency t "^[^\.]")) (classpath (flymake-scala-string-join (append (cons classes jars) flymake-scala-global-classpath) ":"))) (flymake-scala-build-cmd buffer-file-name classes classpath)) (flymake-scala-maven-build-cmd)))) (flymake-scala-build-cmd buffer-file-name flymake-scala-tmpdir flymake-scala-global-classpath)))) (defun flymake-scala-start-fsc-server () (with-temp-buffer (call-process-shell-command "fsc" nil nil))) (defun flymake-scala-maven-update () (interactive) (let ((dir (flymake-scala-find-target-file-dir buffer-file-name "pom.xml"))) (if (flymake-scala-string-not-empty dir) (progn (cd dir) (let* ((cmd (flymake-scala-maven-build-cmd)) (progname (car cmd)) (args (cadr cmd)) (buffname (format "*%s*" progname)) (buffer (get-buffer-create buffname))) (switch-to-buffer-other-window buffer) (start-process-shell-command progname buffer progname (flymake-scala-string-join args " ")))) (message "No pom.xml found")))) (add-hook 'scala-mode-hook (lambda () (flymake-scala-start-fsc-server) (flymake-mode-on)))
maven2ã®ããã¸ã§ã¯ãã«ãå°å³ã«å¯¾å¿ã
pom.xmlãå帰çã«æ¢ãã¦åå¨ããå ´åã¯mvn scala:compileãã
ç¡ãå ´åã¯fscãflymakeã§å®è¡ããã¨ãã¾ãã
â åèã«ãããµã¤ã
2009/10/04 18:00
mvnã³ãã³ãã®å®è¡ãé
ãã®ã§ãäºåç®ä»¥éã¯fscã使ãããã«ä¿®æ£ã
å¾ããjarãªã©ã追å ããå ´åã¯ã
ãå®è¡ãã¦ãã ããã
2009/10/10 21:00
rails.elã®é¢æ°ãåç §ãã¦ãã¾ã£ã¦ããã®ãä¿®æ£