ANN: vs-eval-block

28 views
Skip to first unread message

Terry Brown

unread,
May 16, 2017, 10:38:38 PM5/16/17
to leo-editor
Another "live code" option for Leo. I've added a vs-eval-block
command, in the valuespace.py plugin.

vs-eval-block
-------------

In the body, "# >>>" marks the end of a code block, and "# <<<" marks
the end of an output block. E.g.::

a = 2
# >>>
4
# <<<
b = 2.0*a
# >>>
4.0
# <<<

``vs-eval-block`` evaluates the current code block, either the code block
the cursor's in, or the code block preceding the output block the cursor's
in. Subsequent output blocks are marked "# >>> *" to show they may need
re-evaluation.

Note: you don't really need to type the "# >>>" and "# <<<" markers
because ``vs-eval-block`` will add them as needed. So just type the
first code block and run ``vs-eval-block``.


and here's another example of it's use


import time
a = 7*66
# >>>
462
# <<<
print(2.3*a)
22*a
# >>>
1062.6
10164
# <<<
time.asctime()
# >>>
Tue May 16 22:34:23 2017
# <<<

Edward K. Ream

unread,
May 17, 2017, 7:28:52 AM5/17/17
to leo-editor
On Tue, May 16, 2017 at 9:38 PM, Terry Brown <terry...@gmail.com> wrote:
Another "live code" option for Leo.  I've added a vs-eval-block
command, in the valuespace.py plugin.

​Thanks for this, Terry.  Is this a prototype for ipython-like evaluation?​
 

​I confess I have never really understood what the valuespace plugin is for.​

​Edward

Terry Brown

unread,
May 17, 2017, 5:51:41 PM5/17/17
to leo-e...@googlegroups.com
On Wed, 17 May 2017 06:28:50 -0500
"Edward K. Ream" <edre...@gmail.com> wrote:

> On Tue, May 16, 2017 at 9:38 PM, Terry Brown <terry...@gmail.com>
> wrote:
>
> > Another "live code" option for Leo. I've added a vs-eval-block
> > command, in the valuespace.py plugin.
> >
>
> ​Thanks for this, Terry. Is this a prototype for ipython-like
> evaluation?​

Not really, it was more because it was so easy to do building on
existing vs-eval functionality. Not really related to but inspired by
Lang's diff two nodes and get output question.

> ​I confess I have never really understood what the valuespace plugin
> is for.​

It's really two plugins in one :-} The docs. point out the first four
commands are easy to use body text execution related (Python only, kind
of improved Ctrl-B). The rest is Ville's work, clever but complex
spreading of code and values and templates throughout a tree and then
collecting results etc... I can never remember how that part works long
enough to use it :-/

Cheers -Terry

> ​Edward
>

Edward K. Ream

unread,
May 18, 2017, 7:09:38 AM5/18/17
to leo-editor
On Wed, May 17, 2017 at 4:51 PM, Terry Brown <terry...@gmail.com> wrote:

> ​I confess I have never really understood what the valuespace plugin
> is for.​

It's really two plugins in one :-}  The docs. point out the first four
commands are easy to use body text execution related (Python only, kind
of improved Ctrl-B). 

​Thanks. That's good to know.  I'll reread the docstring about both parts, but especially the easy commands.

Edward
Reply all
Reply to author
Forward
0 new messages