Prefer HTTPS to FTP and HTTP
[autoconf.git] / lib / emacs / autotest-mode.el
blobbba65213168fa54e15af97edf9a3806fa85f43e2
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 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 3 of the License, or
13 ;; (at your option) any later version.
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.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with this program. If not, see <https://www.gnu.org/licenses/>.
23 ;;; Commentary:
25 ;; A major mode for editing autotest input (like testsuite.at).
26 ;; Derived from autoconf-mode.el, by Martin Buchholz (martin@xemacs.org).
28 ;;; Your should add the following to your Emacs configuration file:
30 ;; (autoload 'autotest-mode "autotest-mode"
31 ;; "Major mode for editing autotest files." t)
32 ;; (setq auto-mode-alist
33 ;; (cons '("\\.at\\'" . autotest-mode) auto-mode-alist))
35 ;;; Code:
37 (defvar autotest-font-lock-keywords
38 `(("\\bdnl\\b\\(.*\\)" 1 font-lock-comment-face t)
39 ("\\$[0-9*#@]" . font-lock-variable-name-face)
40 ("^\\(m4_define\\|m4_defun\\)(\\[*\\([A-Za-z0-9_]+\\)" 2 font-lock-function-name-face)
41 ("^AT_SETUP(\\[+\\([^]]+\\)" 1 font-lock-function-name-face)
42 ("^AT_DATA(\\[+\\([^]]+\\)" 1 font-lock-variable-name-face)
43 ("\\b\\(_?m4_[_a-z0-9]*\\|_?A[ST]_[_A-Z0-9]+\\)\\b" . font-lock-keyword-face)
44 "default font-lock-keywords")
47 (defvar autotest-mode-syntax-table nil
48 "syntax table used in autotest mode")
49 (setq autotest-mode-syntax-table (make-syntax-table))
50 (modify-syntax-entry ?\" "\"" autotest-mode-syntax-table)
51 ;;(modify-syntax-entry ?\' "\"" autotest-mode-syntax-table)
52 (modify-syntax-entry ?# "<\n" autotest-mode-syntax-table)
53 (modify-syntax-entry ?\n ">#" autotest-mode-syntax-table)
54 (modify-syntax-entry ?\( "()" 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)
61 (defvar autotest-mode-map
62 (let ((map (make-sparse-keymap)))
63 (define-key map '[(control c) (\;)] 'comment-region)
64 map))
66 (defun autotest-current-defun ()
67 "Autotest value for `add-log-current-defun-function'.
68 This tells add-log.el how to find the current test group/macro."
69 (save-excursion
70 (if (re-search-backward "^\\(m4_define\\|m4_defun\\|AT_SETUP\\)(\\[+\\([^]]+\\)" nil t)
71 (buffer-substring (match-beginning 2)
72 (match-end 2))
73 nil)))
75 ;;;###autoload
76 (defun autotest-mode ()
77 "A major-mode to edit Autotest files like testsuite.at.
78 \\{autotest-mode-map}
80 (interactive)
81 (kill-all-local-variables)
82 (use-local-map autotest-mode-map)
84 (make-local-variable 'add-log-current-defun-function)
85 (setq add-log-current-defun-function 'autotest-current-defun)
87 (make-local-variable 'comment-start)
88 (setq comment-start "# ")
89 (make-local-variable 'parse-sexp-ignore-comments)
90 (setq parse-sexp-ignore-comments t)
92 (make-local-variable 'font-lock-defaults)
93 (setq major-mode 'autotest-mode)
94 (setq mode-name "Autotest")
95 (setq font-lock-defaults `(autotest-font-lock-keywords nil))
96 (set-syntax-table autotest-mode-syntax-table)
97 (run-hooks 'autotest-mode-hook))
99 (provide 'autotest-mode)
101 ;;; autotest-mode.el ends here