summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2015-09-23 23:35:58 +0000
committerKarl Berry <karl@freefriends.org>2015-09-23 23:35:58 +0000
commitf963602ba2f2ff3644f713c45b59b4f22c0c4b04 (patch)
tree84b92302a79a378db5d0f6bb4cb88ccdb7a0fa5a /Master/texmf-dist/tex/latex
parentf2c1bd0a1a94f92d81946cb9195117f87f5d2471 (diff)
chemmacros (23sep15)
git-svn-id: svn://tug.org/texlive/trunk@38447 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex')
-rw-r--r--Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.base.code.tex22
-rw-r--r--Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.charges.code.tex15
-rw-r--r--Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.chemformula.code.tex76
-rw-r--r--Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.particles.code.tex4
-rw-r--r--Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.reactions.code.tex8
-rw-r--r--Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.scheme.code.tex115
-rw-r--r--Master/texmf-dist/tex/latex/chemmacros/chemmacros.sty7
-rw-r--r--Master/texmf-dist/tex/latex/chemmacros/chemmacros5.sty57
8 files changed, 228 insertions, 76 deletions
diff --git a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.base.code.tex b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.base.code.tex
index eab20de2076..d8a65a0096a 100644
--- a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.base.code.tex
+++ b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.base.code.tex
@@ -247,16 +247,24 @@
% load package #1 and add its options to chemmacros
% this requires that package #1 defines its options with l3keys using its
% name as module
-\cs_new_protected:Npn \chemmacros_integrate_package:nn #1#2
+\cs_new_protected:Npn \chemmacros_integrate_package:nnn #1#2#3
{
- \tl_if_blank:nTF {#2}
- { \RequirePackage {#1} }
- { \RequirePackage {#1} [#2] }
+ \tl_if_blank:nTF {#3}
+ {
+ \tl_if_blank:nTF {#1}
+ { \RequirePackage {#2} }
+ { \RequirePackage [#1] {#2} }
+ }
+ {
+ \tl_if_blank:nTF {#1}
+ { \RequirePackage {#2} [#3] }
+ { \RequirePackage [#1] {#2} [#3] }
+ }
\keys_define:nn {chemmacros}
{
- #1 .choice: ,
- #1 / unknown .code:n =
- \keys_set:no {#1} { \l_keys_key_tl = ##1 }
+ #2 .choice: ,
+ #2 / unknown .code:n =
+ \keys_set:no {#2} { \l_keys_key_tl = ##1 }
}
}
diff --git a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.charges.code.tex b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.charges.code.tex
index 36a190a85ed..e852764feed 100644
--- a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.charges.code.tex
+++ b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.charges.code.tex
@@ -50,12 +50,14 @@
circletype / math .code:n =
{
\bool_set_false:N \l__chemmacros_circled_chem_bool
- \bool_set_false:N \l_chemformula_formal_chem_bool
+ \chemmacros_if_package_loaded:nT {chemformula}
+ { \bool_set_false:N \l_chemformula_formal_chem_bool }
} ,
circletype / chem .code:n =
{
\bool_set_true:N \l__chemmacros_circled_chem_bool
- \bool_set_true:N \l_chemformula_formal_chem_bool
+ \chemmacros_if_package_loaded:nT {chemformula}
+ { \bool_set_true:N \l_chemformula_formal_chem_bool }
} ,
circletype .value_required:n = true ,
circled .choice: ,
@@ -63,19 +65,22 @@
{
\bool_set_false:N \l__chemmacros_circled_bool
\bool_set_false:N \l__chemmacros_circled_formal_bool
- \bool_set_false:N \l_chemformula_formal_charges_bool
+ \chemmacros_if_package_loaded:nT {chemformula}
+ { \bool_set_false:N \l_chemformula_formal_charges_bool }
} ,
circled / formal .code:n =
{
\bool_set_true:N \l__chemmacros_circled_bool
\bool_set_true:N \l__chemmacros_circled_formal_bool
- \bool_set_false:N \l_chemformula_formal_charges_bool
+ \chemmacros_if_package_loaded:nT {chemformula}
+ { \bool_set_false:N \l_chemformula_formal_charges_bool }
} ,
circled / all .code:n =
{
\bool_set_true:N \l__chemmacros_circled_bool
\bool_set_false:N \l__chemmacros_circled_formal_bool
- \bool_set_true:N \l_chemformula_formal_charges_bool
+ \chemmacros_if_package_loaded:nT {chemformula}
+ { \bool_set_true:N \l_chemformula_formal_charges_bool }
} ,
circled .default:n = all
}
diff --git a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.chemformula.code.tex b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.chemformula.code.tex
index 56c469f6245..d785ce6c795 100644
--- a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.chemformula.code.tex
+++ b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.chemformula.code.tex
@@ -25,13 +25,52 @@
%
% The Current Maintainer of this work is Clemens Niederberger.
% --------------------------------------------------------------------------
-\ChemModule{chemformula}{2015/07/25 chemformula integration}
+\ChemModule{chemformula}{2015/09/19 integration of chemical formulas}
+\RequirePackage{amstext}
\chemmacros_load_module:n {charges}
-\chemmacros_integrate_package:nn {chemformula} {2015/08/19}
+\msg_new:nnn {chemmacros} {unknown-formula-method}
+ {
+ You~ chose~ the~ formula~ method~ `#1'~ which~ is~ not~ available.~ Valid~
+ methods~ are~ (the~ recommended~ choice)~ `chemformula'~ and~ `mhchem'.~
+ I'm~ falling~ back~ to~ `chemformula'~ now.
+ }
-\RequirePackage{amstext}
+\bool_new:N \l__chemmacros_formula_method_set_bool
+
+\tl_new:N \g_chemmacros_formula_method_tl
+\tl_gset:Nn \g_chemmacros_formula_method_tl {chemformula}
+
+\cs_new_protected:Npn \chemmacros_set_formula_method:n #1
+ {
+ \str_case:nnTF {#1}
+ {
+ {chemformula} {
+ \chemmacros_integrate_package:nnn {} {chemformula} {2015/09/08}
+ \tl_gset:Nn \g_chemmacros_formula_method_tl {chemformula}
+ }
+ {mhchem} {
+ \chemmacros_integrate_package:nnn {version=4} {mhchem} {}
+ \cs_set_protected:Npn \chemmacros_chemformula:n ##1 { \ce {##1} }
+ \cs_set_protected:Npn \chemmacros_reaction:n ##1 { \ce {##1} }
+ \chemmacros_after_module:nn {charges}
+ {
+ \cs_set_protected:Npn \chemmacros_elpair:n ##1 { \ce{##1} : }
+ \cs_set_protected:Npn \chemmacros_plus: { + }
+ \cs_set_protected:Npn \chemmacros_minus: { - }
+ \cs_set_protected:Npn \chemmacros_formal_plus: { \ensuremath{\oplus} }
+ \cs_set_protected:Npn \chemmacros_formal_minus: { \ensuremath{\ominus} }
+ \cs_set_protected:Npn \fplus { \ensuremath{\oplus} }
+ \cs_set_protected:Npn \fminus { \ensuremath{\ominus} }
+ }
+ \tl_gset:Nn \g_chemmacros_formula_method_tl {mhchem}
+ }
+ }
+ { \bool_set_true:N \l__chemmacros_formula_method_set_bool }
+ { \bool_set_false:N \l__chemmacros_formula_method_set_bool }
+ }
+\cs_generate_variant:Nn \chemmacros_set_formula_method:n {V}
% --------------------------------------------------------------------------
% let's make use of `chemformula' inside some of `chemmacros' commands:
@@ -39,4 +78,35 @@
{ \chemformula_chcpd:nn {} {#1} }
\cs_generate_variant:Nn \chemmacros_chemformula:n { x,V }
+\cs_new_protected:Npn \chemmacros_reaction:n #1
+ { \chemformula_ch:nn {} {#1} }
+
+% for module writes prefering traditional 2e programming:
+\cs_new_protected:Npn \chemmacros@formula #1 { \chemmacros_chemformula:n {#1} }
+\cs_new_protected:Npn \chemmacros@reaction #1 { \chemmacros_reaction:n {#1} }
+
% --------------------------------------------------------------------------
+\ChemCompatibilityFrom{5.1}
+\keys_define:nn {chemmacros}
+ {
+ formula .choices:nn =
+ { chemformula , mhchem }
+ { \chemmacros_set_formula_method:V \l_keys_choice_tl } ,
+ formula / unknown .code:n =
+ \msg_warning:nnn {chemmacros} {unknown-formula-method} {#1}
+ \tl_gset:Nn \g_chemmacros_formula_method_tl {chemformula}
+ }
+\EndChemCompatibility
+
+\AtEndPreamble
+ {
+ \bool_if:NF \l__chemmacros_formula_method_set_bool
+ { \chemmacros_set_formula_method:V \g_chemmacros_formula_method_tl }
+ }
+
+% --------------------------------------------------------------------------
+\tex_endinput:D
+
+2015/09/22 - new general option `method' which allows a choice between
+ `chemformula' and `mhchem'
+
diff --git a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.particles.code.tex b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.particles.code.tex
index 110dd05c8ea..ccc506e8c23 100644
--- a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.particles.code.tex
+++ b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.particles.code.tex
@@ -32,7 +32,7 @@
% --------------------------------------------------------------------------
% particles
\cs_new_protected:Nn \chemmacros_define_particle:Nn
- { \cs_set_protected:Npn #1 { \chemformula_chcpd:nn {} {#2} } }
+ { \cs_set_protected:Npn #1 { \chemmacros_chemformula:n {#2} } }
\chemmacros_new_macroset:nnn {Particle} {mm}
{ \chemmacros_define_particle:Nn #1 {#2} }
@@ -72,7 +72,7 @@
\cs_set_protected:cpn {__chemmacros_ \chemmacros_remove_backslash:N #1:}
{
\bool_if:NTF \l__chemmacros_nucleophile_elpair_bool
- { \chemmacros_elpair:n { #2 } \chemmacros_chemformula:n { {}- } }
+ { \chemmacros_elpair:n { #2 } \chemmacros_chemformula:n { {}^{-} } }
{ \chemmacros_chemformula:n { #2- } }
}
\DeclareDocumentCommand #1 {o}
diff --git a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.reactions.code.tex b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.reactions.code.tex
index 087cd521e69..a3468239f06 100644
--- a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.reactions.code.tex
+++ b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.reactions.code.tex
@@ -25,7 +25,7 @@
%
% The Current Maintainer of this work is Clemens Niederberger.
% --------------------------------------------------------------------------
-\ChemModule{reactions}{2015/07/14 reaction environments}
+\ChemModule{reactions}{2015/09/15 reaction environments}
\chemmacros_load_module:n {chemformula}
@@ -169,7 +169,7 @@
\cs_new_protected:Npn \chemmacros_reaction_read:nnw #1#2#3 \end
{
\begin{#1}#2
- \chemformula_ch:nn {} {#3}
+ \chemmacros_reaction:n {#3}
\end{#1}
\end
}
@@ -183,3 +183,7 @@
\NewChemReaction {reactions*} {align*}
% --------------------------------------------------------------------------
+\tex_endinput:D
+
+2015/09/15 - adapt to `method' option => do not use chemformula's macros
+ directly
diff --git a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.scheme.code.tex b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.scheme.code.tex
index 5963e3e2260..d4dd3ae7691 100644
--- a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.scheme.code.tex
+++ b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.scheme.code.tex
@@ -25,7 +25,7 @@
%
% The Current Maintainer of this work is Clemens Niederberger.
% --------------------------------------------------------------------------
-\ChemModule{scheme}{2015/06/09 a scheme floating environment}
+\ChemModule{scheme}{2015/09/19 a scheme floating environment}
\RequirePackage {chemnum}
@@ -43,7 +43,7 @@
\seq_put_right:Nn \l__chemmacros_float_methods_seq {#1}
\prop_put:Nnn \l__chemmacros_float_methods_prop {#1} {#2}
\prop_put:Nnn \l__chemmacros_float_definitions_prop {#1}
- { \cs_set_protected:Npn \__chemmacros_define_float:n ##1 {#3} }
+ { \cs_set_protected:Npn \__chemmacros_define_float:nn ##1##2 {#3} }
}
% the order in which the methods are defined determines in which order the
@@ -57,28 +57,28 @@
float ,
name = \chemmacros_translate:n {#1-name} ,
listname = {\exp_not:N \chemmacros_translate:n {#1-list}}
- ]{los}
+ ]{#2}
}
\chemmacros_define_float_method:nnn {memoir}
{ \chemmacros_if_class_loaded_p:n {memoir} }
{
- \newfloat [chapter] {scheme} {los} {\chemmacros_translate:n {#1-name}}
- \cs_set:Npn \thescheme {\thechapter.\@arabic\c@scheme}
- \newlistof {listofschemes} {los} {\chemmacros_translate:n {#1-list}}
- \newlistentry [chapter] {scheme} {los} {0}
- \cftsetindents {scheme} {0em} {2.3em}
+ \newfloat [chapter] {#1} {#2} {\chemmacros_translate:n {#1-name}}
+ \cs_set:cpn {the#1} {\thechapter.\arabic {#1}}
+ \newlistof {listof#1s} {#2} {\chemmacros_translate:n {#1-list}}
+ \newlistentry [chapter] {#1} {#2} {0}
+ \cftsetindents {#1} {0em} {2.3em}
\tl_put_right:Nn \@memfront@floats
- { \counterwithout {scheme} {chapter} }
+ { \counterwithout {#1} {chapter} }
\tl_put_right:Nn \@memmain@floats
- { \counterwithin {scheme} {chapter} }
+ { \counterwithin {#1} {chapter} }
\tl_put_right:Nn \@memback@floats
{
- \counterwithin {scheme} {chapter}
- \setcounter {scheme} {0}
+ \counterwithin {#1} {chapter}
+ \setcounter {#1} {0}
}
\chemmacros_tex_if:nT {artopt}
- { \counterwithout {scheme} {chapter} }
+ { \counterwithout {#1} {chapter} }
}
\chemmacros_define_float_method:nnn {tocbasic}
@@ -90,26 +90,40 @@
float ,
name = \chemmacros_translate:n {#1-name} ,
listname = {\exp_not:N \chemmacros_translate:n {#1-list}}
- ]{los}
+ ]{#2}
}
\chemmacros_define_float_method:nnn {newfloat}
{ \chemmacros_if_package_loaded_p:n {newfloat} }
{
\DeclareFloatingEnvironment[{
- fileext = los ,
+ fileext = #2 ,
listname = {\exp_not:N \chemmacros_translate:n {#1-list}} ,
name = #2
}]{#1}
}
+\ChemCompatibilityFrom{5.1}
+\chemmacros_define_float_method:nnn {floatrow}
+ { \chemmacros_if_package_loaded_p:n {floatrow} }
+ {
+ \DeclareNewFloatType{#1}{%
+ fileext = #2,
+ placement = htp,
+ name = \chemmacros_translate:n {#1-name}
+ }
+ \cs_new_protected:cpn {listof#1s}
+ { \listof {#1} {\chemmacros_translate:n {#1-list}} }
+ }
+\EndChemCompatibility
+
\chemmacros_define_float_method:nnn {float}
{ \chemmacros_if_package_loaded_p:n {float} }
{
- \newfloat {scheme} {htp} {los}
- \floatname {scheme} {\chemmacros_translate:n {#1-name}}
- \cs_new_protected:Npn \listofschemes
- { \listof {scheme} {\chemmacros_translate:n {#1-list}} }
+ \newfloat {#1} {htp} {#2}
+ \floatname {#1} {\chemmacros_translate:n {#1-name}}
+ \cs_new_protected:cpn {listof#1s}
+ { \listof {#1} {\chemmacros_translate:n {#1-list}} }
}
% --------------------------------------------------------------------------
@@ -134,15 +148,15 @@
\chemmacros_check_float_method:n
}
-\AtBeginDocument
+\AtEndPreamble
{
\chemmacros_check_float_methods:
- \chemmacros_define_float:n {scheme}
+ \chemmacros_define_float:nn {scheme} {los}
}
% --------------------------------------------------------------------------
% #1: env name
-\cs_new_protected:Npn \chemmacros_define_float:n #1
+\cs_new_protected:Npn \chemmacros_define_float:nn #1#2
{
\bool_if:nT
{ !\cs_if_exist_p:c {#1} && !\cs_if_exist_p:c {#1} }
@@ -153,22 +167,25 @@
\l__chemmacros_float_method_tl
\l__chemmacros_tmpa_tl
\tl_use:N \l__chemmacros_tmpa_tl
- \__chemmacros_define_float:n {#1}
+ \__chemmacros_define_float:nn {#1} {#2}
}
{
- \newcounter {scheme}
- \cs_set:Npn \thescheme {\@arabic\c@scheme}
- \cs_new:Npn \fps@scheme {tbp}
- \cs_new:Npn \ftype@scheme {8}
- \cs_new:Npn \ext@scheme {los}
- \cs_new:Npn \fnum@scheme {\schemename\nobreakspace\thescheme}
- \cs_new:Npn \schemename {\chemmacros_translate:n {#1-name}}
- \cs_new:Npn \listschemename {\chemmacros_translate:n {#1-list}}
- \newenvironment {scheme}
- {\@float{scheme}}
+ \newcounter {#1}
+ \cs_set:cpn {the#1} {\arabic{#1}}
+ \cs_new:cpn {fps@#1} {tbp}
+ \cs_new:cpn {ftype@#1} {8}
+ \cs_new:cpn {ext@#1} {#2}
+ \cs_new:cpx {fnum@#1} {
+ \exp_not:c {#1name}
+ \exp_not:N \nobreakspace
+ \exp_not:c {the#1}}
+ \cs_new:cpn {#1name} {\chemmacros_translate:n {#1-name}}
+ \cs_new:cpn {list#1name} {\chemmacros_translate:n {#1-list}}
+ \newenvironment {#1}
+ {\@float{#1}}
{\end@float}
- \newenvironment {scheme*}
- {\@dblfloat{scheme}}
+ \newenvironment {#1*}
+ {\@dblfloat{#1}}
{\end@dblfloat}
\bool_if:nTF
{
@@ -176,38 +193,38 @@
\chemmacros_if_class_loaded_p:n {report}
}
{
- \cs_new_protected:Npn \listofschemes
+ \cs_new_protected:cpn {listof#1s}
{
\chemmacros_tex_if:nTF {@twocolumn}
{ \@restonecoltrue\onecolumn }
{ \@restonecolfalse }
- \chapter* {\listschemename}
+ \exp_args:NNx \chapter* {\exp_not:c {list#1name}}
\@mkboth
- {\MakeUppercase\listschemename}
- {\MakeUppercase\listschemename}
- \@starttoc {los}
+ { \MakeUppercase \use:c {list#1name} }
+ { \MakeUppercase \use:c {list#1name} }
+ \@starttoc {#2}
\chemmacros_tex_if:nT {@restonecol}
{ \twocolumn }
}
}
{
- \cs_new_protected:Npn \listofschemes
+ \cs_new_protected:cpn {listof#1s}
{
- \section* {\listschemename}
+ \exp_args:NNx \section* {\exp_not:c {list#1name}}
\@mkboth
- {\MakeUppercase\listschemename}
- {\MakeUppercase\listschemename}
- \@starttoc {los}
+ { \MakeUppercase \use:c {list#1name} }
+ { \MakeUppercase \use:c {list#1name} }
+ \@starttoc {#2}
}
}
- \cs_new_eq:NN \l@scheme \l@figure
- \chemmacros_if_package_loaded:nT
- {floatrow}
- { \flrow@restyle {scheme} }
+ \cs_new_eq:cN {l@#1} \l@figure
}
}
\cs_set:Npn \schemename {\chemmacros_translate:n {#1-name}}
\cs_set:Npn \listschemename {\chemmacros_translate:n {#1-list}}
}
+\tex_endinput:D
% --------------------------------------------------------------------------
+2015/09/19 - make the module compatible with floatrow
+
diff --git a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.sty b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.sty
index 27fcc7a93cd..b2907ec4e2f 100644
--- a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.sty
+++ b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.sty
@@ -31,9 +31,9 @@
% --------------------------------------------------------------------------
% package information:
-\tl_const:Nn \c_chemmacros_date_tl {2015/09/11}
+\tl_const:Nn \c_chemmacros_date_tl {2015/09/23}
\tl_const:Nn \c_chemmacros_version_major_number_tl {5}
-\tl_const:Nn \c_chemmacros_version_minor_number_tl {0}
+\tl_const:Nn \c_chemmacros_version_minor_number_tl {1}
\tl_const:Nn \c_chemmacros_version_subrelease_tl {}
\tl_const:Nx \c_chemmacros_version_number_tl
{\c_chemmacros_version_major_number_tl.\c_chemmacros_version_minor_number_tl}
@@ -457,3 +457,6 @@ Version history
http://www.mychemistry.eu/2015/06/chemmacros-development/
and the manual section 3.4. Upgrading from version < 5.0
for details
+2015/09/23 - version 5.1 - add option `method' to `chemformula' module
+ - make module `scheme' compatible with `floatrow'
+ - add module hooks `before' and `after'
diff --git a/Master/texmf-dist/tex/latex/chemmacros/chemmacros5.sty b/Master/texmf-dist/tex/latex/chemmacros/chemmacros5.sty
index 7b191bf4948..e8fa9be35f1 100644
--- a/Master/texmf-dist/tex/latex/chemmacros/chemmacros5.sty
+++ b/Master/texmf-dist/tex/latex/chemmacros/chemmacros5.sty
@@ -143,24 +143,26 @@
{
\chemmacros_if_module_exist:nTF {#1}
{
+ \__chemmacros_use_module_hook:nn {before} {#1}
\msg_log:nnn {chemmacros} {loading-module} {#1}
\@onefilewithoptions
{\c__chemmacros_module_prefix_tl.#1}[][]
\c__chemmacros_module_extension_tl
+ \__chemmacros_use_module_hook:nn {after} {#1}
}
{ \msg_error:nnn {chemmacros} {module-missing} {#1} }
}
}
\cs_generate_variant:Nn \__chemmacros_load_module:n { V }
-\prg_new_conditional:Npnn \chemmacros_if_module_loaded:n #1 {T,F,TF}
+\prg_new_conditional:Npnn \chemmacros_if_module_loaded:n #1 {p,T,F,TF}
{
\cs_if_exist:cTF {chemmacros-module-#1-loaded}
{ \prg_return_true: }
{ \prg_return_false: }
}
-\prg_new_conditional:Npnn \chemmacros_if_module_exist:n #1 {T,F,TF}
+\prg_new_conditional:Npnn \chemmacros_if_module_exist:n #1 {p,T,F,TF}
{
\file_if_exist:nTF
{\c__chemmacros_module_prefix_tl.#1.\c__chemmacros_module_extension_tl}
@@ -168,6 +170,50 @@
{ \prg_return_false: }
}
+% --------------------------------------------------------------------------
+% module hooks:
+% #1: module
+% #2: code
+\ChemCompatibilityFrom{5.1}
+\cs_new_protected:Npn \chemmacros_after_module:nn #1#2
+ {
+ \chemmacros_if_module_loaded:nTF {#1}
+ {#2}
+ { \__chemmacros_add_to_module_hook:nnn {#1} {after} {#2} }
+ }
+
+% #1: module
+% #2: code
+\cs_new_protected:Npn \chemmacros_before_module:nn #1#2
+ {
+ \chemmacros_if_module_loaded:nF {#1}
+ { \__chemmacros_add_to_module_hook:nnn {#1} {before} {#2} }
+ }
+\EndChemCompatibility
+
+% #1: module
+% #2: hook name
+% #3: code
+\cs_new_protected:Npn \__chemmacros_add_to_module_hook:nnn #1#2#3
+ {
+ \chemmacros_if_module_loaded:nF {#1}
+ {
+ \tl_if_exist:cF {g__chemmacros_module_#1_#2_hook_tl}
+ { \tl_new:c {g__chemmacros_module_#1_#2_hook_tl} }
+ \tl_gput_right:cn {g__chemmacros_module_#1_#2_hook_tl} {#3}
+ }
+ }
+
+\cs_new_protected:Npn \__chemmacros_use_module_hook:nn #1#2
+ {
+ \tl_if_exist:cT {g__chemmacros_module_#1_#2_hook_tl}
+ {
+ \tl_use:c {g__chemmacros_module_#1_#2_hook_tl}
+ \tl_gclear:c {g__chemmacros_module_#1_#2_hook_tl}
+ }
+ }
+
+% --------------------------------------------------------------------------
\cs_new_protected:Npn \chemmacros_module:nnn #1#2#3
{
\cs_new:cpn {chemmacros-module-#2-loaded} {chemmacros:~module~`#2'}
@@ -182,8 +228,7 @@
]
\bool_if:nF {#1} { \ExplSyntaxOn }
}
-
-% --------------------------------------------------------------------------
+
% define a chemmacros module:
% standard modules are written in the expl3 programming environment, the
% starred version only uses a 2e programming environment, i.e., with @ as a
@@ -239,5 +284,5 @@ Modules: (* = preloaded)
% --------------------------------------------------------------------------
Version history
-2015/08/29 v5.0 - major update of chemmacros; please refer to the end of file
- chemmacros4.sty for the earlier history
+2015/08/29 - initial release v5.0
+2015/09/23 - add module hooks `before' and `after'