Debian Codegraph @

texmf-dist/source/generic/commado/commado.tex

raw
1 \ProvidesFile{commado.tex}[2015/11/16 documenting commado.sty]
2 \title{\pkg{\huge commado.sty} and \pkg{\huge filesdo.sty}\\---\\%
3 Immediately Extend a One-Argument Macro\\
4 to Comma-Separated Lists and Combinations\\
5 of Filename Bases and Extensions\thanks{This document describes
6 \textcolor{blue}{\UseVersionOf{\jobname.sty}}
7 of \textsf{\jobname.sty} as of \UseDateOf{\jobname.sty}
8 and version \textcolor{blue}{\UseVersionOf{filesdo.sty}}
9 as of \UseDateOf{filesdo.sty} of \pkg{filesdo.sty}..}}
10 % \RequirePackage[wrap]{nicefilelist} \listfiles
11 \RequirePackage{makedoc} \ProcessLineMessage{}
12 \renewcommand*{\mdSectionLevelOne}{\string\subsection}
13 \MakeJobDoc{19}{\SectionLevelOneParseInput} %% 2012/11/26
14 \documentclass[fleqn]{article}%% TODO paper dimensions!?
15 % \documentclass{article} %% TODO paper dimensions!?
16 \usepackage{catchdq} %% TODO earlier than `langcode'
17 \input{makedoc.cfg} %% shared formatting settings
18 \ifpdf\else \errhelp{hyperref v6.83m option [draft] bad with \begin{equation}}
19 \errmessage{run this with pdflatex only}\fi
20 \ReadPackageInfos{commado,filesdo}
21 % \usepackage{commado}
22 \MDkeywords{macro programming, programming structures, loops, lists}
23 \sloppy \catchdqs
24 \begin{document}
25 \maketitle
26 \begin{MDabstract}
27 'commado.sty' provides \[`\DoWithCSL{<cmd>}{<list>}'\]
28 in order to apply an existing one-parameter macro <cmd>
29 to each item in a list <list> in which items are
30 \wikienref{comma-separated list}{separated by commas.}
31 'filesdo.sty' provides \[`\DoWithBasesExts{<cmd>}{<bases>}{<exts>}'\]
32 in order to run `<cmd>{<base>.<ext>}' for some (at most)
33 one-parameter macro <cmd>, each base filename <base> in the
34 comma-separated list <bases> and each filename extension <ext>
35 in the comma-separated list <exts>.
36 As opposed to \LaTeX's internal `\@for', no assignments are involved
37 (unless <cmd> uses assignments---"expandability" in "\TeX's gullet").
38
39 Both packages are "generic," i.e., should work with Plain \TeX,
40 \LaTeX\ or even other formats, relying on the \ctanpkgref{plainpkg}
41 package for some minimal \LaTeX-like behaviour.
42
43 \MDaddtoabstract{Related packages} \ctanpkgref{loops} and others
44 mentioned in the \ctanpkgref{dowith} package documentation.
45 \end{MDabstract}
46 \newpage
47 \tableofcontents
48 % \newpage
49 \section{Installing and Calling}
50 The files 'commado.sty' and 'filesdo.sty'
51 are provided ready, installation just requires
52 putting them somewhere where \TeX\ finds them
53 (which may need updating the filename data
54 base).\urlfoot{ukfaqref}{inst-wlcf}
55 However, installation of the package \ctanpkgdref{plainpkg}
56 and the package 'stacklet.sty' (\ctanpkgdref{catcodes} bundle)
57 is required additionally.
58
59 As to calling (loading): 'commado.sty' and 'filesdo.sty' are
60 "\pkg{plainpkg} packages" in the sense of the 'plainpkg'
61 documentation that you may consult for details.
62 So roughly,
63 \begin{itemize}
64 \item load it by \ |\usepackage{<pkg>}| \ if you can,
65 \item otherwise by \ |\RequirePackage{<pkg>}| \\
66 (perhaps from within another "\pkg{plainpkg} package"),
67 \item or by \ |\input <pkg>.sty|
68 \item or even by \ |\input{<pkg>.sty}|~\dots
69 \end{itemize}
70 ---where <pkg> is \qtdcode{commado} or \qtdcode{filesdo}.
71
72 % \pagebreak
73 \section{Syntax and Relation to the 'dowith' Package}
74 In <list> with |\DoWithCSL{<cmd>}{<list>}|, blank spaces %% boxed 2015/11/15
75 before entries or after commas as well as preceding the
76 closing brace are ignored. So
77 \[`\DoWithCSL{<cmd>}{ cfg, sty, tex }'\]
78 works like
79 \[`\DoWithAllOf{<cmd>}{{cfg}{sty}{tex}}'\] %% added `AllOf' 2015/11/15
80 from \ctanpkgstyref{dowith}.\urlfoot{CtanPkgRef}{dowith} %% foot 2012/11/30
81 With `\DoWithCSL'
82 (at present), %% 2012/11/27
83 an item cannot be empty or consist of blank spaces only.
84 Empty or blank items can be handled by `\DoWith'\-`AllOf'.
85 %% <- was not wrong without `AllOf', however ... 2015/11/15
86 %% ... hyphenation is a great compromise! without hyphen?
87 \par %% 2015/11/15
88 \begingroup \footnotesize
89 As to \strong{relevance}, the previous remark addresses those
90 who want to understand what I am doing, such as me.
91 The two commands provide a rather obvious ``link'' between the 'commado'
92 and the 'dowith' bundle. But neither of them is a command that
93 ``you shouldn't miss.'' 'commado.sty' is mainly a programming tool
94 (and I isolate it as an object of study).
95 % similar to a chess diagram to demonstrate how to trap a lonely king
96 % with king and rook only, the actual task being expandability,
97 % in my case to generate \acro{HTML} with \TeX's `\write' primitive).
98 \par\strong{Choosing between 'dowith' and 'commado'.}\quad What I
99 \strong{really use} in the case of comma-separated lists is
100 \strong{'filesdo.sty'} as described in the next section. %% TODO really?
101 It is great to keep certain files or file sections small (\strong{readability}),
102 actually in describing package bundles, on \acro{CTAN} as well as
103 with a complex book at which I am working. However,
104 the comma feature is a little more complex than the 'dowith' way,
105 and I like to avoid unnecessarily complex things.
106 The real advantage of 'filesdo', as I feel it,
107 is the readability of the code with combinations of file \emph{basenames}
108 and \emph{extensions}, similar to \emph{brace expansion} in the
109 \Wikidisambref{Bash}{Unix shell} shell.
110 The braces make obvious which are the basenames and which are the
111 extensions, and the commas structure each of these two lists.
112
113 In applications of \strong{'dowith'}, saving \strong{tokens} and
114 \strong{expansion} steps is more important to me (a kind of sports).
115 \emph{Tokens} actually are saved with 'dowith' when <list> consists of
116 single tokens rather than ``\strong{brace groups},''
117 and the former is the application of 'dowith' in my \ctanpkgdref{langcode} package
118 (in the 'dowith' discussion, I compare this with the \ctanpkgdref{xspace} package).
119 On the other hand, a <list> of brace groups even needs more tokens than a comma-separated list.
120 % (Due to \TeX's tokenization, readability and parsimony are opposite and
121 % incompatible goals.)
122 The number of tokens or expansion steps is relevant when a list is stored
123 as a macro or in a token register. It is less relevant when a list
124 is processed once only at the moment the input file is read
125 and then is not stored any longer.
126
127 There is a situation where I prefer lists of \emph{brace groups}
128 to comma-separated lists although the former need more tokens
129 and their readablility is worse: I use something like
130 \begin{equation}
131 `\autrefs{{apples}{oranges}{pears}}'
132 \end{equation}
133 to generate a list of internal links in a \acro{HTML} file.
134 `\autrefs' this way rests on `\DoSeparateWith' from 'domore.sty'.
135 `\DoSeparateWith' is based on `\DoWith'. Sometimes I use the former
136 one directly as an \emph{author}. The alternative
137 \begin{equation}
138 `\autrefs{apples,oranges,pears}'
139 \end{equation}
140 would need less tokens (which is absolutely irrelevant in this case
141 because the line is in \TeX's memory for a moment only)
142 and may be easier to read. However, often I want to change the order
143 of the items. When I try this by cut\&paste in a comma-separated list,
144 I always wonder whether I should cut/copy the right-hand comma
145 of a list item or the left-hand comma; and at the next moment,
146 I have forgotten whether I cut the right-hand comma
147 or the other one. With the 'dowith' approach, I just cut\&paste
148 a brace group. A function key opens an empty brace group in my
149 favorite editor.
150
151 \par \endgroup
152
153 \section{Example for 'filesdo.sty'}
154 In the file `srcfiles.tex' for the \ctanpkgdref{nicetext} bundle,
155 there is a line
156 \begin{quote}
157 `\DoWithBasesExts\ReadFileInfos{fifinddo,niceverb}{sty,tex}'\kern-10pt
158 \end{quote}
159 This works like
160 \begin{quote}
161 `\ReadFileInfos{fifinddo.sty}'\\
162 `\ReadFileInfos{niceverb.sty}'\\
163 `\ReadFileInfos{fifinddo.tex}'\\
164 `\ReadFileInfos{niceverb.tex}'
165 \end{quote}
166 or actually
167 (a special feature of \ctanpkgref{readprov}'s\urlfoot{CtanPkgRef}{readprov}
168 %% <- foot 2012/11/30
169 `\ReadFileInfos' is that its argument may be
170 a comma-separated list already)
171 \begin{quote}
172 `\ReadFileInfos{fifinddo.sty,niceverb.sty,'\\
173 \null\texttt{ ~ ~ ~ ~ ~ ~ ~ }`fifinddo.tex,niceverb.tex}'
174 \end{quote}
175 I ponder providing a shorthand `\ReadBaseExtInfos' for
176 \begin{quote}
177 `\DoWithBasesExts\ReadFileInfos'
178 \end{quote}
179 and reimplementing `\ReadFileInfos' using `\DoWithCLS' in 'myfilist.sty'
180 (2012-11-27).
181
182 \pagebreak
183 \section{The File 'commado.sty'}
184 \subsection{Package File Header (Legalese and 'plainpkg')}
185 \input{commado.doc}
186
187 \newpage
188
189 \section{The File 'filesdo.sty'}
190 \subsection{Package File Header (Legalese and 'plainpkg')}
191 \ResetCodeLineNumbers
192 \renewcommand*{\mdJobName}{filesdo}
193 \MakeInputJobDoc{19}{\SectionLevelOneParseInput}
194 \end{document}
195
196 VERSION HISTORY
197
198 2012/11/24 for v0.1 very first
199 2012/11/30 for v0.11 \ctanpkgdref moves to `makedoc.cfg',
200 2 more link footnotes
201 2015/11/15f. `AllOf' was missing in the description of
202 the relation to the `dowith' bundle --
203 added an "essay"
204 2015/11/15 error message to deal with hyperref's
205 draft/equation problem as in dowith.tex