summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/concepts/with.sty
blob: 4e94ac0251647e3093b2ba0853cd0afdbc20d04a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \iffalse %%%%
%                                                                              %
%  Copyright (c) 2012 - Michiel Helvensteijn   (www.mhelvens.net)              %
%                                                                              %
%  http://latex-concepts.googlecode.com                                        %
%                                                                              %
%  This work may be distributed and/or modified under the conditions           %
%  of the LaTeX Project Public License, either version 1.3 of this             %
%  license or (at your option) any later version. The latest version           %
%  of this license is in       http://www.latex-project.org/lppl.txt           %
%  and version 1.3 or later is part of all distributions of LaTeX              %
%  version 2005/12/01 or later.                                                %
%                                                                              %
%  This work has the LPPL maintenance status `author-maintained'.              %
%                                                                              %
%  The Current Maintainer of this work is Michiel Helvensteijn.                %
%                                                                              %
%  This work consists of the file with.sty.                                    %
%                                                                              %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \fi %%%%

% I will 'officially' release this package at some point in the future. For
% now I'm just using it to document the concepts package. Still, it's
% released under LPPL, so use it as you will.
%
% -- Michiel Helvensteijn

\NeedsTeXFormat{LaTeX2e}
\RequirePackage{expl3}
\ProvidesExplPackage{with}{2012/12/16}{0.0.1}
  {an inline construct for passing token lists as ##1-type arguments}

\cs_new_eq:NN \qnv \q_no_value

\cs_new:Nn \with:nn {
  \with:nnnnnnnnn {#1}\qnv\qnv\qnv\qnv\qnv\qnv\qnv{#2}
}

\cs_new:Nn \with:nnn {
  \with:nnnnnnnnn {#1}{#2}\qnv\qnv\qnv\qnv\qnv\qnv{#3}
}

\cs_new:Nn \with:nnnn {
  \with:nnnnnnnnn {#1}{#2}{#3}\qnv\qnv\qnv\qnv\qnv{#4}
}

\cs_new:Nn \with:nnnnn {
  \with:nnnnnnnnn {#1}{#2}{#3}{#4}\qnv\qnv\qnv\qnv{#5}
}

\cs_new:Nn \with:nnnnnn {
  \with:nnnnnnnnn {#1}{#2}{#3}{#4}{#5}\qnv\qnv\qnv{#6}
}

\cs_new:Nn \with:nnnnnnn {
  \with:nnnnnnnnn {#1}{#2}{#3}{#4}{#5}{#6}\qnv\qnv{#7}
}

\cs_new:Nn \with:nnnnnnnn {
  \with:nnnnnnnnn {#1}{#2}{#3}{#4}{#5}{#6}{#7}\qnv{#8}
}

\cs_new:Nn \with:nnnnnnnnn {
  \cs_set:Nn \with_aux:nnnnnnnn {#9}
  \with_aux:nnnnnnnn {#1}{#2}{#3}{#4}{#5}{#6}{#7}{#8}
}

\cs_generate_variant:Nn \with:nn        {xn}
\cs_generate_variant:Nn \with:nnn       {xxn}
\cs_generate_variant:Nn \with:nnnn      {xxxn}
\cs_generate_variant:Nn \with:nnnnn     {xxxxn}
\cs_generate_variant:Nn \with:nnnnnn    {xxxxxn}
\cs_generate_variant:Nn \with:nnnnnnn   {xxxxxxn}
\cs_generate_variant:Nn \with:nnnnnnnn  {xxxxxxxn}
\cs_generate_variant:Nn \with:nnnnnnnnn {xxxxxxxxn}

\NewDocumentCommand{\With}{+o+o+o+o+o+o+o+o+m}{
  \IfValueTF{#8}{ \with:xxxxxxxxn{#1}{#2}{#3}{#4}{#5}{#6}{#7}{#8}{#9} }{
  \IfValueTF{#7}{ \with:xxxxxxxn {#1}{#2}{#3}{#4}{#5}{#6}{#7}    {#9} }{
  \IfValueTF{#6}{ \with:xxxxxxn  {#1}{#2}{#3}{#4}{#5}{#6}        {#9} }{
  \IfValueTF{#5}{ \with:xxxxxn   {#1}{#2}{#3}{#4}{#5}            {#9} }{
  \IfValueTF{#4}{ \with:xxxxn    {#1}{#2}{#3}{#4}                {#9} }{
  \IfValueTF{#3}{ \with:xxxn     {#1}{#2}{#3}                    {#9} }{
  \IfValueTF{#2}{ \with:xxn      {#1}{#2}                        {#9} }{
  \IfValueTF{#1}{ \with:xn       {#1}                            {#9} }
                                                                 {#9}
  }}}}}}}
}

\int_new:c{g_with_uniquecsname_count}

\cs_new:Nn \with_uniquecsname:n {
  \with_uniquecsname:xn {uniquecsname} {#1}
}

\cs_new:Nn \with_uniquecsname:xn {
  \int_incr:c {g_with_uniquecsname_count}
  \with:xn {#1\int_use:c{g_with_uniquecsname_count}} {#2}
}

\NewDocumentCommand{\WithUniqueCsname}{O{uniquecsname}+m}{
  \with_uniquecsname:xn {#1} {#2}
}