Will Robertson <[log in to unmask]>, 17.09.2010 07:21:30: > > \def\foo{... > \lccode`#1=`\~ ! Illegal parameter number in definition of \foo. And according to my own experience, it must be \lccode`\~=`#1..., cf. doc.sty \@sverb/\do@noligs and below. > \lowercase{% > \def ~{...} > } > } > > But this requires that ~ is naturally active; Sure? In my proposal below, ~ is only locally active. > and that's not necessarily always a good assumption > (well, in expl3 isn't definitely not). Arno Trautmann [, 17.09.2010 21:53:19 > > \define_active_char:Nn <character> {<code>} > > which makes the <character> active and assigns the given code to it, > internally using the code that Will wrote. \begingroup \catcode`\~=13 \gdef\define_active_char:Nn#1#2{% \catcode`#113% \begingroup \lccode`\~`#1% \lowercase{\endgroup \def ~{#2}}% } \endgroup Not tested exactly this way, sorry, but in a so far private package of mine, I have \providecommand*{\MakeActiveDef}[2]{% \catcode`#1\active \begingroup \lccode`\~`#1% \lowercase{\endgroup \def ~{#2}}% } so (unless another definition of \MakeActiveDef occurs earlier) \MakeActiveDef and \define_active_char:Nn almost have the same meaning (\active vs. 13, in case LaTeX3 won't have \active). The \endgroup trick here is from doc.sty's \[log in to unmask] Admittedly \MakeActiveDef has a single instance (though vital) at present, but I have an analogous \MakeActiveLet in niceverb.sty (ctan.org/pkg/nicetext) that has several vital instances (active characters) and has been used in at least one large-scale project. Actually, I prefer \MakeActiveLet to \MakeActiveDef, \MakeActiveDef only exists because I was (for some minutes) unable to use \MakeActiveLet in that other package. I favor \MakeActiveLet for the case that the meaning of a single active character might be wanted to change, so you store intended meanings as macros \@if@active@i, \@if@active@ii, ... and then switch \MakeActiveLet\<char>\@if@active@i somewhere, \MakeActiveLet\<char>\@if@active@ii somewhere else ... Cheers, Uwe. Will Robertson <[log in to unmask]>, 17.09.2010 07:21:30: > > \def\foo{... > \lccode`#1=`\~ ! Illegal parameter number in definition of \foo. And according to my own experience, it must be \lccode`\~=`#1..., cf. doc.sty \@sverb/\do@noligs and below. > \lowercase{% > \def ~{...} > } > } > > But this requires that ~ is naturally active; Sure? In my proposal below, ~ is only locally active. > and that's not necessarily always a good assumption > (well, in expl3 isn't definitely not). Arno Trautmann [, 17.09.2010 21:53:19 > > \define_active_char:Nn <character> {<code>} > > which makes the <character> active and assigns the given code to it, > internally using the code that Will wrote. \begingroup \catcode`\~=13 \gdef\define_active_char:Nn#1#2{% \catcode`#113% \begingroup \lccode`\~`#1% \lowercase{\endgroup \def ~{#2}}% } \endgroup Not tested exactly this way, sorry, but in a so far private package of mine, I have \providecommand*{\MakeActiveDef}[2]{% \catcode`#1\active \begingroup \lccode`\~`#1% \lowercase{\endgroup \def ~{#2}}% } so (unless another definition of \MakeActiveDef occurs earlier) \MakeActiveDef and \define_active_char:Nn almost have the same meaning (\active vs. 13, in case LaTeX3 won't have \active). The \endgroup trick here is from doc.sty's \[log in to unmask] Admittedly \MakeActiveDef has a single instance (though vital) at present, but I have an analogous \MakeActiveLet in niceverb.sty (ctan.org/pkg/nicetext) that has several vital instances (active characters). Actually, I prefer \MakeActiveLet to \MakeActiveDef, \MakeActiveDef only exists because I was for some minutes unable to use \MakeActiveLet in that other package. I favor \MakeActiveLet for the case that the meaning of a single active character might be wanted to change, so you store intended meanings as macros \@if@active@i, \@if@active@ii, ... and then switch \MakeActiveLet<char>\@if@active@i somewhere, \MakeActiveLet<char>\@if@active@ii somewhere else ... Cheers, Uwe.