flymake-mode

flymake-mode

emacsでリアルタイムに構文チェックを行う方法(flymake)
http://d.hatena.ne.jp/pyopyopyo/20070715/p1
Flymake を使って編集中にシンタックスエラーを検出する
http://dev.ariel-networks.com/Members/matsuyama/detect-syntax-errors-by-flymake

これは便利。デフォルトでは色が見にくいので以下を追加。

(custom-set-faces
'(flymake-errline ((((class color)) (:background "green1"))))
'(flymake-warnline ((((class color)) (:background "green4")))))


ついでに現在の .emacs を貼っておく。

;; Deleteキーでカーソル位置の文字が消えるようにする
(global-set-key [delete] 'delete-char)

(require 'cc-mode)

;; Kernighan & Ritchie スタイルにする
(setq c-default-style "k&r")

;; BackSpace キーを「賢く」し、インデント幅は4桁
(add-hook 'c-mode-common-hook
'(lambda ()
(progn
(c-toggle-hungry-state 1)
;; TAB を SPACE に展開する
;(setq c-basic-offset 4 indent-tabs-mode nil)
;; TAB に TAB を使う
;; (setq c-basic-offset 4 indent-tabs-mode t)
(setq c-basic-offset 8 indent-tabs-mode t)
)
)
)

;; タブ長の設定
(setq tab-width 4)
;;(setq tab-width 8)

;; コンパイルコマンドの設定
(setq compile-command "make")
;; コンパイルコマンドのヒストリ
(setq compile-history (list "make" "make clean"))

;; M-x compile RET を C-c c キーで行う。
(add-hook 'c-mode-hook
(lambda () (define-key c-mode-map "\C-cc" 'compile)))

;; M-x compile RET を C-c c キーで行う。
(add-hook 'c++-mode-hook
(lambda () (define-key c++-mode-map "\C-cc" 'compile)))




;;; C-h と Del の入れ替え
(global-set-key "\C-h" 'delete-backward-char)
(global-set-key "\C-xh" 'help-command) ; override mark-whole-buffer


;; uim-el の設定
(setq load-path
(append
(list (expand-file-name "/usr/local/emacs22.1/share/emacs/site-lisp/uim-el")) load-path))
(require 'uim)
(global-set-key "\C-o" 'uim-mode)

;; anthy
;(setq load-path
; (append
; (list (expand-file-name "/usr/local/emacs22.1/share/emacs/site-lisp/anthy")) load-path))
;(load "anthy")

;; w3m の設定
(setq load-path
(append
(list (expand-file-name "/usr/local/emacs22.1/share/emacs/site-lisp/w3m")) load-path))
(load "w3m")


;;色を付ける
(global-font-lock-mode t)

;;初期フレームの設定
(setq default-frame-alist
(append
'(
(foreground-color . "white") ; 前景色
(background-color . "gray19") ; 背景色
(cursor-color . "white") ; カーソル色
(width . 90) ; フレーム幅(文字数)
(height . 54) ; フレーム高(文字数)
(top . 25) ; フレームの Y 位置(ピクセル数)
(left . 10) ; フレームの X 位置(ピクセル数)
)
default-frame-alist))

;;色の設定
(set-face-foreground 'font-lock-comment-face "darkolivegreen3")
(set-face-foreground 'font-lock-string-face "coral")
(set-face-foreground 'font-lock-keyword-face "violet")
(set-face-foreground 'font-lock-function-name-face "white")
(set-face-foreground 'font-lock-variable-name-face "white")
(set-face-foreground 'font-lock-type-face "skyblue1")
(set-face-foreground 'font-lock-warning-face "yellow")
(set-face-foreground 'font-lock-builtin-face "goldenrod")
(set-face-background 'highlight "yellow")
(set-face-foreground 'highlight "black")
(set-face-background 'region "lightgoldenrod2")
(set-face-foreground 'region "black")
(set-face-foreground 'modeline "skyblue1")
(set-face-background 'modeline "grey15")

;; キーボードで指定したリージョンに色を付ける
(setq transient-mark-mode t)

;; タブ、、改行前のスペース、全角スペースを表示する
;;(defface my-face-r-1 '*1
(font-lock-add-keywords
major-mode
'*2 (:background "green1"))))
'(flymake-warnline ((((class color)) (:background "green4")))))


ここまで

*1:t (:background "gray80"))) nil)
;;全角スペース
(defface my-face-b-1 '((t (:background "gray50"))) nil)
;;tab
(defface my-face-b-2 '((t (:background "gray25"))) nil)
;;半角スペース
(defface my-face-u-1 '((t (:foreground "SteelBlue" :underline t))) nil)
(defvar my-face-r-1 'my-face-r-1)
(defvar my-face-b-1 'my-face-b-1)
(defvar my-face-b-2 'my-face-b-2)
(defvar my-face-u-1 'my-face-u-1)

(defadvice font-lock-mode (before my-font-lock-mode (

*2:"\t" 0 my-face-b-2 append)
(" " 0 my-face-b-1 append)
("[ \t]+$" 0 my-face-u-1 append)
;; ("[\r]*\n" 0 my-face-r-1 append)
)))
(ad-enable-advice 'font-lock-mode 'before 'my-font-lock-mode)
(ad-activate 'font-lock-mode)

;;時刻の表示
(display-time)

;;桁番号の表示
(column-number-mode t)

;;スクロールバーを右に表示
(set-scroll-bar-mode 'right)

;;ツールバーを消す
(tool-bar-mode nil)

;;flymake-mode
(require 'flymake)
(defun flymake-get-make-cmdline (source base-dir)
(list "make"
(list "-s" "-C"
base-dir
(concat "CHK_SOURCES=" source)
"SYNTAX_CHECK_MODE=1")))
(custom-set-faces
'(flymake-errline ((((class color