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