2
0

autotest-mode.el 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. ;;; autotest-mode.el --- autotest code editing commands for Emacs
  2. ;; Author: Akim Demaille (akim@freefriends.org)
  3. ;; Keywords: languages, faces, m4, Autotest
  4. ;; This file is part of Autoconf
  5. ;; Copyright (C) 2001, 2009-2012 Free Software Foundation, Inc.
  6. ;;
  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. ;;
  12. ;; This program is distributed in the hope that it will be useful,
  13. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. ;; GNU General Public License for more details.
  16. ;;
  17. ;; You should have received a copy of the GNU General Public License
  18. ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. ;;; Commentary:
  20. ;; A major mode for editing autotest input (like testsuite.at).
  21. ;; Derived from autoconf-mode.el, by Martin Buchholz (martin@xemacs.org).
  22. ;;; Your should add the following to your Emacs configuration file:
  23. ;; (autoload 'autotest-mode "autotest-mode"
  24. ;; "Major mode for editing autotest files." t)
  25. ;; (setq auto-mode-alist
  26. ;; (cons '("\\.at\\'" . autotest-mode) auto-mode-alist))
  27. ;;; Code:
  28. (defvar autotest-font-lock-keywords
  29. `(("\\bdnl\\b\\(.*\\)" 1 font-lock-comment-face t)
  30. ("\\$[0-9*#@]" . font-lock-variable-name-face)
  31. ("^\\(m4_define\\|m4_defun\\)(\\[*\\([A-Za-z0-9_]+\\)" 2 font-lock-function-name-face)
  32. ("^AT_SETUP(\\[+\\([^]]+\\)" 1 font-lock-function-name-face)
  33. ("^AT_DATA(\\[+\\([^]]+\\)" 1 font-lock-variable-name-face)
  34. ("\\b\\(_?m4_[_a-z0-9]*\\|_?A[ST]_[_A-Z0-9]+\\)\\b" . font-lock-keyword-face)
  35. "default font-lock-keywords")
  36. )
  37. (defvar autotest-mode-syntax-table nil
  38. "syntax table used in autotest mode")
  39. (setq autotest-mode-syntax-table (make-syntax-table))
  40. (modify-syntax-entry ?\" "\"" autotest-mode-syntax-table)
  41. ;;(modify-syntax-entry ?\' "\"" autotest-mode-syntax-table)
  42. (modify-syntax-entry ?# "<\n" autotest-mode-syntax-table)
  43. (modify-syntax-entry ?\n ">#" autotest-mode-syntax-table)
  44. (modify-syntax-entry ?\( "()" autotest-mode-syntax-table)
  45. (modify-syntax-entry ?\) ")(" autotest-mode-syntax-table)
  46. (modify-syntax-entry ?\[ "(]" autotest-mode-syntax-table)
  47. (modify-syntax-entry ?\] ")[" autotest-mode-syntax-table)
  48. (modify-syntax-entry ?* "." autotest-mode-syntax-table)
  49. (modify-syntax-entry ?_ "_" autotest-mode-syntax-table)
  50. (defvar autotest-mode-map
  51. (let ((map (make-sparse-keymap)))
  52. (define-key map '[(control c) (\;)] 'comment-region)
  53. map))
  54. (defun autotest-current-defun ()
  55. "Autotest value for `add-log-current-defun-function'.
  56. This tells add-log.el how to find the current test group/macro."
  57. (save-excursion
  58. (if (re-search-backward "^\\(m4_define\\|m4_defun\\|AT_SETUP\\)(\\[+\\([^]]+\\)" nil t)
  59. (buffer-substring (match-beginning 2)
  60. (match-end 2))
  61. nil)))
  62. ;;;###autoload
  63. (defun autotest-mode ()
  64. "A major-mode to edit Autotest files like testsuite.at.
  65. \\{autotest-mode-map}
  66. "
  67. (interactive)
  68. (kill-all-local-variables)
  69. (use-local-map autotest-mode-map)
  70. (make-local-variable 'add-log-current-defun-function)
  71. (setq add-log-current-defun-function 'autotest-current-defun)
  72. (make-local-variable 'comment-start)
  73. (setq comment-start "# ")
  74. (make-local-variable 'parse-sexp-ignore-comments)
  75. (setq parse-sexp-ignore-comments t)
  76. (make-local-variable 'font-lock-defaults)
  77. (setq major-mode 'autotest-mode)
  78. (setq mode-name "Autotest")
  79. (setq font-lock-defaults `(autotest-font-lock-keywords nil))
  80. (set-syntax-table autotest-mode-syntax-table)
  81. (run-hooks 'autotest-mode-hook))
  82. (provide 'autotest-mode)
  83. ;;; autotest-mode.el ends here