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

Linting failure when reloading file that is not current buffer #1757

Closed
sirlensalot opened this issue Aug 14, 2021 · 2 comments · Fixed by #1759
Closed

Linting failure when reloading file that is not current buffer #1757

sirlensalot opened this issue Aug 14, 2021 · 2 comments · Fixed by #1759

Comments

@sirlensalot
Copy link
Contributor

sirlensalot commented Aug 14, 2021

Problem is in haskell-process-errors-warnings when comparing current buffer file name to the warning result:

(string= (file-truename (buffer-file-name module-buffer))
(file-truename file))

When an error appears in a different file than the currently-loaded one, ghci outputs a relative file name. Thus, if "/var/project/src/Foo/Bar.hs" is loaded but user is looking at "/var/project/src/Baz/Quux.hs", an error in Baz.Quux will print for "src/Baz/Quux.hs"; whereas if it was in the loaded file, it gets a full/absolute path.

The problem occurs when default-directory does not match the session directory: with a relative path, file-truename simply appends default directory. For our example, that would be "/var/project/src/Baz", resulting in the erroneous value of "/var/project/src/Baz/src/Baz/Quux.hs", which will obviously fail the comparison above.

The workaround is to overwrite default-directory with the session current-dir:

  (when (and module-buffer haskell-process-show-overlays)
          (set-variable 'default-directory (haskell-session-current-dir session)) ;; <- workaround
          (haskell-check-paint-overlay
           module-buffer
           (string= (file-truename (buffer-file-name module-buffer))
                    (file-truename file))
           line error-msg file type nil col1))

This resolves the issue, at the cost of setting default-directory for the buffer to the session directory, which is probably not great.

@sirlensalot
Copy link
Contributor Author

If there's some with-XXX or save-excursion trick to set default-directory only in that scope then I think the workaround could be principled.

@purcell
Copy link
Member

purcell commented Aug 14, 2021

You can locally bind default-directory to whatever you want within a let form.

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

Successfully merging a pull request may close this issue.

2 participants