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