Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect parsing of compilation-mode buffers #452

Open
wildwestrom opened this issue Jul 10, 2022 · 3 comments
Open

Incorrect parsing of compilation-mode buffers #452

wildwestrom opened this issue Jul 10, 2022 · 3 comments

Comments

@wildwestrom
Copy link

Related to syl20bnr/spacemacs#15643

Description :octocat:

The wrong parts of a compilation-mode buffer are parsed for certain messages.
This isn't just aesthetics. The part highlighted in red is supposed to be the file name. The part highlighted in blue is supposed to be the location in the file.
When I click on the file name, it thinks the red portion is a file, and therefore can't find it, because the actual file is (dirname/filename\.ext):\d+ not (dirname/filename\.ext:\d+).

Reproduction guide 🪲

  • Start Emacs
  • Open a scratch buffer
  • Paste the following text:
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Could not get string from shell command.
             at src/main.rs:81:14

Caused by:
   0: Broken pipe (os error 32)
             at src/main.rs:79:14
      - Failed to write buffer to stdin', src/main.rs:412:28
  • M-x compilation-mode
  • Try opening the first or second highlighted file.

Observed behaviour:

Here's an example of what I see:
Image here:
image
Notice that highlighting starts at black at at then red at src/main.rs:81 then black at : then blue at 14. When I click on the first or second highlighted files, it tries to navigate to filename:linenumber then go to the column-number.
On a minimal configuration of GNU Emacs, I see this:
image
This indicates that something in spacemacs enhances compilation-mode. I have no idea what exactly does it or how to search for it.
A minimal config of spacemacs will yield the same result, until the rust layer is added.
I also found information dealing with compilation-mode in rust-compile.el therefore I assume this bug is in this package.
image

Expected behaviour:

Same thing as above, except the text should be highlighted as follows.
Start red highlight at src/main.rs then black at : then blue after the first colon and navigate to the correct file and go to the correct line number.

@wildwestrom
Copy link
Author

Just to be clear, made this issue just to get feedback before starting to implement the fix.

@wildwestrom
Copy link
Author

Here's what I got so far. It works great!

  (setq error_stack-regexps
    '("\\(?:at\\|',\\) \\(\\([^:\s]+\\):\\([0-9]+\\)\\)"
      2 3 nil nil 1))
  (setf (cdr (assoc 'cargo compilation-error-regexp-alist-alist))
        error_stack-regexps)

image

@brotzeit
Copy link
Contributor

brotzeit commented Aug 25, 2022

Sorry for the late reply. You're right:

#s(compilation--message
   (nil 28
        (("- Failed to write buffer to stdin', src/main.rs:412" nil)
         nil
         (28 #1))
        nil nil)
   2 nil cucumber)

Open a pr and I'll merge your fix, thanks!

wildwestrom added a commit to wildwestrom/dotfiles-archlinux that referenced this issue Aug 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants