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