texinfo-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

branch master updated: @link in texinfo.tex


From: Gavin D. Smith
Subject: branch master updated: @link in texinfo.tex
Date: Tue, 04 Apr 2023 17:00:04 -0400

This is an automated email from the git hooks/post-receive script.

gavin pushed a commit to branch master
in repository texinfo.

The following commit(s) were added to refs/heads/master by this push:
     new ef81d946c4 @link in texinfo.tex
ef81d946c4 is described below

commit ef81d946c42dded0c7ee66c68c89d951f55b86e6
Author: Gavin Smith <gavinsmith0123@gmail.com>
AuthorDate: Tue Apr 4 21:59:50 2023 +0100

    @link in texinfo.tex
    
    * doc/texinfo.tex (\xrefX, \getprintedrefname, \startxreflink):
    Split out \getprintedrefname and \startxreflink so we can reuse
    this code.
    (\link): New experimental command for creating plain link in
    PDF output with no page number or decoration around link.
    (\definedummies): Add \link.
    
    Suggestion from Andreas Falkenhahn (help-texinfo, February 2023).
---
 ChangeLog       |  13 ++++
 doc/texinfo.tex | 212 +++++++++++++++++++++++++++++++-------------------------
 2 files changed, 131 insertions(+), 94 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 052c0251ca..e6f2f59bce 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2023-04-04  Gavin Smith <gavinsmith0123@gmail.com>
+
+       @link in texinfo.tex
+
+       * doc/texinfo.tex (\xrefX, \getprintedrefname, \startxreflink):
+       Split out \getprintedrefname and \startxreflink so we can reuse
+       this code.
+       (\link): New experimental command for creating plain link in
+       PDF output with no page number or decoration around link.
+       (\definedummies): Add \link.
+
+       Suggestion from Andreas Falkenhahn (help-texinfo, February 2023).
+
 2023-04-03  Gavin Smith <gavinsmith0123@gmail.com>
 
        * tp/Texinfo/XS/parsetexi/def.c (parse_def): Treat @deftypeline
diff --git a/doc/texinfo.tex b/doc/texinfo.tex
index c0a54919a7..9a507c755b 100644
--- a/doc/texinfo.tex
+++ b/doc/texinfo.tex
@@ -3,7 +3,7 @@
 % Load plain if necessary, i.e., if running under initex.
 \expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi
 %
-\def\texinfoversion{2023-03-27.21}
+\def\texinfoversion{2023-04-04.21}
 %
 % Copyright 1985, 1986, 1988, 1990-2023 Free Software Foundation, Inc.
 %
@@ -275,8 +275,7 @@
 % \topmark doesn't work for the very first chapter (after the title
 % page or the contents), so we use \firstmark there -- this gets us
 % the mark with the chapter defs, unless the user sneaks in, e.g.,
