NOTE: I have to adapt this question to reflect Martin's answer (that actually not 100% solves the original problem) so I can accept it. :-)
If I work without standalone document class, I usually put the following setting
\newsavebox\IBox
\savebox\IBox{\raisebox{\depth}[\totalheight]{XeTeX runs very slowly!}}
% trimmed for simplicity
in the preamble.
However, when using standalone document class (to divide my project into one main input file & several sub-files), I am forced to move a setting related to each sub-file to its body as follows.
% sub-file.tex
\documentclass{standalone}
\usepackage{pstricks}
\begin{document}
\newsavebox\IBox%
\savebox\IBox{\raisebox{\depth}[\totalheight]{XeTeX runs very slowly!}}%
% trimmed for simplicity
\begin{pspicture}(\LEFT,\BOTTOM)(\RIGHT,\TOP)
% trimmed for simplicity
\end{pspicture}%
\end{document}
Adding a trailing % to the end of each line of setting code is cumbersome so I need a way not to do this manually. The following code shows what I need; There is a \RemoveTrailingSpaceInThisBlock macro to do the job.
% sub-file.tex
\documentclass{standalone}
\usepackage{pstricks}
\begin{document}
\RemoveTrailingSpaceInThisBlock% to remove trailing space in the current block
\newsavebox\IBox
\savebox\IBox{\raisebox{\depth}[\totalheight]{XeTeX runs very slowly!}}
% trimmed for simplicity
\begin{pspicture}(\LEFT,\BOTTOM)(\RIGHT,\TOP)
% trimmed for simplicity
\end{pspicture}
\end{document}
Is there such a macro to remove the trailing spaces at the end of each line in a code block?

\fbox{..}inside the environment, not the other way around. – Lev Bishop Aug 2 '11 at 7:10