Leo calculator `Alt-X {arbitrary math function}`

Bug #1252842 reported by tbnorth
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
leo-editor
Confirmed
Wishlist
Unassigned

Bug Description

From Matt Wilke - great idea, math expressions in the mini-buffer should be evaluated and the answer shown in the log window.

Math expressions could be identified by starting with a number, although the system could be more powerful if they were explicitly identified with a leading ? or something, so in the spirit of vs-eval in valuespace.py, Alt-X ?a=7*6 would assign 42 to a and display 42 in the log, and a subsequent Alt-X ?a*10 would display 420 in the log.

So, Alt-X [-+0-9].* implies a math expression, and Alt-X ?.* explicitly announces a math expression.

Of course, for 'math', substitute 'python'.

Finally, I think this could be implemented using the vs-eval code directly, although that raises questions about making the plugin on be default.

Revision history for this message
Edward K. Ream (edreamleo) wrote : Re: [Bug 1252842] [NEW] Leo calculator `Alt-X {arbitrary math function}`

On Tue, Nov 19, 2013 at 1:35 PM, tbnorth <email address hidden> wrote:

>
> Math expressions could be identified by starting with a number, although
> ​ ​
> the system could be more powerful if they were explicitly identified
> ​ ​
> with a leading ? or something, so in the spirit of vs-eval in
> valuespace.py, Alt-X ?a=7*6 would assign 42 to a and display 42 in the
> ​ ​
> log, and a subsequent Alt-X ?a*10 would display 420 in the log.
>

​Overloading the Alt-X command is dubious: a calculator is not that often
used.

But Alt-X calc <return> followed by, say, an integral to evaluate (again,
in the minibuffer) would make perfect sense ;-)

EKR

Revision history for this message
Matt Wilkie (maphew) wrote :

two refinements:

(a) In my thinking out loud I was using X as a stand-in for "any hot key",
but I do like the idea of using the real X because it's one less thing to
remember.

Alt-XX (Alt double-tap X, which is distinct from hold-Alt-and-press-X,
then release both and type X) instead of Alt-X, or perhaps Alt-XC would
sidestep the overload, maybe?

(b) log pane is not the best place for the result, since it's spatially a
long way from the mini-buffer, where one's attention is while typing the
formula. UX Ideally it would be in or overlaid on the mini-buffer. I don't
know if that's a feasible idea?

-matt

Revision history for this message
Matt Wilkie (maphew) wrote :

> sidestep the overload

will a mini-buffer command _ever_ start with a punctuation mark?

Vim, ipython and friends use exclamation mark as "send what comes next to
shell". Maybe Leo use it, or another character, as "sent what comes next to
python (and display result)". So something like:

   Alt-X `15 * 36 / 3.3
   Alt-X ~15 * 36 / 3.3
   Alt-X #15 * 36 / 3.3
   Alt-X !15 * 36 / 3.3

Listed in order of personal preference. Backtick 'cause it's an easy key to
find, and not mis-type (I frequently get the wrong num/punct key when
trying to touch type).

! comes last because it should, probably, follow the general trend of
"send to command shell"

-matt

Changed in leo-editor:
status: New → Confirmed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.