summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/changes/changes.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/source/latex/changes/changes.dtx')
-rw-r--r--Master/texmf-dist/source/latex/changes/changes.dtx171
1 files changed, 126 insertions, 45 deletions
diff --git a/Master/texmf-dist/source/latex/changes/changes.dtx b/Master/texmf-dist/source/latex/changes/changes.dtx
index 1fc50b29ccc..b437f0d248d 100644
--- a/Master/texmf-dist/source/latex/changes/changes.dtx
+++ b/Master/texmf-dist/source/latex/changes/changes.dtx
@@ -1,4 +1,4 @@
-% \CheckSum{822}
+% \CheckSum{860}
%
% \iffalse meta-comment
%
@@ -47,6 +47,7 @@
% \changes{v0.5.3}{2010/11/22}{use class options (final, draft) as well}
% \changes{v0.5.4}{2011/04/25}{extract user documentation; default language changed to English; script for removal of commands}
% \changes{v0.6.0}{2012/01/11}{redefined user interface for setting options, markup, authors; newly structured documentation}
+% \changes{v1.0.0}{2012/04/25}{key-value-interface for change commands; special characters in list of changes}
% \GetFileInfo{changes.dtx}
% \RecordChanges
%
@@ -86,8 +87,8 @@
% \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{changes}
-[2012/01/11 v0.6.0 changes-Paket]
-\typeout{*** changes-Paket 2012/01/11 v0.6.0 ***}
+[2012/04/25 v1.0.0 changes-Paket]
+\typeout{*** changes-Paket 2012/04/25 v1.0.0 ***}
% \end{macrocode}
%
% Package \chpackage{xkeyval} provides options with key-value-pairs.
@@ -309,6 +310,8 @@
%
% All options for commands (e.g. \chcommand{definechangesauthor}) have to be declared before option processing.
%
+% \minisec{\chcommand{definechangesauthor}}
+%
% Declare available options of the command, define value storage.
% \begin{macrocode}
\DeclareOptionX<Changes@definechangesauthor>{name}{\def\Changes@definechangesauthor@name{#1}}
@@ -323,6 +326,54 @@
}{}
% \end{macrocode}
%
+% \minisec{\chcommand{added}}
+%
+% Declare available options of the command, define value storage.
+% \begin{macrocode}
+\DeclareOptionX<Changes@added>{id}{\def\Changes@added@id{#1}}
+\DeclareOptionX<Changes@added>{remark}{\def\Changes@added@remark{#1}}
+% \end{macrocode}
+%
+% Set the default values of the options.
+% \begin{macrocode}
+\presetkeys{Changes@added}{
+ id=\@empty,
+ remark=\@empty
+}{}
+% \end{macrocode}
+%
+% \minisec{\chcommand{deleted}}
+%
+% Declare available options of the command, define value storage.
+% \begin{macrocode}
+\DeclareOptionX<Changes@deleted>{id}{\def\Changes@deleted@id{#1}}
+\DeclareOptionX<Changes@deleted>{remark}{\def\Changes@deleted@remark{#1}}
+% \end{macrocode}
+%
+% Set the default values of the options.
+% \begin{macrocode}
+\presetkeys{Changes@deleted}{
+ id=\@empty,
+ remark=\@empty
+}{}
+% \end{macrocode}
+%
+% \minisec{\chcommand{replaced}}
+%
+% Declare available options of the command, define value storage.
+% \begin{macrocode}
+\DeclareOptionX<Changes@replaced>{id}{\def\Changes@replaced@id{#1}}
+\DeclareOptionX<Changes@replaced>{remark}{\def\Changes@replaced@remark{#1}}
+% \end{macrocode}
+%
+% Set the default values of the options.
+% \begin{macrocode}
+\presetkeys{Changes@replaced}{
+ id=\@empty,
+ remark=\@empty
+}{}
+% \end{macrocode}
+%
% \subsubsection{Option processing}
%
% Process the options.
@@ -448,7 +499,7 @@
% \begin{macrocode}
\newcounter{Changes@AuthorCount}
\setcounter{Changes@AuthorCount}{0}
-\newcounter{Changes@iAuthor}
+\newcounter{Changes@Author}
% \end{macrocode}
%
% \begin{macro}{\definechangesauthor}
@@ -658,7 +709,9 @@
% \item author's id
% \item remark
% \end{enumerate}
+% Define boolean for author test.
% \begin{macrocode}
+\newboolean{Changes@WrongID}
\newcommand{\Changes@output}[4]{%
% \end{macrocode}
% Output changed text if option \choption{draft} is set, otherwise output unchanged text.
@@ -666,6 +719,23 @@
\ifthenelse{\boolean{Changes@optiondraft}}%
{%
% \end{macrocode}
+% Check if the author exists, error message otherwise.
+% I have the feeling that this code is optimizable.
+% \begin{macrocode}
+ \setboolean{Changes@WrongID}{true}%
+ \setcounter{Changes@Author}{0}%
+ \whiledo{\value{Changes@Author} < \value{Changes@AuthorCount}}{%
+ \stepcounter{Changes@Author}%
+ \ifthenelse{\equal{#3}{\@nameuse{Changes@AuthorID\theChanges@Author}}}%
+ {\setboolean{Changes@WrongID}{false}}%
+ {}%
+ }%
+ \ifthenelse{\boolean{Changes@WrongID}}%
+ {\PackageError{changes}%
+ {Undefined changes author: #3}%
+ {You have to define the author #3 with e.g.: \definechangesauthor{#3}}}%
+ {}%
+% \end{macrocode}
% Save author text for output.
% \begin{macrocode}
\ifthenelse{\equal{\Changes@optionauthormarkuptext}{id}}%
@@ -713,31 +783,23 @@
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}{\Changes@temp}
-% Temporary variable for exchange of optional parameters between interlocked commands.
-% \begin{macrocode}
-\newcommand{\Changes@temp}{\@empty}
-% \end{macrocode}
-% \end{macro}
-%
% \begin{macro}{\added}
% The command formats text as new text.
-% Defining a command with two optional parameters is rather complicated.
%
% Mandatory argument: added text.
-% Optional arguments: author's id, remark
+% Optional argument (key-value): author's id, remark
% \begin{macrocode}
-\newcommand{\added}[1][\@empty]{%
- \renewcommand{\Changes@temp}{#1}%
- \Changes@added%
-}
-\newcommand{\Changes@added}[2][\@empty]{%
+\newcommand{\added}[2][\@empty]{%
+% \end{macrocode}
+% Call \emph{setkeys} in order to evaluate the key-value-options and fill the value storage.
+% \begin{macrocode}
+ \setkeys{Changes@added}{#1}%
\Changes@output
{\Changes@Markup@Added{#2}}
{#2}
- {\Changes@temp}
- {#1}%
- \stepcounter{Changes@AddCount\Changes@temp}%
+ {\Changes@added@id}
+ {\Changes@added@remark}%
+ \stepcounter{Changes@AddCount\Changes@added@id}%
}
% \end{macrocode}
% \end{macro}
@@ -749,19 +811,19 @@
% It solves the problem of additional space caused by an empty command.
%
% Mandatory argument: deleted text.
-% Optional arguments: author's id, remark
+% Optional argument (key-value): author's id, remark
% \begin{macrocode}
-\newcommand{\deleted}[1][\@empty]{%
- \renewcommand{\Changes@temp}{#1}%
- \Changes@deleted%
-}
-\newcommand{\Changes@deleted}[2][\@empty]{%
+\newcommand{\deleted}[2][\@empty]{%
+% \end{macrocode}
+% Call \emph{setkeys} in order to evaluate the key-value-options and fill the value storage.
+% \begin{macrocode}
+ \setkeys{Changes@deleted}{#1}%
\Changes@output
{\Changes@Markup@Deleted{#2}}
{\@bsphack \expandafter \@esphack}
- {\Changes@temp}
- {#1}%
- \stepcounter{Changes@DeleteCount\Changes@temp}%
+ {\Changes@deleted@id}
+ {\Changes@deleted@remark}%
+ \stepcounter{Changes@DeleteCount\Changes@deleted@id}%
}
% \end{macrocode}
% \end{macro}
@@ -770,19 +832,19 @@
% The command formats text as replaced text.
%
% Mandatory arguments: new text and old text.
-% Optional arguments: author's id, remark
+% Optional argument (key-value): author's id, remark
% \begin{macrocode}
-\newcommand{\replaced}[1][\@empty]{%
- \renewcommand{\Changes@temp}{#1}%
- \Changes@replaced%
-}
-\newcommand{\Changes@replaced}[3][\@empty]{%
+\newcommand{\replaced}[3][\@empty]{%
+% \end{macrocode}
+% Call \emph{setkeys} in order to evaluate the key-value-options and fill the value storage.
+% \begin{macrocode}
+ \setkeys{Changes@replaced}{#1}%
\Changes@output
{{\Changes@Markup@Added{#2}}{\Changes@Markup@Deleted{#3}}}
{#2}
- {\Changes@temp}
- {#1}%
- \stepcounter{Changes@ReplaceCount\Changes@temp}%
+ {\Changes@replaced@id}
+ {\Changes@replaced@remark}%
+ \stepcounter{Changes@ReplaceCount\Changes@replaced@id}%
}
% \end{macrocode}
% \end{macro}
@@ -839,7 +901,7 @@
\changesauthorname: \Changes@InID
\ifthenelse{\equal{\Changes@InName}{\@empty}}
{}
- {(\Changes@InName)}
+ { (\Changes@InName)}
}
}\\
\>\changesaddname:\>\Changes@InAdded\\
@@ -865,12 +927,24 @@
% The contents have to be separated by a semicolon.
% \begin{macrocode}
\AtEndDocument{
+% \end{macrocode}
+% Open output file.
+% \begin{macrocode}
\newwrite\Changes@OutFile
\immediate\openout\Changes@OutFile = \jobname.\Changes@extension
- \setcounter{Changes@iAuthor}{0}
- \whiledo{\value{Changes@iAuthor} < \value{Changes@AuthorCount}}{
- \stepcounter{Changes@iAuthor}
- \def\Changes@ID{\@nameuse{Changes@AuthorID\theChanges@iAuthor}}
+% \end{macrocode}
+% Redefine expandable of \chcommand{protect} in order to write correct special characters.
+% Store original definition for resetting \chcommand{protect}.
+% \begin{macrocode}
+ \let\Changes@protect\protect
+ \let\protect\@unexpandable@protect
+% \end{macrocode}
+% Output data for list of changes.
+% \begin{macrocode}
+ \setcounter{Changes@Author}{0}
+ \whiledo{\value{Changes@Author} < \value{Changes@AuthorCount}}{
+ \stepcounter{Changes@Author}
+ \def\Changes@ID{\@nameuse{Changes@AuthorID\theChanges@Author}}
\immediate\write\Changes@OutFile{\Changes@ID;%
\@nameuse{Changes@AuthorColor\Changes@ID};%
\@nameuse{Changes@AuthorName\Changes@ID};%
@@ -878,7 +952,14 @@
\the\value{Changes@DeleteCount\Changes@ID};%
\the\value{Changes@ReplaceCount\Changes@ID}}
}
- \closeout\Changes@OutFile
+% \end{macrocode}
+% Close output file.
+% \begin{macrocode}
+ \immediate\closeout\Changes@OutFile
+% \end{macrocode}
+% Restore original definition of \chcommand{protect}.
+% \begin{macrocode}
+ \let\protect\Changes@protect
}
% \end{macrocode}
%