1*ef5ccd6cSJohn Marino;;; gdb-code-style.el --- code style checker for GDB contributors 2*ef5ccd6cSJohn Marino 3*ef5ccd6cSJohn Marino;; Copyright (C) 2012-2013 Free Software Foundation, Inc. 4*ef5ccd6cSJohn Marino 5*ef5ccd6cSJohn Marino;; Author: Yao Qi <yao@codesourcery.com> 6*ef5ccd6cSJohn Marino;; Created: 17 April 2012 7*ef5ccd6cSJohn Marino;; Version: 1.0 8*ef5ccd6cSJohn Marino;; Keywords: GDB 9*ef5ccd6cSJohn Marino 10*ef5ccd6cSJohn Marino;; This program is free software; you can redistribute it and/or modify 11*ef5ccd6cSJohn Marino;; it under the terms of the GNU General Public License as published by 12*ef5ccd6cSJohn Marino;; the Free Software Foundation; either version 3 of the License, or 13*ef5ccd6cSJohn Marino;; (at your option) any later version. 14*ef5ccd6cSJohn Marino 15*ef5ccd6cSJohn Marino;; This program is distributed in the hope that it will be useful, 16*ef5ccd6cSJohn Marino;; but WITHOUT ANY WARRANTY; without even the implied warranty of 17*ef5ccd6cSJohn Marino;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*ef5ccd6cSJohn Marino;; GNU General Public License for more details. 19*ef5ccd6cSJohn Marino 20*ef5ccd6cSJohn Marino;; You should have received a copy of the GNU General Public License 21*ef5ccd6cSJohn Marino;; along with this program. If not, see <http://www.gnu.org/licenses/>. 22*ef5ccd6cSJohn Marino 23*ef5ccd6cSJohn Marino;;; Commentary: 24*ef5ccd6cSJohn Marino 25*ef5ccd6cSJohn Marino;; These hooks defined in this file provide some code style checks in 26*ef5ccd6cSJohn Marino;; Emacs. You can load it in your ~/.emacs, 27*ef5ccd6cSJohn Marino;; (load-file "~/$(GDB_SOURCE)/gdb/gdb-code-style.el") 28*ef5ccd6cSJohn Marino 29*ef5ccd6cSJohn Marino 30*ef5ccd6cSJohn Marino;;; Code: 31*ef5ccd6cSJohn Marino 32*ef5ccd6cSJohn Marino;; Don't use these functions. Their alternatives are better. This list 33*ef5ccd6cSJohn Marino;; of functions is from ARI rules. 34*ef5ccd6cSJohn Marino(defun gdb-fun-name-hook () 35*ef5ccd6cSJohn Marino (font-lock-add-keywords 36*ef5ccd6cSJohn Marino nil 37*ef5ccd6cSJohn Marino '(("\\<\\(\\(xasprintf\\|abort\\|vasprintf\\|strerror\\|strdup\\|asprintf\\|sprintf\\)[ ]*\(\\)" 1 font-lock-warning-face t)))) 38*ef5ccd6cSJohn Marino(add-hook 'c-mode-common-hook 'gdb-fun-name-hook) 39*ef5ccd6cSJohn Marino 40*ef5ccd6cSJohn Marino;; Don't include these files directly. 41*ef5ccd6cSJohn Marino(defun gdb-include-hook () 42*ef5ccd6cSJohn Marino (font-lock-add-keywords 43*ef5ccd6cSJohn Marino nil 44*ef5ccd6cSJohn Marino '(("\\<include[ ]*\\(<\\(sys/stat\\|stat\\|dirent\\|wait\\|sys/wait\\|assert\\)\\.h>\\)" 1 font-lock-warning-face t)))) 45*ef5ccd6cSJohn Marino 46*ef5ccd6cSJohn Marino(add-hook 'c-mode-common-hook 'gdb-include-hook) 47*ef5ccd6cSJohn Marino 48*ef5ccd6cSJohn Marino;; Check marker up. If the marker up is missing, like, 49*ef5ccd6cSJohn Marino;; warning ("abc"); 50*ef5ccd6cSJohn Marino;; The '(' and '"' will be highlight. 51*ef5ccd6cSJohn Marino(defun gdb-markup-hook () 52*ef5ccd6cSJohn Marino (font-lock-add-keywords 53*ef5ccd6cSJohn Marino nil 54*ef5ccd6cSJohn Marino '(("\\<\\(warning\\|error\\)[ ]*\\(\([^_]\\)" 2 font-lock-warning-face t)))) 55*ef5ccd6cSJohn Marino 56*ef5ccd6cSJohn Marino(add-hook 'c-mode-common-hook 'gdb-markup-hook) 57*ef5ccd6cSJohn Marino 58*ef5ccd6cSJohn Marino(defun gdb-comment-hook () 59*ef5ccd6cSJohn Marino ;; A space should follow "/*", otherwise report a warning. 60*ef5ccd6cSJohn Marino ;; If the comment is like: 61*ef5ccd6cSJohn Marino ;; /*F. */ 62*ef5ccd6cSJohn Marino ;; The 'F' will be highlight. 63*ef5ccd6cSJohn Marino (font-lock-add-keywords 64*ef5ccd6cSJohn Marino nil 65*ef5ccd6cSJohn Marino '(("/\\*\\([^ ]\\).*\\*/" 1 font-lock-warning-face t))) 66*ef5ccd6cSJohn Marino ;; Two spaces are needed between "." and "*/". Report warning if there 67*ef5ccd6cSJohn Marino ;; is no space (".*/") or only one space (". */"). 68*ef5ccd6cSJohn Marino ;; If the comment is like: 69*ef5ccd6cSJohn Marino ;; /* ABC. */ or /* ABC.*/ 70*ef5ccd6cSJohn Marino ;; the '.' is highlight. 71*ef5ccd6cSJohn Marino (font-lock-add-keywords 72*ef5ccd6cSJohn Marino nil 73*ef5ccd6cSJohn Marino '(("\\<[[:ascii:]]*\\(\\.[ ]?\\)\\*/" 1 font-lock-warning-face t))) 74*ef5ccd6cSJohn Marino ) 75*ef5ccd6cSJohn Marino(add-hook 'c-mode-common-hook 'gdb-comment-hook) 76*ef5ccd6cSJohn Marino 77*ef5ccd6cSJohn Marino;;; gdb-code-style.el ends here 78