texlive[46226] Master/texmf-dist: mpostinl (5jan18)

commits+karl at tug.org commits+karl at tug.org
Fri Jan 5 22:49:56 CET 2018


Revision: 46226
          http://tug.org/svn/texlive?view=revision&revision=46226
Author:   karl
Date:     2018-01-05 22:49:56 +0100 (Fri, 05 Jan 2018)
Log Message:
-----------
mpostinl (5jan18)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/latex/mpostinl/README
    trunk/Master/texmf-dist/doc/latex/mpostinl/mpinlsmp.tex
    trunk/Master/texmf-dist/doc/latex/mpostinl/mpostinl.pdf
    trunk/Master/texmf-dist/source/latex/mpostinl/mpostinl.dtx
    trunk/Master/texmf-dist/source/latex/mpostinl/mpostinl.ins
    trunk/Master/texmf-dist/tex/latex/mpostinl/mpostinl.sty

Modified: trunk/Master/texmf-dist/doc/latex/mpostinl/README
===================================================================
--- trunk/Master/texmf-dist/doc/latex/mpostinl/README	2018-01-05 21:49:40 UTC (rev 46225)
+++ trunk/Master/texmf-dist/doc/latex/mpostinl/README	2018-01-05 21:49:56 UTC (rev 46226)
@@ -1,5 +1,5 @@
-mpostinl v1.12
-Copyright 2010-2017 Niklas Beisert
+mpostinl v1.2
+Copyright 2010-2018 Niklas Beisert
 
 mpostinl is a LaTeX2e package
 which enables the embedding of metapost figures

