jcollard / elm-mode

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

Support Elm 0.19 "elm" sub-commands via customisation #139

Closed purcell closed 6 years ago

purcell commented 6 years ago

Default commands are still those for Elm 0.18, but Elm 0.19's commands can now be used by setting the appropriate custom vars as follows, or in directory local variables for an Elm 0.19 project:

  (setq elm-interactive-command '("elm" "repl")
        elm-reactor-command '("elm" "reactor")
        elm-compile-command '("elm" "make")
        elm-package-command '("elm" "package"))

Tested with 0.18 - looking for feedback from a 0.19 user that this works.

mattsawyer77 commented 6 years ago

This doesn't work for me with Elm 0.19. I get the following error:

Wrong type argument: stringp, ("repl")
purcell commented 6 years ago

Hmm. With 2852fea, I can put the following in a .dir-locals.el file in an Elm 0.19 project and successfully start the repl.

;;; Directory Local Variables
;;; For more information see (info "(emacs) Directory Variables")

((elm-mode
  (elm-interactive-command . ("elm" "repl"))
  (elm-reactor-command . ("elm" "reactor"))
  (elm-compile-command . ("elm" "make"))
  (elm-package-command . ("elm" "package"))
  (elm-package-json . "elm.json")))
crudbetter commented 6 years ago

@purcell We've ported our project to Elm 0.19. I've made a .dir-locals.el file with the contents as you describe. To get Elm-Compile to work I've had to change the compile arguments here https://github.com/jcollard/elm-mode/pull/139/files#diff-c3633a01c792e88846f0ecf0214a49e0R95 - replacing "--yes" and "--warn" with just "--debug".

EDIT - a better way is to add elm-compile-arguments to .dir-locals.el like so:

((elm-mode
  (elm-compile-arguments . ("--output=elm.js" "--debug"))
  (elm-interactive-command . ("elm" "repl"))
  (elm-reactor-command . ("elm" "reactor"))
  (elm-compile-command . ("elm" "make"))
  (elm-package-command . ("elm" "package"))
  (elm-package-json . "elm.json")))
purcell commented 6 years ago

Thanks @crudbetter, that's encouraging.

mattsawyer77 commented 6 years ago

I've tried both versions of .dir-locals.el from above, but neither worked for me. I wonder if it's because I'm using Spacemacs, or emacs 26.1...

purcell commented 6 years ago

@mattsawyer77 You'd have to re-open your elm file before trying it, so that it picks up the .dir-locals.el values -- you should get prompted for them. (M-x normal-mode should also trigger this.)

purcell commented 6 years ago

BTW, a fuller .dir-locals.el for Elm 0.19 is the following:

((elm-mode
  (elm-interactive-command . ("elm" "repl"))
  (elm-reactor-command . ("elm" "reactor"))
  (elm-reactor-arguments . ("--port" "8000"))
  (elm-compile-command . ("elm" "make"))
  (elm-compile-arguments . ("--output=elm.js" "--debug"))
  (elm-package-command . ("elm" "package"))
  (elm-package-json . "elm.json")))
mattsawyer77 commented 6 years ago

I see the variable getting set as intended. describe-variable for elm-interactive-command gives

elm-interactive-command is a variable defined in ‘elm-interactive.el’. Its value is ("elm" "repl") Original value was "elm-repl"

Note, I'm using the stock elm-mode package, not this branch/fork...maybe that's the disconnect here?

purcell commented 6 years ago

Yeah, you'd absolutely need this branch, but I'm about to merge it to master because it shouldn't break existing configs.