OLD | NEW |
1 ; To use this, | 1 ; To use this, |
2 ; 1) Add to init.el: | 2 ; 1) Add to init.el: |
3 ; (setq-default chrome-root "/path/to/chrome/src/") | 3 ; (setq-default chrome-root "/path/to/chrome/src/") |
4 ; (add-to-list 'load-path (concat chrome-root "tools/emacs")) | 4 ; (add-to-list 'load-path (concat chrome-root "tools/emacs")) |
5 ; (require 'trybot) | 5 ; (require 'trybot) |
6 ; 2) Run on trybot output: | 6 ; 2) Run on trybot output: |
7 ; M-x trybot | 7 ; M-x trybot |
8 ; | 8 ; |
9 ; To hack on this, | 9 ; To hack on this, |
10 ; M-x eval-buffer | 10 ; M-x eval-buffer |
11 ; M-x trybot-test | 11 ; M-x trybot-test |
12 | 12 |
13 (defvar chrome-root nil | 13 (defvar chrome-root nil |
14 "Path to the src/ directory of your Chrome checkout.") | 14 "Path to the src/ directory of your Chrome checkout.") |
15 | 15 |
16 (defun get-chrome-root () | 16 (defun get-chrome-root () |
17 (or chrome-root default-directory)) | 17 (or chrome-root default-directory)) |
18 | 18 |
| 19 ; Hunt down from the top, case correcting each path component as needed. |
| 20 ; Currently does not keep a cache. Returns nil if no matching file can be |
| 21 ; figured out. |
| 22 (defun case-corrected-filename (filename) |
| 23 (save-match-data |
| 24 (let ((path-components (split-string filename "/")) |
| 25 (corrected-path (file-name-as-directory (get-chrome-root)))) |
| 26 (mapc |
| 27 (function |
| 28 (lambda (elt) |
| 29 (if corrected-path |
| 30 (let ((next-component |
| 31 (car (member-ignore-case |
| 32 elt (directory-files corrected-path))))) |
| 33 (setq corrected-path |
| 34 (and next-component |
| 35 (file-name-as-directory |
| 36 (concat corrected-path next-component)))))))) |
| 37 path-components) |
| 38 (if corrected-path |
| 39 (file-relative-name (directory-file-name corrected-path) |
| 40 (get-chrome-root)) |
| 41 nil)))) |
| 42 |
19 (defun trybot-fixup () | 43 (defun trybot-fixup () |
20 "Parse and fixup the contents of the current buffer as trybot output." | 44 "Parse and fixup the contents of the current buffer as trybot output." |
21 | 45 |
22 ;; Fixup paths. | 46 ;; Fixup paths. |
23 (cd (get-chrome-root)) | 47 (cd (get-chrome-root)) |
24 | 48 |
25 ;; Delete Windows \r. | 49 ;; Delete Windows \r. |
26 (delete-trailing-whitespace) | 50 (delete-trailing-whitespace) |
27 | 51 |
28 ;; Fix up path references. | 52 ;; Fix up path references. |
29 ; XXX is there something I should so so this stuff doesn't end up on the | 53 ; XXX is there something I should so so this stuff doesn't end up on the |
30 ; undo stack? | 54 ; undo stack? |
31 (goto-char (point-min)) | 55 (goto-char (point-min)) |
32 ; Fix Windows paths ("d:\...\src\"). | 56 ; Fix Windows paths ("d:\...\src\"). |
33 ; TODO: need to fix case; e.g. third_party/webkit -> third_party/WebKit. :( | 57 ; TODO: need to fix case; e.g. third_party/webkit -> third_party/WebKit. :( |
34 (while (re-search-forward "^.:\\\\.*\\\\src\\\\" nil t) | 58 (while (re-search-forward "\\(^.:\\\\.*\\\\src\\\\\\)\\(.*?\\)[(:]" nil t) |
35 (replace-match "") | 59 (replace-match "" nil t nil 1) |
36 ; Line now looks like: | 60 ; Line now looks like: |
37 ; foo\bar\baz.cc error message here | 61 ; foo\bar\baz.cc error message here |
38 ; We want to fixup backslashes in path into forward slashes, without | 62 ; We want to fixup backslashes in path into forward slashes, without |
39 ; modifying the error message. | 63 ; modifying the error message - by matching up to the first colon above |
40 ; XXX current eats backslashes after the filename; how can I limit it to | 64 ; (which will be just beyond the end of the filename) we can use the end of |
41 ; changing from current point up to the first space? | 65 ; the match as a limit. |
42 (subst-char-in-region (point) (line-end-position) ?\\ ?/)) | 66 (subst-char-in-region (point) (match-end 0) ?\\ ?/) |
| 67 ; See if we can correct the file name casing. |
| 68 (let ((filename (buffer-substring (match-beginning 2) (match-end 2)))) |
| 69 (if (and (not (file-exists-p filename)) |
| 70 (setq filename (case-corrected-filename filename))) |
| 71 (replace-match filename t t nil 2)))) |
43 (goto-char (point-min)) | 72 (goto-char (point-min)) |
44 | 73 |
45 ;; Switch into compilation mode. | 74 ;; Switch into compilation mode. |
46 (compilation-mode)) | 75 (compilation-mode)) |
47 | 76 |
48 (defun trybot-test () | 77 (defun trybot-test () |
49 "Load our test data and do the trybot parse on it." | 78 "Load our test data and do the trybot parse on it." |
50 (interactive) | 79 (interactive) |
51 | 80 |
52 (switch-to-buffer (get-buffer-create "*trybot-test*")) | 81 (switch-to-buffer (get-buffer-create "*trybot-test*")) |
(...skipping 17 matching lines...) Expand all Loading... |
70 ;; TODO: fixup URL to append /text if necessary. | 99 ;; TODO: fixup URL to append /text if necessary. |
71 | 100 |
72 ;; Extract the body out of the URL. | 101 ;; Extract the body out of the URL. |
73 ; TODO: delete HTTP headers somehow. | 102 ; TODO: delete HTTP headers somehow. |
74 (switch-to-buffer (get-buffer-create "*trybot*")) | 103 (switch-to-buffer (get-buffer-create "*trybot*")) |
75 (buffer-swap-text (url-retrieve-synchronously url)) | 104 (buffer-swap-text (url-retrieve-synchronously url)) |
76 | 105 |
77 (trybot-fixup)) | 106 (trybot-fixup)) |
78 | 107 |
79 (provide 'trybot) | 108 (provide 'trybot) |
OLD | NEW |