🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.text.tex
Article #113

Re: REAL HACKER'S QUIZZ: redefine \input

#113
From: Donald Arseneau
Date: Fri, 30 Oct 1992 08:28
42 lines
1934 bytes
In article <ORLOFF.92Oct29192755@surya4.cern.ch>, orloff@surya4.cern.ch (Jean Orloff) writes...
>Let me rephrase the heart of my problem: suppose I have a control
>sequence \text containg a_11, b_11, {_1, c_11, }_2. How would I change
>the catcodes of the inner braces???

I don't see how this helps one redefine \input.  But anyway...

%  Here is a way to re-catcode a macro to "other."
%  If there are \'s in the macro replacement text, there might be 
%  some extra space inserted (\that) -> (\that ).
%  It goes to some pain to fix doubled # signs.

% \recatcode takes a single macro as its parameter and redefines that
% macro so its replacement text is all catcoded "other"

{\catcode`\@=11

\gdef\@meaningless#1:->{\@undoublehash}%

\gdef\@gobblethree#1#2#3{}

\catcode`\&=6 \catcode`\#=12 % use & for macro parameters while # is "other"

\gdef\recatcode&1{%
  \toks@=\expandafter{&1}\edef\n@@t{\the\toks@}% prevents error message with #
  \edef&1{\expandafter\@meaningless\meaning\n@@t#\@gobblethree#}}%

\gdef\@undoublehash &1#&2#{&1%
  % if ## emit #\@undoublehash
  % if #\@gobble# emit nothing
  % if #other# emit #other#\@undoublehash (can't happen(?))
  \ifx&2\@gobblethree\@gobblethree #\expandafter\@undoublehash
  \else #&2#\expandafter\@undoublehash\fi} 

}

\tracingall

\def\text{ab{c}} \tt \text
\recatcode\text \text.

\bye    Donald Arseneau
Technical Details
Message-ID: <30OCT199201285728@erich.triumf.ca>
Path: arc1-ca.pugleaf.net!sparky!uunet!destroyer!cs.ubc.ca!unixg.ubc.ca!erich.triumf.ca!asnd
References: <ORLOFF.92Oct26182957@surya4.cern.ch> <ORLOFF.92Oct29192755@surya4.cern.ch>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!destroyer!cs.ubc.ca!unixg.ubc.ca!erich.triumf.ca!asnd
From: asnd@erich.triumf.ca (Donald Arseneau)
Newsgroups: comp.text.tex
Subject: Re: REAL HACKER'S QUIZZ: redefine \input
Date: 30 Oct 1992 01:28 PDT
Organization: TRIUMF: Tri-University Meson Facility
Lines: 42
Distribution: world
Message-ID: <30OCT199201285728@erich.triumf.ca>
References: <ORLOFF.92Oct26182957@surya4.cern.ch> <ORLOFF.92Oct29192755@surya4.cern.ch>
NNTP-Posting-Host: erich.triumf.ca
News-Software: VAX/VMS VNEWS 1.41