Modified: trunk/Master/texmf-dist/doc/latex/mpostinl/mpinlsmp.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/mpostinl/mpinlsmp.tex	2018-01-05 21:49:40 UTC (rev 46225)
+++ trunk/Master/texmf-dist/doc/latex/mpostinl/mpinlsmp.tex	2018-01-05 21:49:56 UTC (rev 46226)
@@ -6,7 +6,7 @@
 %%
 %% mpostinl.dtx  (with options: `sample')
 %% 
-%% Copyright (C) 2010-2017 Niklas Beisert
+%% Copyright (C) 2010-2018 Niklas Beisert
 %% 
 %% This work may be distributed and/or modified under the
 %% conditions of the LaTeX Project Public License, either version 1.3
@@ -17,7 +17,7 @@
 %% version 2005/12/01 or later.
 %% 
 \NeedsTeXFormat{LaTeX2e}[1996/12/01]
-\ProvidesFile{mpinlsmp.tex}[2017/06/24 v1.12 sample for mpostinl]
+\ProvidesFile{mpinlsmp.tex}[2018/01/05 v1.2 sample for mpostinl]
 \documentclass[12pt,a4paper]{article}
 
 \parindent0pt
@@ -30,9 +30,8 @@
 %% optional: add filename to position labels in metapost code
 \IfFileExists{currfile.sty}{\usepackage{currfile}}{}
 %% optional: tools to align graphics
-\IfFileExists{graphbox.sty}
-  {\def\align{align}\usepackage{graphbox}}
-  {\def\align{}}
+\makeatletter\define at key{Gin}{align}[]{}\makeatother
+\IfFileExists{graphbox.sty}{\usepackage{graphbox}}{}
 
 %% some sample package options:
 %% \mpostsetup{write=false}
@@ -67,7 +66,7 @@
 
 scaled (and aligned to centre if available):\\
 X
-\begin{mpostfig}[opt={scale=1.5,\align}]
+\begin{mpostfig}[opt={scale=1.5,align}]
 draw fullcircle scaled unit;
 label(btex 2 etex, (0,0));
 \end{mpostfig}
@@ -83,7 +82,7 @@
 \mpostuse{fig}
 
 display with options:\\
-\mpostuse[scale=1.5,\align]{fig}
+\mpostuse[scale=1.5,align]{fig}
 
 display in a box:\\
 \fbox{\mpostuse{fig}}
@@ -95,7 +94,7 @@
 
 display in equation (align if possible):
 \begin{equation}
-\mpostuse[scale=1.5,\align]{fig}
+\mpostuse[scale=1.5,align]{fig}
 \end{equation}
 
 filename: \mpostgetname{fig}

Modified: trunk/Master/texmf-dist/doc/latex/mpostinl/mpostinl.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/source/latex/mpostinl/mpostinl.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/mpostinl/mpostinl.dtx	2018-01-05 21:49:40 UTC (rev 46225)
+++ trunk/Master/texmf-dist/source/latex/mpostinl/mpostinl.dtx	2018-01-05 21:49:56 UTC (rev 46226)
@@ -1,6 +1,6 @@
 % \iffalse
 %
-% mpostinl.dtx Copyright (C) 2010-2017 Niklas Beisert
+% mpostinl.dtx Copyright (C) 2010-2018 Niklas Beisert
 %
 % This work may be distributed and/or modified under the
 % conditions of the LaTeX Project Public License, either version 1.3
@@ -18,10 +18,10 @@
 % and the derived files mpostinl.sty and mpinlsmp.tex
 %
 %<package|sample>\NeedsTeXFormat{LaTeX2e}[1996/12/01]
-%<package>\ProvidesPackage{mpostinl}[2017/06/24 v1.12 metapost inline figures]
-%<sample>\ProvidesFile{mpinlsmp.tex}[2017/06/24 v1.12 sample for mpostinl]
+%<package>\ProvidesPackage{mpostinl}[2018/01/05 v1.2 metapost inline figures]
+%<sample>\ProvidesFile{mpinlsmp.tex}[2018/01/05 v1.2 sample for mpostinl]
 %<*driver>
-%\ProvidesFile{mpostinl.drv}[2017/06/24 v1.12 mpostinl reference manual file]
+%\ProvidesFile{mpostinl.drv}[2018/01/05 v1.2 mpostinl reference manual file]
 \PassOptionsToClass{10pt,a4paper}{article}
 \documentclass{ltxdoc}
 
@@ -48,7 +48,7 @@
   {\texttt{nbeisert at itp.phys.ethz.ch}}}
 \hypersetup{pdfauthor={Niklas Beisert}}
 \hypersetup{pdfsubject={Manual for the LaTeX2e Package mpostinl}}
-\date{24 June 2017, \textsf{v1.12}}
+\date{5 January 2018, \textsf{v1.2}}
 \maketitle
 
 \begin{abstract}\noindent
@@ -685,6 +685,12 @@
 if the \LaTeX{} source is uploaded to a repository
 or passed on to a publisher.
 
+By default the package checks whether the generated files
+change with respect to the previous \LaTeX{} pass,
+and only modified files are compiled thereupon.
+This check can be disabled by setting the option
+|checksum| to |false|, in which case all files are compiled.
+
 When the metapost file compiles with errors,
 one can inspect the generated metapost file.
 To this end it may be helpful to know which
@@ -1058,7 +1064,7 @@
 \parskip1ex
 \parindent0pt
 
-Copyright \copyright{} 2010--2017 Niklas Beisert
+Copyright \copyright{} 2010--2018 Niklas Beisert
 
 This work may be distributed and/or modified under the
 conditions of the \LaTeX{} Project Public License, either version 1.3
@@ -1139,11 +1145,6 @@
 or remove files not needed after processing.
 However, both appear to be somewhat in contrast
 to the usual \TeX{} philosophy.
-\item
-Compare the generated metapost file to the previous instance
-and compile only in case of changes.
-This could be implemented by a checksum or by some external tool
-such as diff. This feature is probably too difficult to implement.
 %\item
 %an environment to pass tex commands to mpost and also compile them locally
 %probably have to write to file and subsequently input the file
@@ -1155,6 +1156,19 @@
 \subsection{Revision History}
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\paragraph{v1.2:} 2018/01/05
+
+\begin{itemize}
+\item
+new option |checksum| to compile only modified files
+(requires the pdf\TeX{} engine, otherwise disabled)
+\item
+warn if some figures may not be up to date
+\item
+bugfix for example if \textsf{graphbox} is not available
+\end{itemize}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 \paragraph{v1.12:} 2017/06/24
 
 \begin{itemize}
@@ -1279,14 +1293,14 @@
 %    \end{macrocode}
 
 % Include packages \textsf{currfile} and \textsf{graphbox} if available,
-% declare an alignment switch |\align| (if \textsf{graphbox} is available):
+% declare dummy option |align| for |\includegraphics|
+% if \textsf{graphbox} is not available:
 %    \begin{macrocode}
 %% optional: add filename to position labels in metapost code
 \IfFileExists{currfile.sty}{\usepackage{currfile}}{}
 %% optional: tools to align graphics
-\IfFileExists{graphbox.sty}
-  {\def\align{align}\usepackage{graphbox}}
-  {\def\align{}}
+\makeatletter\define at key{Gin}{align}[]{}\makeatother
+\IfFileExists{graphbox.sty}{\usepackage{graphbox}}{}
 %    \end{macrocode}
 
 % Enable immediate mode and line number indicators,
@@ -1353,7 +1367,7 @@
 %    \begin{macrocode}
 scaled (and aligned to centre if available):\\
 X
-\begin{mpostfig}[opt={scale=1.5,\align}]
+\begin{mpostfig}[opt={scale=1.5,align}]
 draw fullcircle scaled unit;
 label(btex 2 etex, (0,0));
 \end{mpostfig}
@@ -1378,7 +1392,7 @@
 % Display the figure with options for |\includegraphics|:
 %    \begin{macrocode}
 display with options:\\
-\mpostuse[scale=1.5,\align]{fig}
+\mpostuse[scale=1.5,align]{fig}
 %    \end{macrocode}
 
 % Display the figure within a box:
@@ -1399,7 +1413,7 @@
 %    \begin{macrocode}
 display in equation (align if possible):
 \begin{equation}
-\mpostuse[scale=1.5,\align]{fig}
+\mpostuse[scale=1.5,align]{fig}
 \end{equation}
 %    \end{macrocode}
 
@@ -1752,19 +1766,8 @@
 %    \end{macrocode}
 
 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% \paragraph{Internal Definitions.}
+% \paragraph{Package Options.}
 %
-% \begin{macro}{\ifmpi at infile}
-% \begin{macro}{\ifmpi at inbody}
-% |\ifmpi at infile| indicates whether a file is open,
-% |\ifmpi at inbody| indicates whether the content section has started:
-%    \begin{macrocode}
-\newif\ifmpi at infile\mpi at infilefalse
-\newif\ifmpi at inbody\mpi at inbodyfalse
-%    \end{macrocode}
-% \end{macro}
-% \end{macro}
-
 % \begin{macro}{\mpostfilename}
 % \begin{macro}{\mpi at nowname}
 % \begin{macro}{\mpi at extension}
@@ -1792,9 +1795,6 @@
 %    \end{macrocode}
 % \end{macro}
 
-% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% \paragraph{Package Options.}
-%
 % The package has some boolean \textsf{keyval} options
 % which can be set to |true| or |false|.
 %    \begin{macrocode}
@@ -1811,6 +1811,7 @@
 \newif\ifmpi at nowkeep\mpi at nowkeepfalse
 \newif\ifmpi at include\mpi at includefalse
 \newif\ifmpi at defglobal\mpi at defglobalfalse
+\newif\ifmpi at checksum\mpi at checksumtrue
 %    \end{macrocode}
 
 % \begin{macro}{\mpi at mpostmem}
@@ -1853,6 +1854,7 @@
 \define at key{\mpi at group}{latex}[true]{\csname mpi at latex#1\endcsname}
 \define at key{\mpi at group}{compile}[true]{\csname mpi at compile#1\endcsname}
 \define at key{\mpi at group}{twice}[true]{\csname mpi at twice#1\endcsname}
+\define at key{\mpi at group}{checksum}[true]{\csname mpi at checksum#1\endcsname}
 \define at key{\mpi at group}{fonts}[true]{\csname mpi at fonts#1\endcsname}
 \define at key{\mpi at group}{prologues}[]{\def\mpi at prologues{#1}}
 \define at key{\mpi at group}{lineno}[true]{\csname mpi at lineno#1\endcsname}
@@ -1881,10 +1883,13 @@
   \expandafter{\CurrentOption}}
 %    \end{macrocode}
 
-% Process package options and warn if |\write18| mechanism is not available:
+% Process package options,
+% warn if |\write18| mechanism is not available,
+% and disable checksum if |\pdfmdfivesum| is not available:
 %    \begin{macrocode}
 \ProcessOptions
 \mpi at warncompile
+\ifdefined\pdfmdfivesum\else\mpi at checksumfalse\fi
 %    \end{macrocode}
 
 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -1904,6 +1909,40 @@
 %    \end{macrocode}
 % \end{macro}
 
+% \begin{macro}{\ifmpi at infile}
+% \begin{macro}{\ifmpi at inbody}
+% |\ifmpi at infile| indicates whether a file is open,
+% |\ifmpi at inbody| indicates whether the content section has started:
+%    \begin{macrocode}
+\newif\ifmpi at infile\mpi at infilefalse
+\newif\ifmpi at inbody\mpi at inbodyfalse
+%    \end{macrocode}
+% \end{macro}
+% \end{macro}
+
+% \begin{macro}{\ifmpi at inclmod}
+% \begin{macro}{\ifmpi at filemod}
+% |\ifmpi at inclmod| indicates whether an include file has been modified,
+% |\ifmpi at filemod| indicates whether the current file is modified:
+%    \begin{macrocode}
+\newif\ifmpi at inclmod\mpi at inclmodfalse
+\newif\ifmpi at filemod
+%    \end{macrocode}
+% \end{macro}
+% \end{macro}
+
+% \begin{macro}{\ifmpi at warnmod}
+% \begin{macro}{\ifmpi at showinfile}
+% |\ifmpi at warnmod| indicates whether a rerun warning is to be issued,
+% |\ifmpi at showinfile| indicates whether a figure has been displayed
+%   while a file is being composed:
+%    \begin{macrocode}
+\newif\ifmpi at warnmod\mpi at warnmodfalse
+\newif\ifmpi at showinfile
+%    \end{macrocode}
+% \end{macro}
+% \end{macro}
+
 % \begin{macro}{\mpi at out}
 % \begin{macro}{\mpi at outnow}
 % File handles for the metapost file (|\mpi at out|)
@@ -2000,6 +2039,19 @@
 %    \end{macrocode}
 % \end{macro}
 
+% \begin{macro}{\mpi at warnmod}
+% Warn if some figure has been displayed while a file has been written
+% (potentially the displayed figure is old):
+%    \begin{macrocode}
+\newcommand{\mpi at warnmod}{%
+  \ifmpi at checksum\ifmpi at warnmod%
+    \PackageWarning{mpostinl}{figure(s) may have changed. %
+      Rerun to update figures}{}%
+  \fi\fi%
+}
+%    \end{macrocode}
+% \end{macro}
+
 % \begin{macro}{\mpostplaceholder}
 % Display a placeholder for non-existing files or labels;
 % this function may be overwritten by the user for customisation purposes
@@ -2198,6 +2250,16 @@
 %    \end{macrocode}
 % \end{macro}
 
+% \begin{macro}{\mpi at getchecksum}
+% Compute the MD5 checksum for a metapost file and store in macro:
+%    \begin{macrocode}
+\newcommand{\mpi at getchecksum}[2]{%
+  \IfFileExists{#2}{\xdef#1{\pdfmdfivesum file{#2}}}{\global\let#1=\@undefined}%
+}
+%    \end{macrocode}
+% \end{macro}
+
+
 % \begin{macro}{\mpi at startfile}
 % Start a new file if not already open:
 %    \begin{macrocode}
@@ -2210,9 +2272,16 @@
       \PackageError{mpostinl}{no filename provided to write to}{}%
     \fi%
 %    \end{macrocode}
+% Compute checksum of old file:
+%    \begin{macrocode}
+    \ifmpi at checksum\ifmpi at inclmod\else%
+      \mpi at getchecksum{\mpi at checksum@before}{\mpostfilename.mp}%
+    \fi\fi%
+%    \end{macrocode}
 % Open file for writing, prepare and write header to file:
 %    \begin{macrocode}
     \global\mpi at infiletrue%
+    \global\mpi at showinfilefalse%
     \ifmpi at write\immediate\openout\mpi at out\mpostfilename.mp\fi%
     \mpi at clearbuf%
     \mpi at beginfile%
@@ -2321,10 +2390,25 @@
     \mpi at writebuf%
     \ifmpi at write\immediate\closeout\mpi at out\fi%
 %    \end{macrocode}
-% Compile if file contains figures:
+% Determine whether file has changed:
 %    \begin{macrocode}
-    \ifmpi at inbody\mpi at compile{\mpostfilename.mp}\fi%
+    \mpi at filemodtrue%
+    \ifmpi at checksum\ifmpi at inclmod\else%
+      \mpi at getchecksum{\mpi at checksum@after}{\mpostfilename.mp}%
+      \ifx\mpi at checksum@before\mpi at checksum@after%
+        \mpi at filemodfalse%
+      \else%
+        \ifmpi at include\mpi at inclmodtrue\fi%
+      \fi%
+    \fi\fi%
 %    \end{macrocode}
+% Compile if file has changed and if it contains figures.
+% Activate warning if file has changed and figures were displayed
+% during composition:
+%    \begin{macrocode}
+    \ifmpi at filemod\ifmpi at inbody\mpi at compile{\mpostfilename.mp}\fi\fi%
+    \ifmpi at filemod\ifmpi at showinfile\global\mpi at warnmodtrue\fi\fi%
+%    \end{macrocode}
 % Reset variables:
 %    \begin{macrocode}
     \global\mpi at infilefalse%
@@ -2369,9 +2453,11 @@
 %    \end{macrocode}
 % \end{macro}
 
-% Make sure to close and process the file at the end:
+% Make sure to close and process the file at the end.
+% Warn if figures may need another compiler pass:
 %    \begin{macrocode}
 \AtEndDocument{\mpi at closefile}
+\AtEndDocument{\mpi at warnmod}
 %    \end{macrocode}
 
 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -2386,6 +2472,7 @@
 \newcommand{\mpostsetup}[1]{%
   \setkeys\mpi at group{#1}%
   \mpi at warncompile%
+  \ifdefined\pdfmdfivesum\else\mpi at checksumfalse\fi%
 }
 %    \end{macrocode}
 % \end{macro}
@@ -2461,7 +2548,7 @@
 \define at key{mpi at fig}{twice}[true]{\csname mpi at twice#1\endcsname}
 \define at key{mpi at fig}{file}{\def\mpi at figfile{#1}}
 \define at key{mpi at fig}{label}{\def\mpi at figlabel{#1}}
-\define at key{mpi at fig}{opt}{\edef\mpi at figopt{[#1]}}
+\define at key{mpi at fig}{opt}{\def\mpi at figopt{[#1]}}
 \define at key{mpi at fig}{now}[true]{\csname mpi at now#1\endcsname}
 %    \end{macrocode}
 
@@ -2531,10 +2618,12 @@
     \mpi at processnow%
   \fi%
 %    \end{macrocode}
-% Display figure:
+% Display figure.
+% Remember immediate display of figure unless processed immediately:
 %    \begin{macrocode}
   \ifmpi at figshow%
     \expandafter\mpi at graphics\mpi at figopt{\mpi at figfile}%
+    \ifmpi at now\else\global\mpi at showinfiletrue\fi%
   \fi%
 }
 %    \end{macrocode}
@@ -2543,7 +2632,8 @@
 % \begin{macro}{\mpostuse}
 % |\mpostuse| includes a metapost figure which was declared earlier
 % via its label. The optional argument is passed as the optional
-% argument for |\includegraphics|
+% argument for |\includegraphics|.
+% Remember if a file is currently open for writing:
 %    \begin{macrocode}
 \newcommand{\mpostuse}[2][]{%
   \expandafter\ifx\csname mpi at l@#2\endcsname\relax%
@@ -2551,6 +2641,7 @@
     \mpostplaceholder[label]{#2}%
   \else%
     \mpi at graphics[#1]{\csname mpi at l@#2\endcsname}%
+    \ifmpi at infile\global\mpi at showinfiletrue\fi%
   \fi%
 }
 %    \end{macrocode}

Modified: trunk/Master/texmf-dist/source/latex/mpostinl/mpostinl.ins
===================================================================
--- trunk/Master/texmf-dist/source/latex/mpostinl/mpostinl.ins	2018-01-05 21:49:40 UTC (rev 46225)
+++ trunk/Master/texmf-dist/source/latex/mpostinl/mpostinl.ins	2018-01-05 21:49:56 UTC (rev 46226)
@@ -2,7 +2,7 @@
 \input docstrip.tex
 
 \keepsilent
-% mpostinl.ins Copyright (C) 2010-2017 Niklas Beisert
+% mpostinl.ins Copyright (C) 2010-2018 Niklas Beisert
 %
 % This work may be distributed and/or modified under the
 % conditions of the LaTeX Project Public License, either version 1.3
@@ -14,7 +14,7 @@
 
 \preamble
 
-Copyright (C) 2010-2017 Niklas Beisert
+Copyright (C) 2010-2018 Niklas Beisert
 
 This work may be distributed and/or modified under the
 conditions of the LaTeX Project Public License, either version 1.3

Modified: trunk/Master/texmf-dist/tex/latex/mpostinl/mpostinl.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/mpostinl/mpostinl.sty	2018-01-05 21:49:40 UTC (rev 46225)
+++ trunk/Master/texmf-dist/tex/latex/mpostinl/mpostinl.sty	2018-01-05 21:49:56 UTC (rev 46226)
@@ -6,7 +6,7 @@
 %%
 %% mpostinl.dtx  (with options: `package')
 %% 
-%% Copyright (C) 2010-2017 Niklas Beisert
+%% Copyright (C) 2010-2018 Niklas Beisert
 %% 
 %% This work may be distributed and/or modified under the
 %% conditions of the LaTeX Project Public License, either version 1.3
@@ -17,15 +17,12 @@
 %% version 2005/12/01 or later.
 %% 
 \NeedsTeXFormat{LaTeX2e}[1996/12/01]
-\ProvidesPackage{mpostinl}[2017/06/24 v1.12 metapost inline figures]
+\ProvidesPackage{mpostinl}[2018/01/05 v1.2 metapost inline figures]
 
 \RequirePackage{verbatim}
 \RequirePackage{graphicx}
 \RequirePackage{keyval}
 
-\newif\ifmpi at infile\mpi at infilefalse
-\newif\ifmpi at inbody\mpi at inbodyfalse
-
 \def\mpostfilename{\jobname}
 \def\mpi at nowname{\jobname-tmp}
 \def\mpi at extension{mps}
@@ -48,6 +45,7 @@
 \newif\ifmpi at nowkeep\mpi at nowkeepfalse
 \newif\ifmpi at include\mpi at includefalse
 \newif\ifmpi at defglobal\mpi at defglobalfalse
+\newif\ifmpi at checksum\mpi at checksumtrue
 
 \def\mpi at mpostmem{}
 \def\mpi at mpostcompiler{}
@@ -68,6 +66,7 @@
 \define at key{\mpi at group}{latex}[true]{\csname mpi at latex#1\endcsname}
 \define at key{\mpi at group}{compile}[true]{\csname mpi at compile#1\endcsname}
 \define at key{\mpi at group}{twice}[true]{\csname mpi at twice#1\endcsname}
+\define at key{\mpi at group}{checksum}[true]{\csname mpi at checksum#1\endcsname}
 \define at key{\mpi at group}{fonts}[true]{\csname mpi at fonts#1\endcsname}
 \define at key{\mpi at group}{prologues}[]{\def\mpi at prologues{#1}}
 \define at key{\mpi at group}{lineno}[true]{\csname mpi at lineno#1\endcsname}
@@ -94,11 +93,21 @@
 
 \ProcessOptions
 \mpi at warncompile
+\ifdefined\pdfmdfivesum\else\mpi at checksumfalse\fi
 
 \def\mpi at empty{}
 
 \begingroup\catcode`\"=12\relax\gdef\mpi at dblquotchar{"}\endgroup
 
+\newif\ifmpi at infile\mpi at infilefalse
+\newif\ifmpi at inbody\mpi at inbodyfalse
+
+\newif\ifmpi at inclmod\mpi at inclmodfalse
+\newif\ifmpi at filemod
+
+\newif\ifmpi at warnmod\mpi at warnmodfalse
+\newif\ifmpi at showinfile
+
 \newwrite\mpi at out
 \newwrite\mpi at outnow
 
@@ -139,6 +148,13 @@
   \expandafter\endgroup\mpi at tmp%
 }
 
+\newcommand{\mpi at warnmod}{%
+  \ifmpi at checksum\ifmpi at warnmod%
+    \PackageWarning{mpostinl}{figure(s) may have changed. %
+      Rerun to update figures}{}%
+  \fi\fi%
+}
+
 \newcommand{\mpostplaceholder}[2][]{\parbox[c]{1in}{%
   \hrule\vrule\hfill%
   \parbox[c]{0pt}{\rule{0cm}{0.6in}}\makebox[0pt][c]{\scriptsize\tt #2}%
@@ -251,12 +267,20 @@
   \fi%
 }
 
+\newcommand{\mpi at getchecksum}[2]{%
+  \IfFileExists{#2}{\xdef#1{\pdfmdfivesum file{#2}}}{\global\let#1=\@undefined}%
+}
+
 \newcommand{\mpi at startfile}{%
   \ifmpi at infile\else%
     \ifx\mpostfilename\mpi at empty%
       \PackageError{mpostinl}{no filename provided to write to}{}%
     \fi%
+    \ifmpi at checksum\ifmpi at inclmod\else%
+      \mpi at getchecksum{\mpi at checksum@before}{\mpostfilename.mp}%
+    \fi\fi%
     \global\mpi at infiletrue%
+    \global\mpi at showinfilefalse%
     \ifmpi at write\immediate\openout\mpi at out\mpostfilename.mp\fi%
     \mpi at clearbuf%
     \mpi at beginfile%
@@ -322,7 +346,17 @@
     \mpi at endfile%
     \mpi at writebuf%
     \ifmpi at write\immediate\closeout\mpi at out\fi%
-    \ifmpi at inbody\mpi at compile{\mpostfilename.mp}\fi%
+    \mpi at filemodtrue%
+    \ifmpi at checksum\ifmpi at inclmod\else%
+      \mpi at getchecksum{\mpi at checksum@after}{\mpostfilename.mp}%
+      \ifx\mpi at checksum@before\mpi at checksum@after%
+        \mpi at filemodfalse%
+      \else%
+        \ifmpi at include\mpi at inclmodtrue\fi%
+      \fi%
+    \fi\fi%
+    \ifmpi at filemod\ifmpi at inbody\mpi at compile{\mpostfilename.mp}\fi\fi%
+    \ifmpi at filemod\ifmpi at showinfile\global\mpi at warnmodtrue\fi\fi%
     \global\mpi at infilefalse%
     \global\let\mpostfilename\mpi at empty%
     \global\mpi at inbodyfalse%
@@ -350,10 +384,12 @@
 }
 
 \AtEndDocument{\mpi at closefile}
+\AtEndDocument{\mpi at warnmod}
 
 \newcommand{\mpostsetup}[1]{%
   \setkeys\mpi at group{#1}%
   \mpi at warncompile%
+  \ifdefined\pdfmdfivesum\else\mpi at checksumfalse\fi%
 }
 
 \newif\ifmpi at deftex
@@ -400,7 +436,7 @@
 \define at key{mpi at fig}{twice}[true]{\csname mpi at twice#1\endcsname}
 \define at key{mpi at fig}{file}{\def\mpi at figfile{#1}}
 \define at key{mpi at fig}{label}{\def\mpi at figlabel{#1}}
-\define at key{mpi at fig}{opt}{\edef\mpi at figopt{[#1]}}
+\define at key{mpi at fig}{opt}{\def\mpi at figopt{[#1]}}
 \define at key{mpi at fig}{now}[true]{\csname mpi at now#1\endcsname}
 
 \newenvironment{mpostfig}[1][]{%
@@ -442,6 +478,7 @@
   \fi%
   \ifmpi at figshow%
     \expandafter\mpi at graphics\mpi at figopt{\mpi at figfile}%
+    \ifmpi at now\else\global\mpi at showinfiletrue\fi%
   \fi%
 }
 
@@ -451,6 +488,7 @@
     \mpostplaceholder[label]{#2}%
   \else%
     \mpi at graphics[#1]{\csname mpi at l@#2\endcsname}%
+    \ifmpi at infile\global\mpi at showinfiletrue\fi%
   \fi%
 }
 



More information about the tex-live-commits mailing list