Another step towards HyDE

| categories: hylang | tags:

(In case that isn't clear, it is a Python with a Lisp, and somewhat how I feel trying to see what this is all about ;)

I have been chipping away at HyDE, the Hy Development Environment. So far I have reasonable support for eldoc in hy code, and some integration into lispy.

The executive summary here is:

  1. We have a first approach at getting eldoc to work.
  2. We have better integration with lispy, including the inline describe and arg functionality, and jump to symbol.

You may want to just watch the video to see what it is about: https://www.youtube.com/watch?v=m62oiB6Feeo

The full details of these implementations are described at the end of this post. For now, we just load the functionality here:

(require 'mile-hy)
mile-hy

Some examples of usage:

(list (butlast [12 34 56]))
[12L, 34L]

For details of the implementations see the following discussion.

https://github.com/jkitchin/jmax/blob/master/mile-hy.el includes:

  • Setting up hy-mode with a repl (partly from lispy)
  • an eldoc function
  • some hooks for hy-mode to setup some functionality.
  • A hy src block expansion template for org-mode
  • the contents of what I previously called ob-hy.el

These things don't work without the code at https://github.com/jkitchin/hy/blob/hydoc/hy/core/hylp.hy which provides some hy functions to get eldoc strings, and file locations. These are still work in progress, but functional at this point.

I also adapted some parts of lispy to support hy better in my fork:

These are not fully ready to be integrated to lispy yet, as the functionality here depends on the hy code (in hylp.hy) that isn't part of hy yet. I hacked lispy anyway to see how easy it would be to extend it for hy. So far, it looks promising.

All of these put together lead to:

  1. eldoc support in hy code
  2. lispy support for C-1 descriptions and C-2 args inline.
  3. lispy support for M-. to jump to symbol definitions (although it is a tad hacky and uses hy to generate an org-link to open the code files at the line of the definition ;).

It is far from fully functional and there are some issues to resolve. The code will also probably change as I resolve some of those issues, but it works well enough to put some ideas out there. Feedback is welcome!

The eldoc functions work pretty well for the hy stuff. They don't work too well on the python side. The function at https://github.com/jkitchin/hy/blob/hydoc/hy/core/hylp.hy#L120 is where some improvement is needed. Right now it really only catches a few types of symbols.

For learning hylang a documentation sprint would be great.

  1. Add examples to the functions.
  2. Add documentation to the compiler @build definitions. Find a way to make this discoverable the way they are for functions and macros.
  3. Figure out how to get Python help in. It might be confusing because the syntax and examples will be different.

Copyright (C) 2016 by John Kitchin. See the License for information about copying.

org-mode source

Org-mode version = 8.2.10

Discuss on Twitter