Skip to content

Commit fe7092d

Browse files
committed
revisions to emacs compilation regexp, more readable and robust.
1 parent 521fb04 commit fe7092d

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

src/etc/emacs/rust-mode.el

+15-7
Original file line numberDiff line numberDiff line change
@@ -229,15 +229,23 @@ The initializer is `DEFAULT-TAB-WIDTH'.")
229229
;; regexp (which is broken on a few edge cases), add our own 'rust
230230
;; compilation error regexp and use it instead.
231231
(defvar rustc-compilation-regexps
232-
(let ((re (concat "^\\([^ \n]+\\):\\([0-9]+\\):\\([0-9]+\\): "
233-
"\\([0-9]+\\):\\([0-9]+\\) "
234-
"\\(?:[Ee]rror\\|\\([Ww]arning\\)\\):")))
235-
(cons re '(1 (2 . 4) (3 . 5) (6))))
232+
(let ((file "\\([^ \n]+\\)")
233+
(start-line "\\([0-9]+\\)")
234+
(start-col "\\([0-9]+\\)")
235+
(end-line "\\([0-9]+\\)")
236+
(end-col "\\([0-9]+\\)")
237+
(error-or-warning "\\(?:[Ee]rror\\|\\([Ww]arning\\)\\)"))
238+
(let ((re (concat "^" file ":" start-line ":" start-col
239+
": " end-line ":" end-col
240+
" \\(?:[Ee]rror\\|\\([Ww]arning\\)\\):")))
241+
(cons re '(1 (2 . 4) (3 . 5) (6)))))
236242
"Specifications for matching errors in rustc invocations.
237243
See `compilation-error-regexp-alist for help on their format.")
238244

239-
(add-to-list 'compilation-error-regexp-alist-alist
240-
(cons 'rustc rustc-compilation-regexps))
241-
(add-to-list 'compilation-error-regexp-alist 'rustc)
245+
(eval-after-load 'compile
246+
'(progn
247+
(add-to-list 'compilation-error-regexp-alist-alist
248+
(cons 'rustc rustc-compilation-regexps))
249+
(add-to-list 'compilation-error-regexp-alist 'rustc)))
242250

243251
;;; rust-mode.el ends here

0 commit comments

Comments
 (0)