jcollard / elm-mode

Elm mode for emacs
GNU General Public License v3.0
373 stars 67 forks source link

[Spacemacs] File mode specification error: (void-variable elm) #50

Closed codedmart closed 8 years ago

codedmart commented 8 years ago

See here: spacemacs issue thread specifically this comment. I reverted back to e0318ebb288be638f4a98cfd56a516b20ed5e723 and all is working fine again. So not sure if this is a bug here or in how spacemacs handles elm-mode. Any advice would be great, thanks!

Bogdanp commented 8 years ago

That's interesting. Do you have auto-compile enabled? What happens if you checkout the current HEAD and delete elm-interactive.elc then re-compile elm-interactive.el? I don't think that change should have affected the semantics of that code but I might be missing something.

codedmart commented 8 years ago

@Bogdanp I believe that I have auto-compile enabled but don't know for sure. I did delete elm-interactive.elc and also removed the entire elm-mode in folder from elpa and reinstalled from scratch and still have the same problem.

Bogdanp commented 8 years ago

I just installed both auto-complete and elm-mode from MELPA and everything compiled fine. I believe this is spacemacs related:

Spacemacs seems to use use-package to defer loading the package. That coupled with the implementation of :defer t in use-package coupled with the fact that auto-complete does not set an autoload cookie for ac-define-source leads me to believe the problem is with-eval-after-load thinks auto-complete has loaded in full even though it hasn't, which leads it to try to evaluate the call to ac-define-source strictly, like it would a normal function call (thus evaluating elm first), even though ac-define-source is a macro. All of that blows up with the error in question :).

My elisp-fu isn't very strong but that seems logical enough. I'll see if there's anything I can do on this end.

Bogdanp commented 8 years ago

Nope, what I wrote above doesn't hold. elm-interactive requires auto-complete at the very top of that file so everything should be loaded by that point.

I was finally able to replicate the issue by uninstalling both packages and adding this to my config:

(use-package elm-mode
  :ensure t
  :mode ("\\.elm\\'" . elm-mode))

(use-package auto-complete
  :defer t
  :ensure t)

Note the order! The problem doesn't occur if I put the use-package definition for auto-complete first (OR if I remove it completely). I'm still not sure exactly why this happens but perhaps you could try fixing it in your config by making sure auto-complete gets installed first.

Bogdanp commented 8 years ago

Alright, I think I finally figured it out. See this commit if you're interested in the details. The change should make it to MELPA soon. Let me know if that fixes the issue for you!

codedmart commented 8 years ago

@Bogdanp Yes this is fixed. Thanks!