This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH] Check style of mark up and comment
- From: Yao Qi <yao at codesourcery dot com>
- To: <gdb-patches at sourceware dot org>
- Date: Wed, 25 Apr 2012 21:14:20 +0800
- Subject: [PATCH] Check style of mark up and comment
Hi,
This patch adds two new hooks to check markup and comment style.
Missing marker up and incorrect comment style are the most common
mistakes found in review. It is useful to check them when writing
code.
gdb:
2012-04-25 Yao Qi <yao@codesourcery.com>
* gdb-code-style.el: New hook gdb-markup-hook
and gdb-comment-hook.
---
gdb/gdb-code-style.el | 31 ++++++++++++++++++++++++++++++-
1 files changed, 30 insertions(+), 1 deletions(-)
diff --git a/gdb/gdb-code-style.el b/gdb/gdb-code-style.el
index 5897831..7e98754 100644
--- a/gdb/gdb-code-style.el
+++ b/gdb/gdb-code-style.el
@@ -45,4 +45,33 @@
(add-hook 'c-mode-common-hook 'gdb-include-hook)
-;;; gdb-code-style.el ends here
\ No newline at end of file
+;; Check marker up. If the marker up is missing, like,
+;; warning ("abc");
+;; The '(' and '"' will be highlight.
+(defun gdb-markup-hook ()
+ (font-lock-add-keywords
+ nil
+ '(("\\<warning[ ]*\\(\([^_]\\)" 1 font-lock-warning-face t))))
+
+(add-hook 'c-mode-common-hook 'gdb-markup-hook)
+
+(defun gdb-comment-hook ()
+ ;; A space shoud follow "/*", otherwise report a warning.
+ ;; If the comment is like:
+ ;; /*F. */
+ ;; The 'F' will be highlight.
+ (font-lock-add-keywords
+ nil
+ '(("/\\*\\([^ ]\\).*\\*/" 1 font-lock-warning-face t)))
+ ;; Two spaces are needed between "." and "*/". Report warning if there
+ ;; is no space (".*/") or only one space (". */").
+ ;; If the comment is like:
+ ;; /* ABC. */ or /* ABC.*/
+ ;; the '.' is highlight.
+ (font-lock-add-keywords
+ nil
+ '(("\\<[[:ascii:]]*\\(\\.[ ]?\\)\\*/" 1 font-lock-warning-face t)))
+ )
+(add-hook 'c-mode-common-hook 'gdb-comment-hook)
+
+;;; gdb-code-style.el ends here
--
1.7.0.4