From a68ce2bf51ee50a7fc315ed7f3d6dc8fc71aa19b Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Tue, 3 Feb 2015 13:56:55 +0000 Subject: [PATCH] small improvement of autoedit.asciidoc --- doc/autoedit.asciidoc | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) 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 ] ] +-------------------------------------------------------------------------------