On Wed, 21 Mar 2018 17:33:41 -0700 (PDT) Phil <phil.s....@gmail.com> wrote:
> Today I started Leo to a Leo Tip (I like those!) suggesting use of > the valuespace plugin. Ok, I'm game. I load it up, and..... I am > completely clueless as to what this is good for. I have read the > documentation, looked for help in this list, and I just don't get it. > > I'm assuming that it made it to a Leo Tip because it has value, which > suggests to me that I might want to use it. But it's not at all > obvious why (or how). What am I missing? The valuespace plugin really really really needs to be split in two. Ville Vainio who used to be more active in Leo wrote the original valuespace plugin. It was a complex and complicated system for spreading bits of information through a Leo tree and then collecting them together, with various levels of evaluation, and then formatting the results into output nodes. Kind of a free form database / spreadsheet thing interspersed with whatever else you were using the outline for. I've worked through it a couple of times and sort of felt I've understood what's going on, but then forgotten it all again shortly afterwards - it's that kind of complex. It was a time when there seemed to be a new plugin being written every day, and it defines a namespace, c.vs (i.e. a Python dict), where results are stored between runs and available to other scripts. So I wanted to write some expression evaluation commands with persistent results and didn't want to add yet another plugin for something relatively simple, so I added my commands to the valuespace plugin: vs-eval vs-last vs-last-pretty vs-eval-block (more recent than the others) vs-eval Evaluate the selected text, if any. Done in the c.vs namespace, so `a = 10` would cause c.vs['a'] to be 10. The result of the last expression or assignment is printed in the log. Selects the next line, handy for executing line by line. vs-last insert the result of the last vs-eval in the body vs-last-pretty as vs-last, but format with pprint.pformat vs-eval-block evaluate series of blocks of code in the body, separated like this: # >>> code to run # <<< output of code # >>> code to run # <<< output of code ... e.g. import datetime datetime.datetime.now() # >>> 2018-03-21 21:46:13.582835 # <<< datetime.datetime.now()+datetime.timedelta(days=1000) # >>> 2020-12-15 21:46:34.403814 # <<< vs-eval-block inserts the separators, blocks can be re-run by placing the cursor in them and doing vs-eval-block, and the cursor is placed in the next block, so you can go back up, change something, then quickly re-execute everything. In my biased opinion those four commands are the most generally useful Python evaluation commands in Leo. Results are persistent (not like Ctrl-B execute-script), autocomplete works, you have syntax highlighting (missing in the Python console), results can easily be place in the body (e.g. "the cat is 7 years, or 7*365 days old" - want to replace 7*365 with 2555? Select it, vs-eval, delete it, vs-last. Every time someone's looking for that kind of functionality I point to valuespace, and I'm sure nine times out of ten they get lost in all the completely separate complexity you encountered. I think the Tip meant to direct you to the vs-eval family of commands, not all the rest of it. Hmm, now I actually read the tip: https://github.com/leo-editor/leo-editor/issues/617 I see it does refer to the outline oriented spreadsheet aspect, but I suspect that's just an editorial error - I really wouldn't put it on that list for that - that's clever but so complicated I don't imagine many people getting to grips with it. I've promoted valuespace heavily for the above commands, I suspect that's why it ended up on that list. Cheers -Terry -- You received this message because you are subscribed to the Google Groups "leo-editor" group. To unsubscribe from this group and stop receiving emails from it, send an email to leo-editor+unsubscr...@googlegroups.com. To post to this group, send email to leo-editor@googlegroups.com. Visit this group at https://groups.google.com/group/leo-editor. For more options, visit https://groups.google.com/d/optout.