Having been writing small lib for TikZ, I tried to use this macro in order to search for @. Code compiled, but the result was false, despite that I was sure it was in tested string. So, I decided to look into an implementation of this macro, but it breaks my brain by self-recursive usage of pgfutil@in@ and pgfutil@in@@. Could someone explain how that manages to work? And, furthermore, if it can be changed to make search for @ applicable?
% pgfutil@in@
\newif\ifpgfutil@in@
% Usage:
% \pgfutil@in@{one}{three two one}
% \ifpgfutil@in@
% -> will be true!
% \else
% \fi
%
% \pgfutil@in@{,}{1234,456567}
% \ifpgfutil@in@
% -> will be true!
% \else
% \fi
\def\pgfutil@in@#1#2{%
\def\pgfutil@in@@##1#1##2##3\pgfutil@in@@{%
\ifx\pgfutil@in@##2\pgfutil@in@false\else\pgfutil@in@true\fi}%
\pgfutil@in@@#2#1\pgfutil@in@\pgfutil@in@@}
I expect that there must be some way to tweak it by means of catcode...
EDIT:
Usage example:
\edef \pgf@marshal{\noexpand \pgfutil@in@{@}{\tikz@temp}}%
\pgf@marshal%
EDIT 2:
I discovered that using \pgfutil@in@{@}{\tikz@temp} from document context with set \makeatletter I don't encounter any problems even with searching for @ directly.
Having investigated into how TikZ includes libraries, I found that it saves category code for @, sets it to 11, includes library, then restores the category code for @. So it's ok to define macroses with @ in the name.
But before executing \pgfutil@in@{@}{\tikz@temp} (now inside some macros in my library) I do:
\c@pgf@counta = \catcode`\@%
\showthe \c@pgf@counta%
and see that pdflatex outputs 12. Hmmm... I guess this is due to that macroses in my library are just read and saved for later use. They're executed inside the document environment, when the category code for @ is already 12. Made such a suggestion I tried to put \makeatletter just before the \begin{document} and it worked like a charm!
So, is there a way to somehow alter the category code for @ just in place where it should be 11 by the time of execution?
Another suggestion is that by the time the macros is read the category code for @ is 11, but when being executed, the expanded value of \tikz@temp contains @ of category code 12. So, they will never match, unless I do \makeatletter at the document context.
@wrong somewhere. – Joseph Wright May 04 '11 at 15:02@really deserves a separate question. I suggest you post one, linking to this question for context. (We like to keep each question focussed, where possible.) – Joseph Wright May 04 '11 at 17:45