My favorites | Sign in
dea
Project Home Downloads Wiki Issues Source
Checkout   Browse   Changes    
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
;; Copyright (C) 2010 ahei

;; Author: ahei <ahei0802@gmail.com>
;; URL: http://code.google.com/p/dea/source/browse/trunk/my-lisps/flymake-settings.el
;; Time-stamp: <2011-03-20 17:49:31 Sunday by taoshanwen>

;; This file is free software; you can redistribute it and/or
;; modify it under the terms of the GNU General Public License as
;; published by the Free Software Foundation; either version 3,
;; or (at your option) any later version.

;; This file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public
;; License along with GNU Emacs; see the file COPYING. If not,
;; write to the Free Software Foundation, Inc., 51 Franklin
;; Street, Fifth Floor, Boston, MA 02110-1301, USA.

(defvar flymake-mode-map (make-sparse-keymap))

(autoload 'flymake-find-file-hook "flymake" "" t)

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

(defun flymake-settings ()
"Settings for `flymake'."
(setq flymake-gui-warnings-enabled nil)

(defvar flymake-makefile-filenames '("Makefile" "makefile" "GNUmakefile") "File names for make.")

(defun flymake-get-make-gcc-cmdline (source base-dir)
(let (found)
(dolist (makefile flymake-makefile-filenames)
(if (file-readable-p (concat base-dir "/" makefile))
(setq found t)))
(if found
(list "make"
(list "-s"
"-C"
base-dir
(concat "CHK_SOURCES=" source)
"SYNTAX_CHECK_MODE=1"
"check-syntax"))
(list (if (string= (file-name-extension source) "c") "gcc" "g++")
(list "-o"
"/dev/null"
"-fsyntax-only"
"-Wall"
source)))))

(defun flymake-simple-make-gcc-init-impl (create-temp-f use-relative-base-dir use-relative-source build-file-name get-cmdline-f)
"Create syntax check command line for a directly checked source file.
Use CREATE-TEMP-F for creating temp copy."
(let* ((args nil)
(source-file-name buffer-file-name)
(buildfile-dir (file-name-directory source-file-name)))
(if buildfile-dir
(let* ((temp-source-file-name (flymake-init-create-temp-buffer-copy create-temp-f)))
(setq args
(flymake-get-syntax-check-program-args
temp-source-file-name
buildfile-dir
use-relative-base-dir
use-relative-source
get-cmdline-f))))
args))

(defun flymake-simple-make-gcc-init ()
(flymake-simple-make-gcc-init-impl 'flymake-create-temp-inplace t t "Makefile" 'flymake-get-make-gcc-cmdline))

(setq flymake-allowed-file-name-masks
'(("\\.\\(?:c\\(?:pp\\|xx\\|\\+\\+\\)?\\|CC\\)\\'" flymake-simple-make-gcc-init)
("\\.xml\\'" flymake-xml-init)
("\\.html?\\'" flymake-xml-init)
("\\.cs\\'" flymake-simple-make-init)
("\\.p[ml]\\'" flymake-perl-init)
("\\.php[345]?\\'" flymake-php-init)
("\\.h\\'" flymake-master-make-header-init flymake-master-cleanup)
("\\.java\\'" flymake-simple-make-java-init flymake-simple-java-cleanup)
("[0-9]+\\.tex\\'" flymake-master-tex-init flymake-master-cleanup)
("\\.tex\\'" flymake-simple-tex-init)
("\\.idl\\'" flymake-simple-make-init)))

(defun flymake-display-current-warning/error ()
"Display warning/error under cursor."
(interactive)
(let ((ovs (overlays-in (point) (1+ (point)))))
(dolist (ov ovs)
(catch 'found
(when (flymake-overlay-p ov)
(message (overlay-get ov 'help-echo))
(throw 'found t))))))

(defun flymake-goto-next-error-disp ()
"Go to next error in err ring, and then display warning/error."
(interactive)
(flymake-goto-next-error)
(flymake-display-current-warning/error))

(defun flymake-goto-prev-error-disp ()
"Go to previous error in err ring, and then display warning/error."
(interactive)
(flymake-goto-prev-error)
(flymake-display-current-warning/error))

(defun flymake-settings-4-emaci ()
"`flymake' settings for `emaci'."
(emaci-add-key-definition
"z" 'flymake-display-current-warning/error
'(memq major-mode dev-modes)))

(eval-after-load "emaci"
`(flymake-settings-4-emaci)))

(eval-after-load "flymake"
`(flymake-settings))

(eal-define-keys
'flymake-mode-map
`(("C-c N" flymake-goto-next-error-disp)
("C-c P" flymake-goto-prev-error-disp)
("C-c M-w" flymake-display-current-warning/error)))

(provide 'flymake-settings)

Change log

r1386 by taoshanwen on Mar 25, 2011   Diff
Small changes.
Go to: 
Project members, sign in to write a code review

Older revisions

r1343 by taoshanwen on Nov 25, 2010   Diff
Small changes.
r1303 by ahei on Sep 25, 2010   Diff
Add emaci key definition for flymake.
r1302 by ahei on Sep 24, 2010   Diff
Add settings for flymake.
All revisions of this file

File info

Size: 4897 bytes, 127 lines
Powered by Google Project Hosting