Live data from Hacker News

Run programs in Emacs buffer, seeing their output inline, interactively

github.com

1–10 of 39 posts

Re: Run programs in Emacs buffer, seeing their output inline, interactively

#3
post #2

This is useful! Are there other packages on MELPA that provide similar functionality?

Org mode provides a supercharged version of this functionality that will work for any language as long as you can point it to an appropriate runtime. It's definitely a little more verbose, since you have to declare the language and stuff inside the org mode syntax, but I'm sure that you could get it to work ad-hoc with a little hacking.

https://orgmode.org/worg/org-contrib/babel/

Re: Run programs in Emacs buffer, seeing their output inline, interactively

#4
post #2

This is useful! Are there other packages on MELPA that provide similar functionality?

`org-mode` has the ability to evaluate code blocks and store the output in a following results block[0].

You can configure it to run just about everything in various ways and therefore you can do Literate Programming in nearly the full Knuth sense in it.

I find it's a good solution for a local "notebook" similar to IPython/Jupyter Notebooks but for any language in Emacs.

[0] https://orgmode.org/manual/Evaluating-Code-Blocks.html

Re: Run programs in Emacs buffer, seeing their output inline, interactively

#5
Tangentially, has there been any work in having more structured scrollback, say one buffer for every command, which can be collapsed, pinned or copied individually? Presently there's the minor annoyance when (accidentally) running any program with lots of output, which is that all the scrollback above it becomes inaccessible. Yeah, could have run them in different splits or redirected to begin with, but sometimes you don't know beforehand. And being able to reuse the output of a slow command after the fact would be handy too.

I was thinking that this'd be a feature of the terminal, but on second thought the terminal doesn't know where one command begins or ends, so it'd have to be the shell that saves the output.

Re: Run programs in Emacs buffer, seeing their output inline, interactively

#6
post #2

This is useful! Are there other packages on MELPA that provide similar functionality?

There is lively.el [1]! It is also on MELPA in a more recent version [2]. It allows to put an elisp expression into any buffer and then replaces that with the output in a time interval or manually. I use that frequently.

[1] https://lukego.livejournal.com/23379.html [2] https://github.com/purcell/lively/tree/348675828c6a81bfa1ac3...

Re: Run programs in Emacs buffer, seeing their output inline, interactively

#7

Tangentially, has there been any work in having more structured scrollback, say one buffer for every command, which can be collapsed, pinned or copied individually? Presently there's the minor annoyance when (accidentally) running any program with lots of output, which is that all the scrollback above it becomes inaccessible. Yeah, could have run them in different splits or redirected to begin with, but sometimes you…

Is this different from cells in a notebook (eg Jupyter)?

Re: Run programs in Emacs buffer, seeing their output inline, interactively

#8

Tangentially, has there been any work in having more structured scrollback, say one buffer for every command, which can be collapsed, pinned or copied individually? Presently there's the minor annoyance when (accidentally) running any program with lots of output, which is that all the scrollback above it becomes inaccessible. Yeah, could have run them in different splits or redirected to begin with, but sometimes you…

EShell in Emacs can preserve point at the prompt that executed the command. You can then hit space to page through the output, or start typing to immediately jump to the end of the buffer (and thus a blank prompt):

https://www.masteringemacs.org/article/complete-guide-master...

There's also `C-c C-p` to jump to the previous command prompt in the likes of M-x shell. That's not quite what you want, but it's another way to jump back up.

Re: Run programs in Emacs buffer, seeing their output inline, interactively

#9
post #2

This is useful! Are there other packages on MELPA that provide similar functionality?

`org-mode` has the ability to evaluate code blocks and store the output in a following results block[0]. You can configure it to run just about everything in various ways and therefore you can do Literate Programming in nearly the full Knuth sense in it. I find it's a good solution for a local "notebook" similar to IPython/Jupyter Notebooks but for any language in Emacs. [0] https://orgmode.org/manual/Evaluating-Code…

Org+babel is probably my favorite thing about emacs, magit being a close second.

I tried doing Literate Programming using this blog as my guide http://fgiasson.com/blog/index.php/2016/06/21/optimal-emacs-..., but I got burned out pretty quickly. I think my problem was I put literally everything in a single README.org file, and it was so taxing scrolling up and down. I might try again but with multiple org files.

Post reply on HN