Alternative evaluate last expression support for the freja editor.
The freja editor.
- Clone this repository somewhere and cd to the resulting directory
- Start freja with:
freja ./freja-eval-last-expr/defaults.janet
Control+L
to load the file
-
In freja's buffer window, type some code that could be evaluated successfully, e.g.:
(+ 1 1)
-
With the cursor after the closing paren, press the key sequence
Control+Enter
. -
Observe in the console or the echoer area at the bottom of freja's window, the following sort of output:
=> (+ 1 1) 2
In this version, Control+Enter
invokes the function eval-last-expr
which:
- Determines a region of text containing (but not necessarily limited to) the expression immediately preceding the cursor
- Analyzes the region to determine a "last expression"
- Hands the determined expression off for evaluation
Note that the code relies on a Left Margin Convention for Janet code. Briefly, this means that in one's Janet code the presence of a left paren, single quote, or a tilde in the left-most column always indicates the beginning of a top-level form.
There are tests than can be run by jpm test
.
One set of tests runs tests inside freja while the other uses janet-usages-as-tests to test supporting code.