jcollard / elm-mode

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

code-fixes elm-compile-{clean-imports,add-annotations} work on unsaved buffer contents #114

Closed berkan closed 7 years ago

berkan commented 7 years ago

I wanted to be able to add annotations and clean imports without first having to save the buffer.

For example: if I start writing a new function and want elm-make to automatically add its annotation, I need to remember to save the file first. I rather I didn't have to do that (nor be prompted to do that).

With this change, elm-compile-clean-imports and elm-compile-add-annotations work on unsaved buffer contents:

Berkan

purcell commented 7 years ago

Thanks. I support this in principle, but there are a couple of small issues with the PR:

Hope that helps!

purcell commented 7 years ago

(Also xor is unused, so should be removed in any case.)

purcell commented 7 years ago

I'm playing with this a bit locally. The use of get-buffer was wrong, and broke in situations where the elm source is in a subdir, because then file passed to elm-compile--temporary is a relative path, and that doesn't match the buffer name -- in general you absolutely cannot assume that the buffer name for a file with a given name will be the same as the name of the file.

In any case, I've fixed this up accordingly and merged it. Thanks for your contribution!