When a function is called, I would like to remove any leading space. Then the function can control the spacing. If I don't remove spaces, it then makes a difference whether or not I have a space before the function is called.


I would like the output of the following two lines to be equal:
This is a \MyFunction[1] test.
This is a\MyFunction[1] test.


However, they are not because the first line has a space before the function call.


\def\MyFunction{\dosingleempty\doMyFunction}
\def\doMyFunction[#1]{%
\processaction[#1]%
[1=>\medspace dog ,%
2=>\medspace cat ,%
default=>\ldots]%
}


\starttext
Test1: This is a\MyFunction[1] test.


Test2: This is a \MyFunction[1] test.


Test3: This is a \MyFunction test.


Test4: This is a\MyFunction test.
\stoptext


Is there a way to do this and not cause any side effects?


Thanks,
Bart