bug-texinfo
[Top][All Lists]

## Re: rethinking @def*

 From: Gavin Smith Subject: Re: rethinking @def* Date: Fri, 29 Jul 2022 16:14:16 +0100

On Thu, Jul 28, 2022 at 03:52:21PM +0100, Gavin Smith wrote:
> On Thu, Jul 28, 2022 at 04:27:28PM +0200, pertusus@free.fr wrote:
> > I tested with Texinfo TeX @t{\f[}@r{@slanted{font}}@t{]} (which is the
> > fourth line deffn name) in the argument part of @deffn, and the brackets
> > remain in roman font.  I could not find any combination of @-command
> > that could format the bracket in anything else than roman font.
> > Which means that if you would have wanted to use typewriter brackets in
> > the argument, you wouldn't have been able to, as far as I can tell.
> > It works because it is in the name of the @deffn, but does not in the
> > argument of the @deffn.
> >
> > This seems wrong to me, not to be able to specify the font of the
> > bracket in def* arguments.  Not sure what can be done, though,
> > except for removing completly the code that makes brackets upright
> > and letting the user do the formatting herself.
>
> I agree this should be possible.
>
> I expect we could fix texinfo.tex to turn off this code inside
> font commands on a @def* line, along with the code for ampersand that
> was causing a problem in your other message.

Here's the fix, on top of the earlier change for ampersand:

diff --git a/doc/texinfo.tex b/doc/texinfo.tex
--- a/doc/texinfo.tex
+++ b/doc/texinfo.tex
@@ -2818,7 +2818,7 @@ end
\let\emph=\smartitalic

% Explicit font changes: @r, @sc, undocumented @ii.
-\def\r#1{{\stopmagicamp\rm #1}} % roman font, used for code comment
+\def\r#1{{\defcharsdefault\rm #1}} % roman font, used for code comment
\def\sc#1{{\smallcaps#1}}       % smallcaps font
\def\ii#1{{\it #1}}             % italic font

@@ -7881,13 +7881,15 @@ might help (with 'rm \jobname.?? \jobname.??s')%
% so TeX would otherwise complain about undefined control sequence.
{
\activeparens
-  \global\let(=\lparen \global\let)=\rparen
-  \global\let[=\lbrack \global\let]=\rbrack
-  \global\let& = \&
+  \gdef\defcharsdefault{%
+    \let(=\lparen \let)=\rparen
+    \let[=\lbrack \let]=\rbrack
+    \let& = \&%
+  }
+  \globaldefs=1 \defcharsdefault

\gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb}
\gdef\magicamp{\let&=\amprm}
-  \gdef\stopmagicamp{\let&=\&}
}
\let\ampchar\&

This is limited to @r, so your test case

@t{\f[}@r{@slanted{font}}@t{]}

would still have roman square brackets.  It would have to become

@t{\f@r{@t{[}}}@r{@slanted{font}}@r{@t{]}}

which is not what anybody wants to be writing.

It would be simple to add the \defcharsdefault control sequence to
the definition of @t too, and I think it makes sense to do this.
It would be an abuse of the semantics of @r as a metasyntactic
escape to use it for syntactic characters like [ or ].