Merge pull request #3163 from con-f-use/master

Remove hard coded Alt+. binding
This commit is contained in:
Gil Forsyth 2019-06-12 14:12:18 -04:00 committed by GitHub
commit 610d4c1fe8
Failed to generate hash of commit
2 changed files with 23 additions and 28 deletions

23
news/bashism_altdot.rst Normal file
View file

@ -0,0 +1,23 @@
**Added:**
* <news item>
**Changed:**
* <news item>
**Deprecated:**
* <news item>
**Removed:**
* <news item>
**Fixed:**
* Removed obsolte "Alt+." keybinding in xontrib-bashisms that was causing built-in binding to malfunction.
**Security:**
* <news item>

View file

@ -3,10 +3,6 @@ import shlex
import sys
import re
from prompt_toolkit.keys import Keys
from prompt_toolkit.filters import Condition, EmacsInsertMode, ViInsertMode
from xonsh.platform import ptk_shell_type
__all__ = ()
@ -43,30 +39,6 @@ def bash_preproc(cmd, **kw):
return re.sub(r"!([!$^*]|[\w]+)", replace_bang, cmd)
@events.on_ptk_create
def custom_keybindings(bindings, **kw):
if ptk_shell_type() == "prompt_toolkit2":
handler = bindings.add
@Condition
def last_command_exists():
return len(__xonsh__.history) > 0
else:
handler = bindings.registry.add_binding
@Condition
def last_command_exists(cli):
return len(__xonsh__.history) > 0
insert_mode = ViInsertMode() | EmacsInsertMode()
@handler(Keys.Escape, ".", filter=last_command_exists & insert_mode)
def recall_last_arg(event):
arg = __xonsh__.history[-1].cmd.split()[-1]
event.current_buffer.insert_text(arg)
def alias(args, stdin=None):
ret = 0