LATEX-L Archives

Mailing list for the LaTeX3 project

LATEX-L@LISTSERV.UNI-HEIDELBERG.DE

Options: Use Forum View

Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Heiko Oberdiek <[log in to unmask]>
Reply To:
Mailing list for the LaTeX3 project <[log in to unmask]>
Date:
Sat, 18 Sep 2010 01:33:51 +0200
Content-Type:
text/plain
Parts/Attachments:
text/plain (77 lines)
On Fri, Sep 17, 2010 at 11:34:50PM +0200, Uwe Lueck wrote:

> > \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}}%
>     }

But then the contents of #2 is converted to lowercase, too.
The trick is to move the (parameter text and) definition text
outside of \lowercase:

    \providecommand*{\MakeActiveDef}[2]{%
      \catcode`#1\active
      \begingroup
        \lccode`\~`#1%
        \lowercase{\endgroup \def ~}{#2}%
    }

or even

    \providecommand*{\MakeActiveDef}[1]{%
      \catcode`#1\active
      \begingroup
        \lccode`\~`#1%
        \lowercase{\endgroup \def ~}%
    }

The latter allows definition of active chars with parameters:

  \MakeActiveDef{\+}#1{Do something with #1}


> The \endgroup trick here is from doc.sty's \[log in to unmask]

doc.sty contains:

  \def\verbatim@nolig@list{\do\`\do\<\do\>\do\,\do\'\do\-}
  \def\do@noligs#1{%
    \catcode`#1\active
    \begingroup
       \lccode`\~=`#1\relax
       \lowercase{\endgroup\def~{\leavevmode\kern\z@\char`#1}}}

\do@noligs is lucky, if used with \verbatim@nolig@list, because
#1 always contains a command token that is not affected by \lowercase.
However '`' could have an unexpected \lccode value.
Therefore I suggest

  \def\do@noligs#1{%
    \catcode`#1\active
    \begingroup
      \lccode`\~=`#1\relax
    \lowercase{\endgroup\def~}{\leavevmode\kern\z@\char`#1}%
  }

Yours sincerely
  Heiko <[log in to unmask]>

ATOM RSS1 RSS2