ȥå   Խ ʬ Хåå ź ʣ ̾ѹ   ñ측 ǽ   إ   ǽRSS

С/y-takata/Flymake

Last-modified: 2011-06-27 () 14:23:30 (2360d)
Top / С / y-takata / Flymake

Flymake

GNU Flymake -- an on-the-fly syntax checker for Emacs

ä⡥ʤΤɸźդäȤϡġ

ץ

(1) ԽоݥեƱǥ쥯ȥˡcheck-syntaxȤåȤMakefile֤MakefileȤʤϸҡˡ

ʲJavaξ硧

.PHONY: check-syntax
check-syntax:
	javac -J-Dfile.encoding=utf-8 $(CHK_SOURCES)

file.encodingϥ顼åUTF-8ǽϤ뤿˻ѡ

(2) .emacsʤޤ .emacs.d/init.elˤ˰ʲɲá

(require 'flymake)
(add-hook 'find-file-hook 'flymake-find-file-hook)

.javaե򳫤мưŪflymake-modeˤʤ롥

顼սˤϿդޥäƤȥ顼åݥåץåɽ롥

CξMakefile򲼵Τ褦ˤФ褤

.PHONY: check-syntax
check-syntax:
	$(CC) -W -Wall -pedantic -fsyntax-only $(CHK_SOURCES)

JavaCƱǥ쥯ȥ˺ߤϡMakefileפƤʤȤ롥

  • Mac OS X 10.4 + CarbonEmacs 2007-06 Ȥ߹碌ȡޤ Flymake Configuration Error ȤФơflymake-modeդˤʤ롥M-x flymake-mode ưǼ¹Ԥв롥

θоݤˤ

嵭Τ褦

(add-hook 'find-file-hook 'flymake-find-file-hook)

ȵҤȡͽꤵƤĥ(c, cpp, xml, html, pl, java, tex, ...)Υե뤬٤flymakeоݤˤʤ롥

θΥեΤоݤˤϰʲΤ褦˽񤯡

(add-hook 'c-mode-hook '(lambda () (flymake-mode t)))
(add-hook 'java-mode-hook '(lambda () (flymake-mode t)))

MakefileȤʤ

.emacsʤޤ.emacs.d/init.elˤǰʲΤ褦ꤹСmakeȤ鷺ľgccjavacȤ褦ˤʤ롥

(require 'flymake)
(defun flymake-c-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 "gcc" (list "-Wall" "-W" "-pedantic" "-fsyntax-only" local-file))))
(push '("\\.c$" flymake-c-init) flymake-allowed-file-name-masks)
(add-hook 'c-mode-hook '(lambda () (flymake-mode t)))

嵭ȡ.hե򳫤Ȥflymake-modeˤʤäƤޤMakefileʤפܤ롥ʾöŪ˺ǸιԤʲΤ褦Ѥ .h եФƤflymake-modeˤʤʤ

(add-hook 'c-mode-hook '(lambda () (if (string-match "\\.c$" buffer-file-name)
                               (flymake-mode t))))

Javaξ

-encodingβսϤäȤޤä褤⡥

ɵȥե뤬¸ߤʤȤʿե򳫤Ȥˤ˥顼ˤʤäflymake-modeդˤʤ뤳ȤȽɤľФ褤Ϲͤġ

(require 'flymake)
(defun flymake-java-init ()
  (flymake-simple-make-init-impl
   'flymake-create-temp-with-folder-structure nil nil
   buffer-file-name
   'flymake-get-java-cmdline))
(defun flymake-get-java-cmdline (source base-dir)
  (list "javac" (list "-J-Dfile.encoding=utf-8" "-encoding" "utf-8"
              source)))
(push '("\\.java$" flymake-java-init) flymake-allowed-file-name-masks)
(add-hook 'java-mode-hook '(lambda () (flymake-mode t)))

͡