| 1 |
;;; autotest-mode.el - Edit autotest for Emacs -*- lexical-binding: t -*- |
| 2 |
|
| 3 |
;; Author: Akim Demaille ([email protected]) |
| 4 |
;; Keywords: languages, faces, m4, Autotest |
| 5 |
|
| 6 |
;; This file is part of Autoconf |
| 7 |
|
| 8 |
;; Copyright (C) 2001, 2009-2017, 2020-2026 Free Software Foundation, |
| 9 |
;; Inc. |
| 10 |
;; |
| 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. |
| 15 |
;; |
| 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. |
| 20 |
;; |
| 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/>. |
| 23 |
|
| 24 |
;;; Commentary: |
| 25 |
|
| 26 |
;; A major mode for editing autotest input (like testsuite.at). |
| 27 |
;; Derived from autoconf-mode.el, by Martin Buchholz ([email protected]). |
| 28 |
|
| 29 |
;;; Your should add the following to your Emacs configuration file: |
| 30 |
|
| 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)) |
| 35 |
|
| 36 |
;;; Code: |
| 37 |
|
| 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") |
| 46 |
) |
| 47 |
|
| 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) |
| 61 |
|
| 62 |
(defvar autotest-mode-map |
| 63 |
(let ((map (make-sparse-keymap))) |
| 64 |
(define-key map '[(control c) (\;)] 'comment-region) |
| 65 |
map)) |
| 66 |
|
| 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))) |
| 75 |
|
| 76 |
;;;###autoload |
| 77 |
(defun autotest-mode () |
| 78 |
"A major-mode to edit Autotest files like testsuite.at. |
| 79 |
\\{autotest-mode-map} |
| 80 |
" |
| 81 |
(interactive) |
| 82 |
(kill-all-local-variables) |
| 83 |
(use-local-map autotest-mode-map) |
| 84 |
|
| 85 |
(make-local-variable 'add-log-current-defun-function) |
| 86 |
(setq add-log-current-defun-function 'autotest-current-defun) |
| 87 |
|
| 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) |
| 92 |
|
| 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)) |
| 99 |
|
| 100 |
(provide 'autotest-mode) |
| 101 |
|
| 102 |
;;; autotest-mode.el ends here |