ghc-mod icon indicating copy to clipboard operation
ghc-mod copied to clipboard

add elispPath command to bootstrap elisp code from ghc-mod installation

Open etrepum opened this issue 10 years ago • 10 comments

Per #358 this adds an elispPath command which prints out the elisp directory in the ghc-mod installation. Adds a separate elisp-bootstrap directory with elisp code to call ghc-mod with elispPath and load the real code.

I don't really know what I'm doing in elisp but this worked for me. Here's what is in my initialization for emacs:

(add-to-list 'load-path "~/src/ghc-mod/elisp-bootstrap")
(load "ghc-mod")
(add-hook 'haskell-mode-hook (lambda () (ghc-bootstrap)))
(add-hook 'haskell-mode-hook 'turn-on-haskell-indentation)

Presumably you'd be able to take the elisp-boostrap dir and upload it to MELPA which would work for all future versions of ghc-mod. Possible enhancements would include better error reporting, in particular if ghc-mod isn't found then it should tell the user to install ghc-mod and ensure that it's on the PATH.

etrepum avatar Jun 04 '15 18:06 etrepum

If we want this to land on MELPA we have to move it to elisp/ or change this: https://github.com/milkypostman/melpa/blob/master/recipes/ghc. MELPA just pulls the package from git so it'll update as soon as we merge this.

DanielG avatar Jun 04 '15 18:06 DanielG

Another improvement would be to check to make sure that ghc-mod understands the elispPath command. Having an old version would be essentially the same error as not having it installed at all, but it would be helpful if it mentioned that an old, incompatible, version was found.

etrepum avatar Jun 04 '15 18:06 etrepum

Perhaps then we would move the current elisp code out of elisp/ and move the bootstrap code into there.

etrepum avatar Jun 04 '15 18:06 etrepum

What's up with that Makefile? Is that a template you got from somewhere?

DanielG avatar Jun 04 '15 18:06 DanielG

I got it from the elisp dir

etrepum avatar Jun 04 '15 18:06 etrepum

Oh rite xD, I could swear I've never seen that thing before. I'm not really sure why we need that especially the archive and bump targets seem dated.

DanielG avatar Jun 04 '15 18:06 DanielG

I just added some stuff to deal with versions and ./scripts/bump.sh. Not sure if it works because I don't have GNU sed or tac here right now (on OS X).

etrepum avatar Jun 04 '15 18:06 etrepum

You know I'm not so sure I like the approach. If we go with this we'll be stuck with people having (ghc-bootstrap) in their init files forever. Our current entrypoint (ghc-init) is bad enough I'd much rather have it be (ghc-mod-mode) as with just about every other Emacs minor mode but that's complicated by the fact that we can't currently undo all of ghc-init's effects :/

Anyways since we're already stuck with (ghc-init) you might as well rename ghc-bootstrap -> ghc-init so then people won't have to change anything in their emacs init, you'd just have to install the new version of the ghc package and it would just work. So we don't get name conflicts we should rename ghc-init in elisp/ to something else.

DanielG avatar Jun 04 '15 19:06 DanielG

Also have a look at this (https://github.com/kazu-yamamoto/ghc-mod/compare/master...DanielG:dev-elisp-simple) branch I started doing some cleanup ages ago maybe you can base this on that branch. Dunno if it's useful though.

DanielG avatar Jun 04 '15 19:06 DanielG

One problem at a time I guess? We could do something like this now, and work on isolating the effects and such for ghc-mod-mode later.

Renaming things sound fine to me. Should we still rename ghc-init to ghc-mod-init and have an alias of ghc-init for backwards compatibility?

etrepum avatar Jun 04 '15 20:06 etrepum