##// END OF EJS Templates
contrib: add compilation-mode linking for our test output...
Augie Fackler -
r41951:b6a757de default
parent child Browse files
Show More
@@ -1,56 +1,63 b''
1 ;; hg-test-mode.el - Major mode for editing Mercurial tests
1 ;; hg-test-mode.el - Major mode for editing Mercurial tests
2 ;;
2 ;;
3 ;; Copyright 2014 Matt Mackall <mpm@selenic.com>
3 ;; Copyright 2014 Matt Mackall <mpm@selenic.com>
4 ;; "I have no idea what I'm doing"
4 ;; "I have no idea what I'm doing"
5 ;;
5 ;;
6 ;; This software may be used and distributed according to the terms of the
6 ;; This software may be used and distributed according to the terms of the
7 ;; GNU General Public License version 2 or any later version.
7 ;; GNU General Public License version 2 or any later version.
8 ;;
8 ;;
9 ;; To enable, add something like the following to your .emacs:
9 ;; To enable, add something like the following to your .emacs:
10 ;;
10 ;;
11 ;; (if (file-exists-p "~/hg/contrib/hg-test-mode.el")
11 ;; (if (file-exists-p "~/hg/contrib/hg-test-mode.el")
12 ;; (load "~/hg/contrib/hg-test-mode.el"))
12 ;; (load "~/hg/contrib/hg-test-mode.el"))
13
13
14 (defvar hg-test-mode-hook nil)
14 (defvar hg-test-mode-hook nil)
15
15
16 (defvar hg-test-mode-map
16 (defvar hg-test-mode-map
17 (let ((map (make-keymap)))
17 (let ((map (make-keymap)))
18 (define-key map "\C-j" 'newline-and-indent)
18 (define-key map "\C-j" 'newline-and-indent)
19 map)
19 map)
20 "Keymap for hg test major mode")
20 "Keymap for hg test major mode")
21
21
22 (add-to-list 'auto-mode-alist '("\\.t\\'" . hg-test-mode))
22 (add-to-list 'auto-mode-alist '("\\.t\\'" . hg-test-mode))
23
23
24 (defconst hg-test-font-lock-keywords-1
24 (defconst hg-test-font-lock-keywords-1
25 (list
25 (list
26 '("^ \\(\\$\\|>>>\\) " 1 font-lock-builtin-face)
26 '("^ \\(\\$\\|>>>\\) " 1 font-lock-builtin-face)
27 '("^ \\(>\\|\\.\\.\\.\\) " 1 font-lock-constant-face)
27 '("^ \\(>\\|\\.\\.\\.\\) " 1 font-lock-constant-face)
28 '("^ \\([[][0-9]+[]]\\)$" 1 font-lock-warning-face)
28 '("^ \\([[][0-9]+[]]\\)$" 1 font-lock-warning-face)
29 '("^ \\(.*?\\)\\(\\( [(][-a-z]+[)]\\)*\\)$" 1 font-lock-string-face)
29 '("^ \\(.*?\\)\\(\\( [(][-a-z]+[)]\\)*\\)$" 1 font-lock-string-face)
30 '("\\$?\\(HG\\|TEST\\)\\w+=?" . font-lock-variable-name-face)
30 '("\\$?\\(HG\\|TEST\\)\\w+=?" . font-lock-variable-name-face)
31 '("^ \\(.*?\\)\\(\\( [(][-a-z]+[)]\\)+\\)$" 2 font-lock-type-face)
31 '("^ \\(.*?\\)\\(\\( [(][-a-z]+[)]\\)+\\)$" 2 font-lock-type-face)
32 '("^#.*" . font-lock-preprocessor-face)
32 '("^#.*" . font-lock-preprocessor-face)
33 '("^\\([^ ].*\\)$" 1 font-lock-comment-face)
33 '("^\\([^ ].*\\)$" 1 font-lock-comment-face)
34 )
34 )
35 "Minimal highlighting expressions for hg-test mode")
35 "Minimal highlighting expressions for hg-test mode")
36
36
37 (defvar hg-test-font-lock-keywords hg-test-font-lock-keywords-1
37 (defvar hg-test-font-lock-keywords hg-test-font-lock-keywords-1
38 "Default highlighting expressions for hg-test mode")
38 "Default highlighting expressions for hg-test mode")
39
39
40 (defvar hg-test-mode-syntax-table
40 (defvar hg-test-mode-syntax-table
41 (let ((st (make-syntax-table)))
41 (let ((st (make-syntax-table)))
42 (modify-syntax-entry ?\" "w" st) ;; disable standard quoting
42 (modify-syntax-entry ?\" "w" st) ;; disable standard quoting
43 st)
43 st)
44 "Syntax table for hg-test mode")
44 "Syntax table for hg-test mode")
45
45
46 (defun hg-test-mode ()
46 (defun hg-test-mode ()
47 (interactive)
47 (interactive)
48 (kill-all-local-variables)
48 (kill-all-local-variables)
49 (use-local-map hg-test-mode-map)
49 (use-local-map hg-test-mode-map)
50 (set-syntax-table hg-test-mode-syntax-table)
50 (set-syntax-table hg-test-mode-syntax-table)
51 (set (make-local-variable 'font-lock-defaults) '(hg-test-font-lock-keywords))
51 (set (make-local-variable 'font-lock-defaults) '(hg-test-font-lock-keywords))
52 (setq major-mode 'hg-test-mode)
52 (setq major-mode 'hg-test-mode)
53 (setq mode-name "hg-test")
53 (setq mode-name "hg-test")
54 (run-hooks 'hg-test-mode-hook))
54 (run-hooks 'hg-test-mode-hook))
55
55
56 (with-eval-after-load "compile"
57 ;; Link to source files in test-check-code.t violations.
58 (add-to-list 'compilation-error-regexp-alist-alist
59 '(hg-test-check-code-output
60 "\\+ \\([^:\n]+\\):\\([0-9]+\\):$" 1 2))
61 (add-to-list 'compilation-error-regexp-alist 'hg-test-check-code-output))
62
56 (provide 'hg-test-mode)
63 (provide 'hg-test-mode)
General Comments 0
You need to be logged in to leave comments. Login now