I'm using the latest Doom Emacs on Emacs 27 with this config: https://github.com/gregghz/doom-config/tree/d3af4724cb4a5dd379645580698f7d24a5c3922a.
I have this code to run a bloop command (like bloop compile
) and have the results pop up in a compilation-mode
buffer. My understanding was that adding entries to compilation-error-regexp-alist
would allow compilation-mode
to detect and linkify all errors in the output (and jump to the first one).
I have this in my config.el:
(after! compile
(add-to-list 'compilation-error-regexp-alist-alist '(bloop "^\\[E\\] \\([A-Za-z0-9\\._/-]+\\):\\([0-9]+\\):\\([0-9]+\\):.*$" 1 2 3))
(add-to-list 'compilation-error-regexp-alist 'bloop))
Here is some example error output from the buffer:
-*- mode: compilation; default-directory: "~/workspace/scratch/scala/" -*-
Compilation started at Tue Jul 14 07:32:08
bloop compile --reporter scalac scala
Compiling scala (1 Scala source)
[E] /Users/gher33/workspace/scratch/scala/src/main/scala/Main.scala:4:34: not found: type Units
[E] def main(args: Array[String]): Units = {
[E] ^
[E] /Users/gher33/workspace/scratch/scala/src/main/scala/Main.scala:5:17: not found: type Thing
[E] val x = new Thing
[E] ^
[E] /Users/gher33/workspace/scratch/scala/src/main/scala/Main.scala:8:19: value f is not a member of Int
[E] lazy val x = 10 f
[E] ^
[E] three errors found
Compiled scala (991ms)
[E] Failed to compile 'scala'
Compilation exited abnormally with code 8 at Tue Jul 14 07:32:10
Testing the regex with regexp-builder
matches each of the three errors. However in the compilation-mode
buffer none of the errors are detected or linkified.
What am I missing?
=EDIT=
Running describe-mode
produces this output:
Auto-Compression Auto-Encryption Better-Jumper Better-Jumper-Local Clipetty
Column-Number Company Company-Prescient Dap Dap-Auto-Configure Dap-Tooltip
Dap-Ui Dap-Ui-Controls Dap-Ui-Many-Windows Doom-Modeline Electric-Indent Evil
Evil-Escape Evil-Goggles Evil-Local Evil-Snipe Evil-Snipe-Local
Evil-Snipe-Override Evil-Snipe-Override-Local Evil-Surround File-Name-Shadow
Flyspell-Lazy Font-Lock Gcmh General-Override Global-Clipetty Global-Company
Global-Eldoc Global-Evil-Surround Global-Flycheck Global-Font-Lock
Global-Git-Commit Global-Magit-File Global-So-Long Global-Undo-Tree Ivy
Ivy-Posframe Ivy-Prescient Ivy-Rich Line-Number Mouse-Wheel Ns-Auto-Titlebar
Override-Global Persp Prescient-Persist Projectile Recentf Save-Place Savehist
Shell-Dirtrack Show-Paren Size-Indication Smartparens-Global Solaire-Global
Transient-Mark Treemacs-Filewatch Treemacs-Follow Treemacs-Fringe-Indicator
Treemacs-Git Undo-Tree Which-Key Window-Divider Winner Ws-Butler
Ws-Butler-Global Xterm-Mouse
(Information about these minor modes follows the major mode info.)
Compilation mode defined in ‘compile.el’:
Major mode for compilation log buffers.
To visit the source for a line-numbered error,
move point to the error message line and type RET.
To kill the compilation, type C-c C-k.
If I run compilation-mode
in that buffer, linkification happens and the links work. The output of describe-mode
doesn't change.
The buffer is created/summoned with this code:
(defun bloop-exec (comint root command &rest args)
(unless command (error "Missing argument `command'."))
(let* ((buffer-name (bloop-buffer-name root command))
(raw-command (cons bloop-program-name (cons command args)))
(full-command (string-join (mapcar 'shell-quote-argument raw-command) " "))
(inhibit-read-only 1))
(when (not (executable-find bloop-program-name))
(error (concat "`%s' not found. Is bloop installed and on PATH? "
"See `bloop-program-name' variable.")
bloop-program-name))
(if comint
(with-current-buffer (get-buffer-create buffer-name)
(pop-to-buffer-same-window (current-buffer))
;; (read-only-mode)
(buffer-disable-undo)
(if (comint-check-proc (current-buffer))
(error "A bloop command is still running!")
;; TODO: Maybe save buffers?
(cd root)
(erase-buffer)
(insert (concat root "$ " full-command))
(newline 2)
(comint-mode)
;; (compilation-shell-minor-mode)
(comint-exec (current-buffer) buffer-name bloop-program-name nil (cons command args))
(current-buffer)))
(let ((compilation-buffer-name-function (lambda (mode) buffer-name)))
(cd root)
(compile full-command)))))
-
after the9
in the filename character class is probably wrong: if you are looking to match a literal-
, you have to put it either at the beginning or at the end of the character class.compilation-mode
buffer incompilation-mode
? The reason that I ask is that if I create a file with the contents above, close and reopen the file (to get the file local variable to take effect and put the buffer incompilation-mode
), I get the errors recognized and linkified without adding anything to the regexp alist (of course, the links are bad on my system but still...)describe-mode
also shows "Compilation mode defined in 'compile.el'". HOWEVER, if i runcompilation-mode
while in the buffer, it does actually linkify the errors. I've updated the question with additional info about this.bloop-exec
was always called withcomint
set to nil so it would always hit the else branch. Change(compile full-command)
to(compile full-command t)
fixes it!