newedit: Add $edit:commit-eof~.

This commit is contained in:
Qi Xiao 2018-11-18 16:24:12 +01:00
parent bacedb1b7d
commit 21860df2ce
3 changed files with 13 additions and 2 deletions

View File

@ -23,9 +23,18 @@ func exitBinding() error {
//elvish:doc-fn commit-code
//
// Causes the current editor session to terminate, committing the code that is
// being edited. Internally, this works by raising a special exception.
// Causes the Elvish REPL to end the current read iteration and evaluate the
// code it just read. Internally, this works by raising a special exception.
func commitCode() error {
return editutil.ActionError(types.CommitCode)
}
//elvish:doc-fn commit-eof
//
// Causes the Elvish REPL to terminate. Internally, this works by raising a
// special exception.
func commitEOF() error {
return editutil.ActionError(types.CommitEOF)
}

View File

@ -3,6 +3,7 @@ package newedit
// Elvish code for default bindings, assuming the editor ns as the global ns.
const defaultBindingsElv = `
insert:binding = (binding-map [
&Ctrl-D= $commit-eof~
&Default= $insert:default-handler~
])
`

View File

@ -33,6 +33,7 @@ func NewEditor(in, out *os.File, ev *eval.Evaler) *Editor {
"binding-map": makeBindingMap,
"exit-binding": exitBinding,
"commit-code": commitCode,
"commit-eof": commitEOF,
})
// Hooks