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

flycheck-mode hook and dir-locals #58

Closed
themoritz opened this issue Dec 17, 2017 · 12 comments
Closed

flycheck-mode hook and dir-locals #58

themoritz opened this issue Dec 17, 2017 · 12 comments

Comments

@themoritz
Copy link

This is more of a note for everyone using a .dir-locals.el file to set dante-target.

When using dante with the recommended entry in my .emacs file as described in the readme, I had an issue where every time I opened a .hs file, the dante-target variable would be overwritten to nil and subsequently dante fails because cabal can't handle multiple targets. This prevented me from using Emacs' dir-locals feature to tell dante which target to use.

The workaround was to remove the following flycheck-mode hook (I don't understand why this fixes the problem or why flycheck keeps working without this line):

(add-hook 'haskell-mode-hook 'flycheck-mode)
@themoritz
Copy link
Author

Just learned that the order of the hooks matters. The issue is only there if the flycheck-mode hook comes after the dante-mode hook.

@michalrus
Copy link

michalrus commented Dec 28, 2017

Emacs is depressing. #ihatemyeditor

Thank you very much, tho.

@joehealy
Copy link

joehealy commented Jan 1, 2018

Did you get to the bottom of why the flycheck-mode hook was needed?

@michalrus
Copy link

No, right now I have an “if it works I freakin’ don’t care” relation w/ Emacs. :throw_up:

But I think I remember a similar problem with Scala and its ENSIME. Maybe let’s… /cc @fommil?

@fommil
Copy link

fommil commented Jan 1, 2018

hmm, I think this sounds familiar as documented Emacs behaviour due to the load order of .dir-locals.el. The relevant part of my init.el points at https://emacs.stackexchange.com/questions/7743 as an example, also see the docs of hack-local-variables-hook.

@fommil
Copy link

fommil commented Jan 1, 2018

btw, it sounds hacky, but I'm actually fine with the Emacs approach. I don't believe anybody has solved the generic problem of load order for any customisable system automatically. Even my xbox computer games have a "load order" for mods, which is the same problem, in a different guise. When customising a core tool, we have to open up the hood sometimes.

FYI additional thing... when I load whitespace-mode and want to use local variables I use this alternative function instead of the default hook loader.

(defun whitespace-mode-with-local-variables ()
  "A variant of `whitespace-mode' that can see local variables."
  (add-hook 'hack-local-variables-hook 'whitespace-mode nil t))

Which is the escape hatch.

@fommil
Copy link

fommil commented Jan 1, 2018

the other thing dante could do would be to make dante-target buffer local by default, e.g. https://stackoverflow.com/questions/21917049 i.e. call (make-variable-buffer-local 'dante-target) immediately after defining it.

(users must then use setq-default instead of setq) and also add to the safe-local-variable list. Example from another project: Wilfred/ag.el#145

I recommend that anything project-specific be made buffer local in a similar fashion.

@themoritz
Copy link
Author

@joehealy I actually found out that the hook wasn't really necessary for me in the first place. 😕

@michalrus
Copy link

@fommil, thank you for all the details! =)

@fommil
Copy link

fommil commented Jan 1, 2018

@michalrus no problem, I hope to one day be a) a haskell developer b) using this mode.

@michalrus
Copy link

I very much recommend the switch. It’s been an amazing experience so far for me. ^.^

@fommil
Copy link

fommil commented Jan 1, 2018

it's my employers who need to be convinced...

@jyp jyp closed this as completed Jan 5, 2018
romanofski added a commit to romanofski/nix that referenced this issue Jan 31, 2020
Following this jyp/dante#58 discussion, I'm
using this change in the configuration in order to get dante to work
including the use of multiple targets in Nix.
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

5 participants