package edit

import (
	
	
	
	
	
)

//elvdoc:var -instant:binding
//
// Binding for the instant mode.

//elvdoc:fn -instant:start
//
// Starts the instant mode. In instant mode, any text entered at the command
// line is evaluated immediately, with the output displayed.
//
// **WARNING**: Beware of unintended consequences when using destructive
// commands. For example, if you type `sudo rm -rf /tmp/*` in the instant mode,
// Elvish will attempt to evaluate `sudo rm -rf /` when you typed that far.

func ( *Editor,  *eval.Evaler,  eval.NsBuilder) {
	 := newBindingVar(emptyBindingsMap)
	 := newMapBindings(, , )
	.AddNs("-instant",
		eval.NsBuilder{
			"binding": ,
		}.AddGoFns("<edit:-instant>:", map[string]interface{}{
			"start": func() { instantStart(.app, , ) },
		}).Ns())
}

func ( cli.App,  *eval.Evaler,  tk.Bindings) {
	 := func( string) ([]string, error) {
		, ,  := eval.StringCapturePort()
		if  != nil {
			return nil, 
		}
		 = .Eval(
			parse.Source{Name: "[instant]", Code: },
			eval.EvalCfg{
				Ports:     []*eval.Port{nil, },
				Interrupt: eval.ListenInterrupts})
		return (), 
	}
	,  := mode.NewInstant(,
		mode.InstantSpec{Bindings: , Execute: })
	if  != nil {
		.SetAddon(, false)
		.Redraw()
	}
	if  != nil {
		.Notify(.Error())
	}
}