Skip to content

Instantly share code, notes, and snippets.

@lambdageek
Created March 8, 2022 17:23
Show Gist options
  • Save lambdageek/67420bbb57c694d59861463958ad391d to your computer and use it in GitHub Desktop.
Save lambdageek/67420bbb57c694d59861463958ad391d to your computer and use it in GitHub Desktop.
Make Emacs understand MSBuild Exec task compilation output
(defun ak-msbuildify-regexp-str (s)
(replace-regexp-in-string "\\^" "^ \\\\{0,2\\\\}" s))
(defun ak-msbuildify-alist-alist (xss-orig)
(let* ((xss (copy-alist xss-orig))
(l xss))
(while (consp l)
;; l is (('symbol REGEXP ...) ...)
(let* ((x (copy-sequence (car l))) ;; unshare with the original alist
(r (cdr x)))
(setcar r (ak-msbuildify-regexp-str (car r)))
(setcar l x))
(setq l (cdr l)))
xss))
(defun ak-msbuildify-compilation ()
"Replace the normal regexps in ‘compilation-error-regexp-alist-alist’ to match output of MS Build Exec tasks.
The console logger in MS Build indents output from the commands
that are invoked by 2 columns. This function modifies the
regexps that try to match compiler build output by replacing
their use of \"^\" by a regexp that matches beginning of line
followed by upto 2 spaces."
(interactive)
(when (not (boundp 'ak-compilation-error-regexp-alist-alist))
(setq ak-compilation-error-regexp-alist-alist (copy-alist compilation-error-regexp-alist-alist))
(setq compilation-error-regexp-alist-alist (ak-msbuildify-alist-alist compilation-error-regexp-alist-alist))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment