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