Skip to content

Highlight hyperlinks in "haskell-compile" when using stack #764

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

Closed
k-bx opened this issue Jul 14, 2015 · 8 comments
Closed

Highlight hyperlinks in "haskell-compile" when using stack #764

k-bx opened this issue Jul 14, 2015 · 8 comments

Comments

@k-bx
Copy link
Contributor

k-bx commented Jul 14, 2015

The new haskell stack tool outputs compilation errors shifted by 4 spaces right, which breaks highlighting of errors, since haskell-compilation-error-regexp-alist has a regex that must start a line with no spaces.

Example compilation output that's not highlighted:

-*- mode: haskell-compilation; default-directory: "~/workspace/protocol-buffers/" -*-
HsCompilation started at Wed Jul 15 02:09:36

cd /Users/kb/workspace/protocol-buffers/ && stack build
hprotoc-2.1.3-0bfa2fc6ae7966890c323cb09dc4b57f: unregistering (missing dependencies: alex, protocol-buffers, protocol-buffers-descriptor)
protocol-buffers-2.1.3-a9fbe21f68c562356c7d2b85e44d031e: unregistering (local file changes)
protocol-buffers-descriptor-2.1.3-c816db2c5a31354b20177edcb197fe2f: unregistering (missing dependencies: protocol-buffers)
protocol-buffers-2.1.3: build
alex-3.1.4: configure
alex-3.1.4: build
alex-3.1.4: install
Progress: 2/4
--  While building package protocol-buffers-2.1.3 using:
      /usr/local/bin/runhaskell -package=Cabal-1.18.1.5 -clear-package-db -global-package-db -package-db=/Users/kb/.stack/snapshots/x86_64-osx/lts-2.16/7.8.4/pkgdb/ /var/folders/7l/3ys9j0lx20j6z69lm6s_9r780000gn/T/stack41978/Setup.hs --builddir=.stack-work/dist/x86_64-osx/Cabal-1.18.1.5/ build
    Process exited with code: ExitFailure 1
    Logs have been written to: "/Users/kb/workspace/protocol-buffers/.stack-work/logs/protocol-buffers-2.1.3.log"

    Building protocol-buffers-2.1.3...
    Preprocessing library protocol-buffers-2.1.3...
    [10 of 10] Compiling Text.ProtocolBuffers ( Text/ProtocolBuffers.hs, .stack-work/dist/x86_64-osx/Cabal-1.18.1.5/build/Text/ProtocolBuffers.o )

    Text/ProtocolBuffers.hs:54:1: parse error on input ‘import’

HsCompilation exited abnormally with code 1 at Wed Jul 15 02:09:54

You can see that part Text/ProtocolBuffers.hs:54:1: parse error on input ‘import’ is not being highlighed as a hyperlink.

I propose improving haskell-compilation-error-regexp-alist variable by allowing spaces in line-beginning.

I'm really bad at elisp (especially its regexes, string, escaping syntax etc), so probably would be better if some of you would fix this. I quick-fixed this by removing ^ symbol to just match anywhere, not at line-beginning, but better would be to explicitly only allow spaces.

Thank you!

@k-bx
Copy link
Contributor Author

k-bx commented Jul 14, 2015

Just in case someone takes this, regex for skipping "Loading module" spam also could get this kind of an improvement!

@gracjan
Copy link
Contributor

gracjan commented Jul 15, 2015

We need stack to stabilize it output a bit and then somebody that actively uses stack to contribute the relevant code.

@k-bx
Copy link
Contributor Author

k-bx commented Jul 15, 2015

@gracjan how would you tell if stack's output is stabilized? It looks pretty stabilized to me, I think this error-reporting didn't change for 3 releases already (but need to check to be sure).

I am actively using stack, so if no-one will step-up, I will make sure I understand involved elisp code and will add precisely what is needed then.

@gracjan
Copy link
Contributor

gracjan commented Jul 19, 2015

@k-bx: It would be really appreciated if you did it. Some helpful information:

Link to regexps in Emacs: http://www.gnu.org/software/emacs/manual/html_node/emacs/Regexps.html

Also we need to make better engenireeng effort to not break things:

  • create a tests/haskell-compile-tests.el, look in other files in tests to see how to do it
  • add tests with compiler output inside, write a check if it matches correctly
  • make two separate commits, one for functionality, one for tests

Note that we would like to have tests only for the regexp part, not for the whole compilation as that would be a bit too involved I think.

@k-bx
Copy link
Contributor Author

k-bx commented Jul 19, 2015

@gracjan thanks for the tips! I'll try to do it then. If someone will want to step-in, please write here.

@gracjan
Copy link
Contributor

gracjan commented Sep 2, 2015

@k-bx: Were you able to look at this?

@k-bx
Copy link
Contributor Author

k-bx commented Sep 2, 2015

@gracjan so, I didn't do any hacking (just kept using my fork), but was indeed using stack and observing.

Output is this: when you build a "main" project, stack's output is non-indented. When you build dependencies, if there's an error, stack will output it indented. So it should be fixed by regex fix, similar to the one I did for myself. I will take a look today if I can do that properly.

Second problem which still exists is that, when you try to "go" by the error-file, emacs doesn't know where to find it, asking you to point it to the "root project directory". While pointing works fine, would be great to somehow make it know the dir by itself. Not sure how that could be done.

k-bx added a commit to k-bx/haskell-mode that referenced this issue Sep 2, 2015
Useful for stack tool, which renders dependency-errors indented

Resolves haskell#764
@k-bx
Copy link
Contributor Author

k-bx commented Sep 2, 2015

@gracjan please review PR ^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants