gdb/gdb-code-style.el - gdb

Functions defined

Source code

  1. ;;; gdb-code-style.el --- code style checker for GDB contributors

  2. ;; Copyright (C) 2012-2015 Free Software Foundation, Inc.

  3. ;; Author: Yao Qi <yao@codesourcery.com>
  4. ;; Created: 17 April 2012
  5. ;; Version: 1.0
  6. ;; Keywords: GDB

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

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

  15. ;; You should have received a copy of the GNU General Public License
  16. ;; along with this program.  If not, see <http://www.gnu.org/licenses/>.

  17. ;;; Commentary:

  18. ;; These hooks defined in this file provide some code style checks in
  19. ;; Emacs.  You can load it in your ~/.emacs,
  20. ;; (load-file "~/$(GDB_SOURCE)/gdb/gdb-code-style.el")


  21. ;;; Code:

  22. ;; Don't use these functions.  Their alternatives are better.  This list
  23. ;; of functions is from ARI rules.
  24. (defun gdb-fun-name-hook ()
  25.   (font-lock-add-keywords
  26.    nil
  27.    '(("\\<\\(\\(xasprintf\\|abort\\|vasprintf\\|strerror\\|strdup\\|asprintf\\|sprintf\\)[ ]*\(\\)" 1 font-lock-warning-face t))))
  28. (add-hook 'c-mode-common-hook 'gdb-fun-name-hook)

  29. ;; Don't include these files directly.
  30. (defun gdb-include-hook ()
  31.   (font-lock-add-keywords
  32.    nil
  33.    '(("\\<include[ ]*\\(<\\(sys/stat\\|stat\\|dirent\\|wait\\|sys/wait\\|assert\\)\\.h>\\)" 1 font-lock-warning-face t))))

  34. (add-hook 'c-mode-common-hook 'gdb-include-hook)

  35. ;; Check marker up.  If the marker up is missing, like,
  36. ;;   warning ("abc");
  37. ;; The '(' and '"' will be highlight.
  38. (defun gdb-markup-hook ()
  39.   (font-lock-add-keywords
  40.    nil
  41.    '(("\\<\\(warning\\|error\\)[ ]*\\(\([^_]\\)" 2 font-lock-warning-face t))))

  42. (add-hook 'c-mode-common-hook 'gdb-markup-hook)

  43. (defun gdb-comment-hook ()
  44.   ;; A space should follow "/*", otherwise report a warning.
  45.   ;; If the comment is like:
  46.   ;; /*F.  */
  47.   ;; The 'F' will be highlight.
  48.   (font-lock-add-keywords
  49.    nil
  50.    '(("/\\*\\([^ ]\\).*\\*/" 1 font-lock-warning-face t)))
  51.   ;; Two spaces are needed between "." and "*/".  Report warning if there
  52.   ;; is no space (".*/") or only one space (". */").
  53.   ;; If the comment is like:
  54.   ;; /* ABC. */ or /* ABC.*/
  55.   ;; the '.' is highlight.
  56.   (font-lock-add-keywords
  57.    nil
  58.    '(("\\<[[:ascii:]]*\\(\\.[ ]?\\)\\*/" 1 font-lock-warning-face t)))
  59.   )
  60. (add-hook 'c-mode-common-hook 'gdb-comment-hook)

  61. ;;; gdb-code-style.el ends here