I wouldn't normally do something like this but issue #487 brought to
my attention the fact that too many of the python modules don't have
an encoding comment and of those that do there is a lot of pointless
inconsistency in the style of the comment.
We want to avoid doing anything at startup that can be deferred. So instead of
creating the history command parser on module import memoize the function.
I'm not completely sure of the mechanism, but by assigning the value of
`builtins.__xonsh_env__.get('VI_MODE')` to an instance attribute the PT
history teardown routine throws an error on exit.
Instead, just feed the True/False value from the `.get()` directly to
the lambda function that runs the vi_mode keybinding. Everything still
works as expected and no errors on exit.
This fixes most of the lint errors in the history code. It also fixes
two bugs that were found by pylint due to misnamed variables. This patch
does not make any functional changes. I'll fix the remaining lint errors
in a subsequent patch when I tackle cross-module issues.
This replaces the bash script I originally proposed as a way to safely invoke
unit tests with a xonsh script (we need to eat our own dog food). This also
udpates the documentation.
This adds the envvar `VI_MODE`, (default `False`). If it is set to `True`,
either in a `.xonshrc` or dynamically, then the prompt is switched to
`vi_mode`.
`vi_mode` defaults to an `--insert--` environment, then user can hit ESC
to enter command mode, etc...
This makefile makes it easier to run things like unit tests and pylint
against the code. Especially before doing a commit. It also helps ensure
unit tests are not affected by local config files (e.g., ~/.xonshrc).
h/t @jonathanslenders
When using the prompt_toolkit shell, user can press Ctrl-X Ctrl-E to
open the current line in $EDITOR.
Limitations -- it can only open the _current_ line, so if you are
already in a multiline prompt, you can't edit what is already entered in
lines above.
However, you can enter multiline commands in the editor and these are
correctly interpreted by xonsh (assuming correct syntax, etc)
Fix the handling of negative history indexes where a slice specification
is involved. Negative indexes not part of a slice specification worked by
accident because the argparse module (see section "16.4.4.3 Arguments
containing --") treats such values as positional arguments (which is a
misfeature of argparse in my opinion). I've also added unit tests for
"history show" to keep this from being broken in the future.