On 8 August 2015 at 22:05, Gavin Smith <[email protected]> wrote:
>> I'd like to make the @macroargdummy token completely disappear at some
>> point, but maybe it isn't possible.
>
> Doing \def\macroargdummy{} in \scanmacro also makes the files I tried
> work. It didn't the first time I tried, maybe because I had stale
> index files.

That last patch I posted doesn't work properly when a macro defines an
index entry, because of changes in the active definition of backslash
down under the definition of \cindex (\normalturnoffactive underneath
\commondummies).

Here's a change that I think's nicer, which does the expansion of the
active backslash earlier as an extra stage of expansion.
Index: doc/texinfo.tex
===================================================================
--- doc/texinfo.tex     (revision 6493)
+++ doc/texinfo.tex     (working copy)
@@ -7460,7 +7460,8 @@
 
 \def\macroargctxt{% used when scanning invocations
   \scanctxt
-  \catcode`\\=0
+  \catcode`\\=\active
+  %\catcode`\\=0
 }
 % why catcode 0 for \ in the above?  To recognize \\ \{ \} as "escapes"
 % for the single characters \ { }.  Thus, we end up with the "commands"
@@ -7907,16 +7908,51 @@
 
 \def\norecurse#1{\bgroup\cslet{#1}{macsave.#1}}
 
+% Call #1 with a list of tokens #2, with any doubled backslashes in #2
+% compressed to one.
+\def\passargtomacro#1#2{%
+% Append an unexpandable token to #2, to allows a trailing
+% active backslash in the argument not to eat the next token.
+\let\macroargdummy=\relax
+\def\arg{#2\macroargdummy}%
+%
+% Expand the arg list.  There won't be unwanted expansion of control sequences 
+% in the argument because the arg was read with the catcode of @ as \other.
+\let\resultingbackslash=\relax % prevent expansion
+\usemacroargbackslash
+\def\macroargdummy{}%
+\edef\arg{\arg}%
+\expandafter#1\expandafter{\arg}%
+}
+
+% use active definition of backslash at time of expansion
+\def\resultingbackslash{\activebackslash}
+
+% \macroargbackslash
+% - expand \\ and single \ as \resultingbackslash
+{ \catcode`\@=0 @catcode`@\=@active
+@gdef@macroargbackslash#1{%
+% we need noexpand because \ is active
+@if @noexpand \@noexpand #1@resultingbackslash%
+@else @resultingbackslash #1%
+@fi}
+
+@gdef@usemacroargbackslash{@let\=@macroargbackslash}
+}
+
+
 % \braceorline MAC is used for a one-argument macro MAC.  It checks
 % whether the next non-whitespace character is a {.  It sets the context
 % for reading the argument (slightly different in the two cases).  Then,
-% to read the argument, in the whole-line case, it then calls the
-% regular \parsearg MAC; in the lbrace case, it just calls MAC itself.
+% to read the argument, in the whole-line case, it then calls the regular
+% \parsearg MAC; in the lbrace case, it calls \passargtomacro MAC.
 % 
 \def\braceorline#1{\let\macnamexxx=#1\futurelet\nchar\braceorlinexxx}
 \def\braceorlinexxx{%
-  \ifx\nchar\bgroup\macroargctxt
-  \else\macrolineargctxt\expandafter\parsearg
+  \ifx\nchar\bgroup
+    \macroargctxt\expandafter\passargtomacro
+  \else
+    \macrolineargctxt\expandafter\parsearg
   \fi \macnamexxx}
 
 
@@ -10292,7 +10328,10 @@
 % catcode other.  We switch back and forth between these.
 @gdef@rawbackslash{@let\=@backslashcurfont}
 @gdef@otherbackslash{@let\=@realbackslash}
+@gdef@usenormalbackslash{@let\=@normalbackslash}
 
+{@catcode`@\=@active @gdef@activebackslash{\}}
+
 @gdef@usemathbackslash{@def@backslashcurfont{@math{@backslash}}}
 
 % Same as @turnoffactive except outputs \ as {\tt\char`\\} instead of

Reply via email to