-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathflymake-google-cpplint.el
More file actions
153 lines (122 loc) · 5.57 KB
/
flymake-google-cpplint.el
File metadata and controls
153 lines (122 loc) · 5.57 KB
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
;;; flymake-google-cpplint.el --- Help to comply with the Google C++ Style Guide
;; Copyright 2014 Akiha Senda
;; Author: Akiha Senda <senda.akiha@gmail.com>
;; URL: https://github.com/senda-akiha/flymake-google-cpplint/
;; Created: 02 February 2014
;; Version: 1.0.0
;; Keywords: flymake, C, C++
;; Package-Requires: ((flymake-easy "0.9"))
;; This file is not part of GNU Emacs.
;; However, it is distributed under the same license.
;; GNU Emacs 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.
;; GNU Emacs 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.
;;; Commentary:
;; If you're want to write code according to the [Google C++ Style Guide](http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml), this will help a great deal.
;; I recommend that the package [google-c-style](http://melpa.milkbox.net/#/google-c-style) also installed with.
;; For more infomations, please check the GitHub
;; https://github.com/senda-akiha/flymake-google-cpplint/
;;; Code:
(require 'flymake-easy)
(defconst flymake-google-cpplint-err-line-patterns
'(("\\(.*\\):\\([[:digit:]]+\\): *\\(.*\\)\r?\n"
1 2 nil 3)))
(defcustom flymake-google-cpplint-verbose ""
"verbose=#
Specify a number 0-5 to restrict errors to certain verbosity levels."
:type 'string
:group 'flymake-google-cpplint)
(defcustom flymake-google-cpplint-filter ""
"filter=-x,+y,...
Specify a comma-separated list of category-filters to apply: only
error messages whose category names pass the filters will be printed.
(Category names are printed with the message and look like
\"[whitespace/indent]\".) Filters are evaluated left to right.
\"-FOO\" and \"FOO\" means \"do not print categories that start with FOO\".
\"+FOO\" means \"do print categories that start with FOO\".
Examples: --filter=-whitespace,+whitespace/braces
--filter=whitespace,runtime/printf,+runtime/printf_format
--filter=-,+build/include_what_you_use
To see a list of all the categories used in cpplint, pass no arg:
--filter="
:type 'string
:group 'flymake-google-cpplint)
(defcustom flymake-google-cpplint-counting ""
"counting=total|toplevel|detailed
The total number of errors found is always printed. If
'toplevel' is provided, then the count of errors in each of
the top-level categories like 'build' and 'whitespace' will
also be printed. If 'detailed' is provided, then a count
is provided for each category like 'build/class'."
:type 'string
:group 'flymake-google-cpplint)
(defcustom flymake-google-cpplint-root ""
"root=subdir
The root directory used for deriving header guard CPP variable.
By default, the header guard CPP variable is calculated as the relative
path to the directory that contains .git, .hg, or .svn. When this flag
is specified, the relative path is calculated from the specified
directory. If the specified directory does not exist, this flag is
ignored.
Examples:
Assuing that src/.git exists, the header guard CPP variables for
src/chrome/browser/ui/browser.h are:
No flag => CHROME_BROWSER_UI_BROWSER_H_
--root=chrome => BROWSER_UI_BROWSER_H_
--root=chrome/browser => UI_BROWSER_H_"
:type 'string
:group 'flymake-google-cpplint)
(defcustom flymake-google-cpplint-linelength ""
"linelength=digits
This is the allowed line length for the project. The default value is
80 characters.
Examples:
--linelength=120"
:type 'string
:group 'flymake-google-cpplint)
(defcustom flymake-google-cpplint-extensions ""
"extensions=extension,extension,...
The allowed file extensions that cpplint will check
Examples:
--extensions=hpp,cpp"
:type 'string
:group 'flymake-google-cpplint)
(defcustom flymake-google-cpplint-command (executable-find "cpplint.py")
"The name of the cpplint executable."
:type 'string
:group 'flymake-google-cpplint)
(defcustom flymake-google-cpplint-location 'inplace
"Where to create the temporary copy: one of 'tempdir or 'inplace (default)."
:type `(choice
(const :tag "In place" inplace)
(const :tag "Temporary location" tempdir))
:group 'flymake-google-cpplint)
(defun flymake-google-cpplint-build-command-line (filename)
"Construct a command that flymake can use to check C/C++ source."
(list flymake-google-cpplint-command
flymake-google-cpplint-verbose
flymake-google-cpplint-filter
flymake-google-cpplint-counting
flymake-google-cpplint-root
flymake-google-cpplint-linelength
flymake-google-cpplint-extensions
filename))
;;;###autoload
(defun flymake-google-cpplint-load ()
"Configure flymake mode to check the current buffer's C/C++ source."
(interactive)
(flymake-easy-load 'flymake-google-cpplint-build-command-line
flymake-google-cpplint-err-line-patterns
flymake-google-cpplint-location
"cpp"))
(provide 'flymake-google-cpplint)
;;; flymake-google-cpplint.el ends here