[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: @linemacro, adapted from @macro implementation
From: |
Gavin D. Smith |
Subject: |
branch master updated: @linemacro, adapted from @macro implementation |
Date: |
Sat, 04 Mar 2023 05:47:33 -0500 |
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 18a1887bb2 @linemacro, adapted from @macro implementation
18a1887bb2 is described below
commit 18a1887bb21e848affc211da9588584a6888f007
Author: Gavin Smith <gavinsmith0123@gmail.com>
AuthorDate: Sat Mar 4 10:47:22 2023 +0000
@linemacro, adapted from @macro implementation
(\linemacro): New macro, to implement @linemacro command.
(\linegetargs, \linegetparamlist, \parselinemacrobody, \linemacrodef):
New macros that are part of the implementation.
This is mainly intended for use with @defblock/@defline.
---
ChangeLog | 10 +++++++
doc/texinfo.tex | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 92 insertions(+), 1 deletion(-)
diff --git a/ChangeLog b/ChangeLog
index 5a6cde1d0b..3f2003b496 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2023-03-04 Gavin Smith <gavinsmith0123@gmail.com>
+
+ @linemacro, adapted from @macro implementation
+
+ (\linemacro): New macro, to implement @linemacro command.
+ (\linegetargs, \linegetparamlist, \parselinemacrobody, \linemacrodef):
+ New macros that are part of the implementation.
+
+ This is mainly intended for use with @defblock/@defline.
+
2023-03-03 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/ParserNonXS.pm (_handle_line_command),
diff --git a/doc/texinfo.tex b/doc/texinfo.tex
index 35f71d5757..a5d40667f3 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-02-19.14}
+\def\texinfoversion{2023-03-04.10}
%
% Copyright 1985, 1986, 1988, 1990-2023 Free Software Foundation, Inc.
%
@@ -8604,6 +8604,87 @@ might help (with 'rm \jobname.?? \jobname.??s')%
\fi \macnamexxx}
+% @linemacro
+
+\parseargdef\linemacro{%
+ \linegetargs#1 \linegetargs
+ \expandafter\linegetparamlist\argl;%
+ \begingroup \macrobodyctxt \usembodybackslash
+ \parselinemacrobody
+}
+
+% Parse the arguments to a @linemacro line. Set \macname to the name
+% of the macro and \argl to the list of arguments.
+\def\linegetargs#1 #2\linegetargs{%
+ \macname={#1}%
+ \def\argl{#2}%
+}
+
+% Build up \paramlist which will be used as the parameter text for the macro.
+% At the end it will be like "#1 #2 #3\endlinemacro".
+\def\linegetparamlist#1;{%
+ \paramno=0\def\paramlist{}%
+ \let\hash\relax \let\xeatspaces\relax
+ \linegetparamlistxxx#1; %
+}
+\def\linegetparamlistxxx#1 {%
+ \if#1;\let\next=\linegetparamlistxxxx
+ \else \let\next=\linegetparamlistxxx
+ \advance\paramno by 1
+ \expandafter\edef\csname macarg.\eatspaces{#1}\endcsname
+ {\noexpand\xeatspaces{\hash\the\paramno}}%
+ \edef\paramlist{\paramlist\hash\the\paramno\space}%
+ \fi\next}
+\def\linegetparamlistxxxx{%
+ \ifx\paramlist\empty
+ \def\paramlist{\hash 1\endlinemacro}%
+ \else
+ \expandafter\fixparamlist\paramlist\fixparamlist
+ \fi
+}
+% Replace final space token
+\def\fixparamlist#1 \fixparamlist{%
+ \def\paramlist{#1\endlinemacro}%
+}
+
+% Read the body of the macro, replacing backslash-surrounded variables
+%
+{\catcode`\ =\other\long\gdef\parselinemacrobody#1@end linemacro{%
+\let\xeatspaces\relax
+\xdef\macrobody{#1}%
+\endgroup
+\linemacrodef
+}}
+
+% Make the definition
+\def\linemacrodef{%
+ \let\hash=##%
+ \let\xeatspaces\relax
+ \expandafter\xdef\csname\the\macname\endcsname{%
+ \bgroup
+ \noexpand\scanctxt
+ \noexpand\parsearg
+ \expandafter\noexpand\csname\the\macname @@\endcsname
+ }
+ \expandafter\xdef\csname\the\macname @@\endcsname##1{%
+ \egroup
+ \expandafter\noexpand
+ \csname\the\macname @@@\endcsname##1 \noexpand\endlinemacro
+ % Note that we append a space to the macro line to terminate the last
+ % argument in case the final argument is empty. @xeatspaces may be needed
+ % to remove this space.
+ }
+ \expandafter\expandafter
+ \expandafter\xdef
+ \expandafter\expandafter\csname\the\macname @@@\endcsname\paramlist{%
+ \newlinechar=13 % split \macrobody into lines
+ \let\noexpand\xeatspaces\noexpand\eatspaces
+ \noexpand\scantokens{\macrobody}%
+ }
+}
+
+
+
% @alias.
% We need some trickery to remove the optional spaces around the equal
% sign. Make them active and then expand them all to nothing.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: @linemacro, adapted from @macro implementation,
Gavin D. Smith <=