1 (define-derived-mode sepia-regex-mode text-mode
"RE"
2 "Mode for looking at 'use re \"debug\"' output."
4 (font-lock-add-keywords
6 '(("^\\(Compiling REx\\|Guessing start of match\\|Matching REx\\|Freeing REx:\\)" . font-lock-keyword-face
)
7 ("^Match .*" . font-lock-warning-face
)
8 ;; ("^Matches word.*" . font-lock-keyword-face)
9 ;; ("^Matching stclass.* against.*" . font-lock-keyword-face)
10 ("^ +\\([0-9]+\\)[: ]" 1 font-lock-constant-face
)
11 ("^ *[0-9]+ <\\([^>]*\\)>" 1 font-lock-string-face
)
12 ("^ *[0-9]+ <[^>]*> <\\([^>]*\\)>" 1 font-lock-string-face
)
13 ("^ *[0-9]+.*?\\(|.*\\)" 1 font-lock-comment-face
)
16 (modify-syntax-entry ?
\" "\"")
17 (font-lock-fontify-buffer)
18 (toggle-truncate-lines 1))
20 (defun sepia-test-regex (pat str
)
21 (interactive "Smatch pattern: \nSAgainst string: \n")
22 "Show the debug output for compiling `pat' and matching against `str'.
24 XXX: this doesn't work, because I can't figure out how to
25 redirect the debug output to a file."
26 (with-current-buffer (get-buffer-create "*sepia-regex*")
27 (let ((inhibit-read-only t
))
29 (shell-command (format "perl -Mre=debug -e 'q#%s# =~ m/%s/'" str pat
)
31 ;; (insert (sepia-eval-raw
32 ;; (format "do { use re 'debug'; qq#%s# =~ m#%s# }" str pat)))
35 (pop-to-buffer (current-buffer))))