-% @setcolor (or @url, or @link, etc.) between @contents and the very
-% first @chapter.
+% @setcolor (or @url etc.) between @contents and the very first @chapter.
 \def\gettopheadingmarks{%
   \ifcase0\the\savedtopmark\fi
   \ifx\thischapter\empty \ifcase0\firstmark\fi \fi
@@ -4950,6 +4949,7 @@ $$%
   \commondummyword\inforef    {}%
   \commondummyword\kbd        {}%
   \commondummyword\key        {}%
+  \commondummyword\link       {}%
   \commondummyword\math       {}%
   \commondummyword\option     {}%
   \commondummyword\pxref      {}%
@@ -8808,17 +8808,103 @@ might help (with 'rm \jobname.?? \jobname.??s')%
 \def\xrefX[#1,#2,#3,#4,#5,#6]{\begingroup
   \unsepspaces
   %
-  % Get args without leading/trailing spaces.
-  \def\printedrefname{\ignorespaces #3}%
-  \setbox\printedrefnamebox = \hbox{\printedrefname\unskip}%
-  %
+  \getprintedrefname{#1}{#3}{#5}%
   \def\infofilename{\ignorespaces #4}%
   \setbox\infofilenamebox = \hbox{\infofilename\unskip}%
   %
-  \def\printedmanual{\ignorespaces #5}%
+  \startxreflink{#1}{#4}%
+  {%
+    % Have to otherify everything special to allow the \csname to
+    % include an _ in the xref name, etc.
+    \indexnofonts
+    \turnoffactive
+    \def\value##1{##1}%
+    \expandafter\global\expandafter\let\expandafter\Xthisreftitle
+      \csname XR#1-title\endcsname
+  }%
+  %
+  % Float references are printed completely differently: "Figure 1.2"
+  % instead of "[somenode], p.3".  \iffloat distinguishes them by
+  % \Xthisreftitle being set to a magic string.
+  \iffloat\Xthisreftitle
+    % If the user specified the print name (third arg) to the ref,
+    % print it instead of our usual "Figure 1.2".
+    \ifdim\wd\printedrefnamebox = 0pt
+      \refx{#1-snt}%
+    \else
+      \printedrefname
+    \fi
+    %
+    % If the user also gave the printed manual name (fifth arg), append
+    % "in MANUALNAME".
+    \ifdim \wd\printedmanualbox > 0pt
+      \space \putwordin{} \cite{\printedmanual}%
+    \fi
+  \else
+    % node/anchor (non-float) references.
+    %
+    % If we use \unhbox to print the node names, TeX does not insert
+    % empty discretionaries after hyphens, which means that it will not
+    % find a line break at a hyphen in a node names.  Since some manuals
+    % are best written with fairly long node names, containing hyphens,
+    % this is a loss.  Therefore, we give the text of the node name
+    % again, so it is as if TeX is seeing it for the first time.
+    %
+    \ifdim \wd\printedmanualbox > 0pt
+      % Cross-manual reference with a printed manual name.
+      %
+      \crossmanualxref{\cite{\printedmanual\unskip}}%
+    %
+    \else\ifdim \wd\infofilenamebox > 0pt
+      % Cross-manual reference with only an info filename (arg 4), no
+      % printed manual name (arg 5).  This is essentially the same as
+      % the case above; we output the filename, since we have nothing else.
+      %
+      \crossmanualxref{\code{\infofilename\unskip}}%
+    %
+    \else
+      % Reference within this manual.
+      %
+      % Only output a following space if the -snt ref is nonempty, as the ref
+      % will be empty for @unnumbered and @anchor.
+      \setbox2 = \hbox{\ignorespaces \refx{#1-snt}}%
+      \ifdim \wd2 > 0pt \refx{#1-snt}\space\fi
+      %
+      % output the `[mynode]' via the macro below so it can be overridden.
+      \xrefprintnodename\printedrefname
+      %
+      \ifflagclear{txiomitxrefpg}{%
+        % We always want a comma
+        ,%
+        % output the `page 3'.
+        \turnoffactive \putpageref{#1}%
+        % Add a , if xref followed by a space
+        \if\space\noexpand\tokenafterxref ,%
+        \else\ifx\     \tokenafterxref ,% @TAB
+        \else\ifx\*\tokenafterxref ,%   @*
+        \else\ifx\ \tokenafterxref ,%   @SPACE
+        \else\ifx\
+                  \tokenafterxref ,%    @NL
+        \else\ifx\tie\tokenafterxref ,% @tie
+        \fi\fi\fi\fi\fi\fi
+      }{}%
+    \fi\fi
+  \fi
+  \endlink
+\endgroup}
+
+% \getprintedrefname{NODE}{LABEL}{MANUAL}
+% - set \printedrefname and \printedmanual
+%
+\def\getprintedrefname#1#2#3{%
+  % Get args without leading/trailing spaces.
+  \def\printedrefname{\ignorespaces #2}%
+  \setbox\printedrefnamebox = \hbox{\printedrefname\unskip}%
+  %
+  \def\printedmanual{\ignorespaces #3}%
   \setbox\printedmanualbox  = \hbox{\printedmanual\unskip}%
   %
-  % If the printed reference name (arg #3) was not explicitly given in
+  % If the printed reference name (arg #2) was not explicitly given in
   % the @xref, figure out what we want to use.
   \ifdim \wd\printedrefnamebox = 0pt
     % No printed node name was explicitly given.
@@ -8842,8 +8928,10 @@ might help (with 'rm \jobname.?? \jobname.??s')%
       \fi
     \fi
   \fi
-  %
-  % Make link in pdf output.
+}
+
+% \startxreflink{NODE}{FILE} - start link in pdf output.
+\def\startxreflink#1#2{%
   \ifpdf
     % For pdfTeX and LuaTeX
     {\indexnofonts
@@ -8851,8 +8939,8 @@ might help (with 'rm \jobname.?? \jobname.??s')%
      \turnoffactive
      % This expands tokens, so do it after making catcode changes, so _
      % etc. don't get their TeX definitions.  This ignores all spaces in
-     % #4, including (wrongly) those in the middle of the filename.
-     \getfilename{#4}%
+     % #2, including (wrongly) those in the middle of the filename.
+     \getfilename{#2}%
      %
      % This (wrongly) does not take account of leading or trailing
      % spaces in #1, which should be ignored.
@@ -8880,8 +8968,8 @@ might help (with 'rm \jobname.?? \jobname.??s')%
        \turnoffactive
        % This expands tokens, so do it after making catcode changes, so _
        % etc. don't get their TeX definitions.  This ignores all spaces in
-       % #4, including (wrongly) those in the middle of the filename.
-       \getfilename{#4}%
+       % #2, including (wrongly) those in the middle of the filename.
+       \getfilename{#2}%
        %
        % This (wrongly) does not take account of leading or trailing
        % spaces in #1, which should be ignored.
@@ -8911,85 +8999,7 @@ might help (with 'rm \jobname.?? \jobname.??s')%
       \setcolor{\linkcolor}%
     \fi
   \fi
-  {%
-    % Have to otherify everything special to allow the \csname to
-    % include an _ in the xref name, etc.
-    \indexnofonts
-    \turnoffactive
-    \def\value##1{##1}%
-    \expandafter\global\expandafter\let\expandafter\Xthisreftitle
-      \csname XR#1-title\endcsname
-  }%
-  %
-  % Float references are printed completely differently: "Figure 1.2"
-  % instead of "[somenode], p.3".  \iffloat distinguishes them by
-  % \Xthisreftitle being set to a magic string.
-  \iffloat\Xthisreftitle
-    % If the user specified the print name (third arg) to the ref,
-    % print it instead of our usual "Figure 1.2".
-    \ifdim\wd\printedrefnamebox = 0pt
-      \refx{#1-snt}%
-    \else
-      \printedrefname
-    \fi
-    %
-    % If the user also gave the printed manual name (fifth arg), append
-    % "in MANUALNAME".
-    \ifdim \wd\printedmanualbox > 0pt
-      \space \putwordin{} \cite{\printedmanual}%
-    \fi
-  \else
-    % node/anchor (non-float) references.
-    % 
-    % If we use \unhbox to print the node names, TeX does not insert
-    % empty discretionaries after hyphens, which means that it will not
-    % find a line break at a hyphen in a node names.  Since some manuals
-    % are best written with fairly long node names, containing hyphens,
-    % this is a loss.  Therefore, we give the text of the node name
-    % again, so it is as if TeX is seeing it for the first time.
-    % 
-    \ifdim \wd\printedmanualbox > 0pt
-      % Cross-manual reference with a printed manual name.
-      % 
-      \crossmanualxref{\cite{\printedmanual\unskip}}%
-    %
-    \else\ifdim \wd\infofilenamebox > 0pt
-      % Cross-manual reference with only an info filename (arg 4), no
-      % printed manual name (arg 5).  This is essentially the same as
-      % the case above; we output the filename, since we have nothing else.
-      % 
-      \crossmanualxref{\code{\infofilename\unskip}}%
-    %
-    \else
-      % Reference within this manual.
-      %
-      % Only output a following space if the -snt ref is nonempty, as the ref
-      % will be empty for @unnumbered and @anchor.
-      \setbox2 = \hbox{\ignorespaces \refx{#1-snt}}%
-      \ifdim \wd2 > 0pt \refx{#1-snt}\space\fi
-      %
-      % output the `[mynode]' via the macro below so it can be overridden.
-      \xrefprintnodename\printedrefname
-      %
-      \ifflagclear{txiomitxrefpg}{%
-        % We always want a comma
-        ,%
-        % output the `page 3'.
-        \turnoffactive \putpageref{#1}%
-        % Add a , if xref followed by a space
-        \if\space\noexpand\tokenafterxref ,%
-        \else\ifx\     \tokenafterxref ,% @TAB
-        \else\ifx\*\tokenafterxref ,%   @*
-        \else\ifx\ \tokenafterxref ,%   @SPACE
-        \else\ifx\
-                  \tokenafterxref ,%    @NL
-        \else\ifx\tie\tokenafterxref ,% @tie
-        \fi\fi\fi\fi\fi\fi
-      }{}%
-    \fi\fi
-  \fi
-  \endlink
-\endgroup}
+}
 
 % can be overridden in translation files
 \def\putpageref#1{%
@@ -9028,6 +9038,20 @@ might help (with 'rm \jobname.?? \jobname.??s')%
 %
 \def\xrefprintnodename#1{[#1]}
 
+% @link{NODENAME, LABEL, MANUAL} - create a "plain" link, with no
+% page number.  Not useful if printed on paper.
+%
+\def\link#1{\linkX[#1,,,]}
+\def\linkX[#1,#2,#3,#4]{%
+  \begingroup
+  \getprintedrefname{#1}{#2}{#3}%
+  \startxreflink{#1}{#3}%
+  \printedrefname
+  \endlink
+  \endgroup
+}
+
+
 % Things referred to by \setref.
 %
 \def\Ynothing{}



reply via email to

[Prev in Thread] Current Thread [Next in Thread]