JonyEpsilon / gorilla-repl

A rich REPL for Clojure in the notebook style.
http://gorilla-repl.org
MIT License
888 stars 104 forks source link

Embedding code references #199

Closed mikepence closed 8 years ago

mikepence commented 9 years ago

There are times when I want to quote a block of code in a Gorilla REPL page that I am constructing. I assume that the use cases for this --literate exposition of functionality, etc. -- are pretty evident.

In actual LP approaches, the narrative contains and generates the program. I think it is enough for a piece of markdown to reference a function name and an optional start and end line number and display the code that it finds there.

I am happy to explore this further and consider what is possible with org mode and babel as an example, and maybe even work through to a PR.

mikepence commented 9 years ago

I could even see this being a third kind of block: markdown, repl and code ref

mikepence commented 9 years ago

Somewhat related, I realized that if you prefix a code expression with a "#_" -- even on a preceding line -- it can effectively become a non-eval'd code listing with the appropriate styling. So, at least lets you embed code, if not have an actual reference to a code site in the codebase itself.

JonyEpsilon commented 9 years ago

Hi Mike, sorry for the slow reply (and to your email) - been somewhat snowed under lately.

I've never seen what you're proposing done before, I don't think. To make sure I'm understanding: you would put some sort of reference into a block of text, and it would automatically insert the source for the code you referenced? I'm not sure the use case is obvious to me either - the idea is to write a comment that relates to the code, but to allow that comment to be other than next to the code in the document? Sorry if these are simplistic questions! I haven't much familiarity with literate programming, so I'm not sure I have a good picture of what you're proposing.

Jony

JonyEpsilon commented 8 years ago

Going to close this one pending clarification - happy to re-open.