diff --git a/doc/autoedit.asciidoc b/doc/autoedit.asciidoc index 6a4b14a9..c6936e20 100644 --- a/doc/autoedit.asciidoc +++ b/doc/autoedit.asciidoc @@ -32,17 +32,21 @@ note that if nothing gets selected on phase *2.*, an error will be raised. We want to do that each time the user jumps a line, just after the new line is inserted. So the hook would be: ------------------------------------------------------- -:hook InsertChar \n %{ exec ks^\h+yjP } ------------------------------------------------------- +-------------------------------------------------------- +:hook InsertChar \n %{ exec k s^\h+y jP } +-------------------------------------------------------- + +(exec concatenates the keys for all argument, so the spaces will be ignored, +allowing for clearer separation. either use or quote the argument to +use a space key) That works, however if the phase *2.* raises an error, the +:exec+ will stop and the user will get it's selections on the previous line. the solution is to use a *draft* context, instead of the one the user is interacting with. -------------------------------------------------------------- -:hook InsertChar \n %{ exec -draft ks^\h+yjP } -------------------------------------------------------------- +--------------------------------------------------------------- +:hook InsertChar \n %{ exec -draft k s^\h+y jP } +--------------------------------------------------------------- That way, exec is executed in a *copy* of the user's context, which means it manipulates a *copy* of the user's selections. @@ -77,7 +81,7 @@ it will write informations about it in the debug buffer, which we do not want, as this is actually expected. In order to prevent that, the exec should be wrapped in a try command. So we would have: ------------------------------------------------------------------------------ -:hook InsertChar \n %[ try %[ exec -draft k[{(]\h*$j ] ] ------------------------------------------------------------------------------ +------------------------------------------------------------------------------- +:hook InsertChar \n %[ try %[ exec -draft k [{(]\h*$ j ] ] +-------------------------------------------------------------------------------