Bump version number to 1.0b14.
[clon.git] / doc / enduser.texi
blob6baa16e895818fd67553117ca4d2d92b9fe551d1
1 \input texinfo
3 @c enduser.texi --- End-user manual
5 @c Copyright (C) 2010 Didier Verna
7 @c Author:        Didier Verna <didier@lrde.epita.fr>
8 @c Maintainer:    Didier Verna <didier@lrde.epita.fr>
9 @c Created:       Tue Jun  2 18:29:49 2009
10 @c Last Revision: Thu Aug 12 14:57:09 2010
12 @c This file is part of Clon.
14 @c Clon is free software; you can redistribute it and/or modify
15 @c it under the terms of the GNU General Public License version 3,
16 @c as published by the Free Software Foundation.
18 @c Clon is distributed in the hope that it will be useful,
19 @c but WITHOUT ANY WARRANTY; without even the implied warranty of
20 @c MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21 @c GNU General Public License for more details.
23 @c You should have received a copy of the GNU General Public License
24 @c along with this program; if not, write to the Free Software
25 @c Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 @c Commentary:
30 @c Contents management by FCM version 0.1.
33 @c ====================================================================
34 @c Header
35 @c ====================================================================
36 @c %**start of header
37 @setfilename clon-enduser.info
38 @settitle The Clon End-User Manual
39 @afourpaper
40 @c %**end of header
44 @c ====================================================================
45 @c Settings
46 @c ====================================================================
47 @set VERSION 1.0 beta 14 "Michael Brecker"
48 @set COPYRIGHT_DATE 2010
49 @setchapternewpage odd
50 @setcontentsaftertitlepage
51 @documentdescription
52 The Clon End-User Manual for version @value{VERSION}.
53 @end documentdescription
57 @c ====================================================================
58 @c New Commands
59 @c ====================================================================
61 @macro clon
62 @t{Clon}
63 @end macro
65 @macro cl
66 Common Lisp
67 @end macro
69 @macro tty
70 @t{tty}
71 @end macro
73 @macro etc
74 @i{etc.}
75 @end macro
77 @macro eg
78 @i{e.g.}
79 @end macro
81 @macro ie
82 @i{i.e.}
83 @end macro
85 @macro perse
86 @i{per-se}
87 @end macro
89 @macro cmdline
90 command-line
91 @end macro
93 @macro CmdLine
94 Command-Line
95 @end macro
98 @c The following 3 macros are here to circumvent the info filenames
99 @c changes, when referencing the user manual:
101 @macro pxuserref{node}
102 @ifinfo
103 @pxref{\node\, , , clon-user, The Clon User Manual}
104 @end ifinfo
105 @ifnotinfo
106 @pxref{\node\, , , user, The Clon User Manual}
107 @end ifnotinfo
108 @end macro
110 @macro xuserref{node}
111 @ifinfo
112 @xref{\node\, , , clon-user, The Clon User Manual}
113 @end ifinfo
114 @ifnotinfo
115 @xref{\node\, , , user, The Clon User Manual}
116 @end ifnotinfo
117 @end macro
119 @macro userref{node}
120 @ifinfo
121 @ref{\node\, , , clon-user, The Clon User Manual}
122 @end ifinfo
123 @ifnotinfo
124 @ref{\node\, , , user, The Clon User Manual}
125 @end ifnotinfo
126 @end macro
130 @c ====================================================================
131 @c Info Category and Directory
132 @c ====================================================================
133 @dircategory Common Lisp
134 @direntry
135 * Clon End-User: (clon-enduser).        The Clon End-User Manual.
136 @end direntry
140 @c ====================================================================
141 @c Copying
142 @c ====================================================================
143 @copying
144 @quotation
145 Copyright @copyright{} @value{COPYRIGHT_DATE} Didier Verna.
147 Permission is granted to make and distribute verbatim copies of this
148 manual provided the copyright notice and this permission notice are
149 preserved on all copies.
151 @ignore
152 Permission is granted to process this file through TeX and print the
153 results, provided the printed document carries a copying permission
154 notice identical to this one except for the removal of this paragraph
155 (this paragraph not being relevant to the printed manual).
157 @end ignore
158 Permission is granted to copy and distribute modified versions of this
159 manual under the conditions for verbatim copying, provided also that the
160 sections entitled ``Copying'' and ``GNU General Public License'' are
161 included exactly as in the original, and provided that the entire
162 resulting derived work is distributed under the terms of a permission
163 notice identical to this one.
165 Permission is granted to copy and distribute translations of this manual
166 into another language, under the above conditions for modified versions,
167 except that this permission notice may be stated in a translation
168 approved by the Free Software Foundation.
169 @end quotation
170 @end copying
174 @c ====================================================================
175 @c Title Page
176 @c ====================================================================
177 @titlepage
178 @title The Clon End-User Manual
179 @subtitle The @CmdLine{} Options Nuker, Version @value{VERSION}
180 @vskip 2cm
181 @image{clon,16cm}
182 @author Didier Verna <@email{didier@@lrde.epita.fr}>
183 @page
184 @vskip 0pt plus 1filll
185 @insertcopying
187 @hfill Cover art by Alexis Angelidis.
188 @end titlepage
192 @c ====================================================================
193 @c Table of Contents
194 @c ====================================================================
195 @contents
199 @c ====================================================================
200 @c Master Menu
201 @c ====================================================================
202 @ifnottex
203 @node Top, Copying, (dir), (dir)
204 @top The Clon End-User Manual
206 This is the @clon{} End-User Manual for @clon{} version @value{VERSION}:
207 it describes the use of applications powered by @clon{}.
209 @menu
210 * Copying::             The GNU General Public License
211 * Introduction::        What Clon is all about
212 * Clonification::       Determining whether a program is powered by Clon
213 * The Command Line::    Making use of @clon{}'s @cmdline{} features
214 * Output::              Understanding and customizing @clon{}'s output
215 * Conclusion::          That's all folks
216 * Concept Index::       Concept Index
217 @end menu
219 @insertcopying
220 @end ifnottex
224 @c ====================================================================
225 @c Copying
226 @c ====================================================================
227 @node Copying, Introduction, Top, Top
228 @unnumbered Copying
230 @quotation
231 @clon{} is free software; you can redistribute it and/or modify it under
232 the terms of the GNU General Public License version 3,
233 as published by the Software Foundation.
235 @clon{} is distributed in the hope that it will be useful, but WITHOUT
236 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
237 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
238 more details.
240 You should have received a copy of the GNU General Public License along
241 with this program; if not, write to the Free Software Foundation, Inc.,
242 675 Mass Ave, Cambridge, MA 02139, USA.
243 @end quotation
247 @c ====================================================================
248 @c Introduction
249 @c ====================================================================
250 @node Introduction, Clonification, Copying, Top
251 @chapter Introduction
253 @clon{} is a library for managing @cmdline{} options in standalone @cl{}
254 applications. It provides a unified option syntax with both short and
255 long names, automatic completion of partial names and automatic
256 retrieval/conversion of option arguments from the @cmdline{}, associated
257 environment variables, fallback or default values. @clon{} comes with a
258 set of extensible option types (switches, paths, strings @etc{}).
259 @clon{} also provides automatic generation and formatting of help
260 strings, with support for highlighting on @tty{}'s through ISO/IEC 6429
261 SGR. This formatting is customizable through @emph{themes}.
263 Depending on the target audience, @clon{} stands for either ``The
264 @CmdLine{} Options Nuker'' or ``The @cl{} Options Nuker''. @clon{} also
265 has a recursive acronym: ``@clon{} Likes Options Nuking'', and a reverse
266 one: ``Never Omit to Link with @clon{}''. Other possible expansions of
267 the acronym are still being investigated.
269 This manual is for the @clon{} @emph{end-user}, that is, the user of an
270 application powered by @clon{}. It describes how to use the @cmdline{}
271 of clonified@footnote{An application using @clon{} for its @cmdline{}
272 option management is said to be @emph{clonified}. It is also possible to
273 say @emph{clonfiscated}. However, we advise against using
274 @emph{clonistified}. The term @emph{clonificated} is also considered bad
275 style, and the use of @emph{clonificationated} is strictly prohibited.}
276 applications and how to customize @clon{}'s output. Everybody should
277 read this manual first. If you want to use @clon{} in one of your
278 applications, then you are considered a @clon{} @emph{user}, as opposed
279 to a @clon{} @emph{end-user}, and you should then read the corresponding
280 manual (@pxuserref{Top}).
282 @ref{Clonification} shows how to verify that an application is powered
283 by @clon{}. @ref{The Command Line} explains how to use the @cmdline{} of
284 a clonified application, and @ref{Output} describes how to customize the
285 output of @clon{}.
289 @c ====================================================================
290 @c Clonification
291 @c ====================================================================
292 @node Clonification, The Command Line, Introduction, Top
293 @chapter Clonification
294 @cindex @t{--clon-help}
295 @cindex @t{--clon-banner}
296 @cindex @t{--clon-version}
297 @cindex Built-in Options
298 @cindex Built-in Options, @t{--clon-help}
299 @cindex Built-in Options, @t{--clon-banner}
300 @cindex Built-in Options, @t{--clon-version}
301 @cindex Options, built-in
302 @cindex Options, built-in, @t{--clon-help}
303 @cindex Options, built-in, @t{--clon-banner}
304 @cindex Options, built-in, @t{--clon-version}
306 Given this wonderful standalone @cl{} application, how do I know if it
307 uses @clon{} for handing the @cmdline{}? Perhaps the simplest way to
308 know is to type
310 @example
311 program --clon-help
312 @end example
314 and see what happens. If you get an error, then you are out of luck.
315 Otherwise, you will get a list of @clon{}-specific options. Every
316 clonified application has these options built-in, and they are all
317 called @t{--clon-}@i{something}. We will describe most of them when
318 appropriate in this manual, but here's already the description for a
319 couple of them (in addition to @option{--clon-help} that we've just
320 mentioned).
322 @table @option
323 @item --clon-banner
324 When given this option, the application outputs a whole bunch of
325 information, including the version of @clon{} it is using, and
326 @clon{}-specific copyright information.
328 @item --clon-version
329 This option makes the application output the version of @clon{} it is
330 using. By default (or by using it like this:
331 @option{--clon-version=long}), this information is provided in
332 @emph{long} form (release number, status and name; just try it). If you
333 ask for @option{--clon-version=short}, you'll get a more compact version
334 information, and if you try @option{--clon-version=number}, you will end
335 up with a purely numerical version number. For more information on
336 @clon{} version numbering, see @userref{Version Numbering}.
337 @end table
341 @c ====================================================================
342 @c The Command Line
343 @c ====================================================================
344 @node The Command Line, Output, Clonification, Top
345 @chapter The Command Line
346 @cindex Command-Line
348 @clon{} provides applications with usual @cmdline{} features such as
349 option names coming in short (@eg{} @samp{-h}) or long (@eg{}
350 @samp{--help}) form. @clon{} also comes with a set of more specific
351 features, such as @emph{packs} or abbreviated forms, that you might want
352 to become familiar with in order to use an application's @cmdline{} to
353 its full extent.
355 @menu
356 * Option Calls::        Different ways to specify options
357 * Option Packs::        Grouping option calls together
358 * Option Separator::    Telling @clon{} to mind it's own business
359 * Option Retrieval::    How @clon{} computes the value of an option
360 @end menu
363 @c -------------
364 @c Option Calls
365 @c -------------
366 @node Option Calls, Option Packs, The Command Line, The Command Line
367 @section Option Calls
368 @cindex Command-Line, options
369 @cindex Options, command-line
371 @clon{} offers a set of precise syntactic rules that every clonified
372 application follows implicitly, making them work in a homogeneous way.
373 Although application programmers have the ability to extend @clon{} by
374 defining their own option @emph{types}, even those new options obey the
375 same syntactic rules as the built-in ones.
377 @menu
378 * Option Names::        Long, short or abbreviated
379 * Option Arguments::    None, mandatory or optional
380 @end menu
382 @node Option Names, Option Arguments, Option Calls, Option Calls
383 @subsection Option Names
384 @cindex Options, names
385 An option can come with either a short name, a long name, or both. It is
386 also possible to abbreviate long names.
388 @menu
389 * Full Names::          Long or short
390 * Abbreviations::       Shorter long names
391 @end menu
393 @node Full Names, Abbreviations, Option Names, Option Names
394 @subsubsection Full Names
395 @cindex Long Form
396 @cindex Short Form
397 @cindex Command-Line, options, long form
398 @cindex Command-Line, options, short form
399 @cindex Options, names, full
400 @cindex Options, names, long
401 @cindex Options, names, short
402 @cindex Options, command-line, long form
403 @cindex Options, command-line, short form
404 To provide an option by short name, use a @emph{short form}: a single
405 dash followed by the option's short name (@eg{} @samp{-h}). To provide
406 an option by long name, use a @emph{long form}: two dashes followed by
407 the option's long name (@eg{} @samp{--help}).
409 Short names typically consist of a single character. They are concise
410 but more difficult to remember. Long names can be whole words, or even
411 word sequences (usually separated by dashes). They are easier to
412 remember but longer to type on the @cmdline{}.
414 You should be aware of the fact that in a clonified application, neither
415 short names nor long ones are restricted in length. In fact, it would
416 be perfectly possible to have an option's short name longer than the
417 corresponding long one, although that would make little sense. The only
418 real difference is whether you use one or two dashes. Some other
419 differences also come into play when an option expects an argument
420 (@pxref{Option Arguments}) though (it would be no fun otherwise).
422 @node Abbreviations, , Full Names, Option Names
423 @subsubsection Abbreviations
424 @cindex Abbreviated Form
425 @cindex Abbreviated Long Form
426 @cindex Long Form, abbreviated
427 @cindex Options, names, abbreviated
428 @cindex Options, names, long, abbreviated
429 @cindex Command-Line, options, abbreviated form
430 @cindex Command-Line, options, abbreviated long form
431 @cindex Command-Line, options, long form, abbreviated
432 @cindex Options, command-line, abbreviated form
433 @cindex Options, command-line, abbreviated long form
434 @cindex Options, command-line, long form, abbreviated
435 When calling an option by long form, it is possible to abbreviate its
436 name, at the risk of being ambiguous. An abbreviation is simply the
437 beginning of the option's name (for instance, @samp{--he} can stand for
438 @samp{--help}). In case of ambiguity, @clon{} always chooses the option
439 which is ``closest'' to the abbreviation (here, the ``distance'' between
440 an abbreviation and an option's name is the number of missing
441 characters).
443 @node Option Arguments, , Option Names, Option Calls
444 @subsection Option Arguments
445 @cindex Arguments
446 @cindex Options, arguments
447 In @clon{}, there are different kinds of options: in addition to having
448 a short and/or long name, an option may or may not take an argument. For
449 those taking one, the argument may be either mandatory or optional.
450 Then, there is also an additional, extended call syntax for some of
451 them. But then again, that is not the whole story about getting an
452 option's value (@pxref{Option Retrieval}). If everything goes well, you
453 are now wondering whether you really want to use a @cmdline{} at all.
455 @menu
456 * Flags::                       Options with no argument
457 * Valued Options::              Options with arguments
458 * Switches::                    Options with Boolean arguments
459 @end menu
461 @node Flags, Valued Options, Option Arguments, Option Arguments
462 @subsubsection Flags
463 @cindex Flags
464 @cindex Options, types, flags
465 First of all, some options don't take an argument at all. In the @clon{}
466 jargon, these options are called @emph{flags}. Flags just stand for
467 themselves: either they are present on the @cmdline{}, or they are not
468 (as a matter of fact, this is a lie, @pxref{Option Retrieval}). A
469 typical example of a flag would be displayed like this in a standard
470 help string (but @pxref{Output}):
472 @example
473   -h, --help        Print this help and exit.
474 @end example
476 @node Valued Options, Switches, Flags, Option Arguments
477 @subsubsection Valued Options
478 @cindex Valued Options
479 @cindex Options, types, valued
480 @cindex Values
481 @cindex Options, values
482 Options taking an argument are said to be @emph{valued}. We need a bit
483 of terminology here: and option's @emph{argument} is typically what you
484 provide on the @cmdline{} (or elsewhere, @pxref{Option Retrieval}). An
485 option's argument is thus a string. An option's @emph{value} is what
486 results from the conversion of the option's argument to the proper type
487 (the same string, a number, whatever).
489 @cindex Sticky Arguments
490 @cindex Arguments, sticky
491 @cindex Options, arguments, sticky
492 @cindex Mandatory Arguments
493 @cindex Arguments, mandatory
494 @cindex Options, arguments, mandatory
495 @cindex Optional Arguments
496 @cindex Arguments, optional
497 @cindex Options, arguments, optional
498 In @clon{}, a valued option's argument can be either mandatory or
499 optional. We know that valued options, just like flags, may be provided
500 in short or long form. When using the long form, the proper way of
501 providing an argument is to append it after an @samp{=} sign, like this:
502 @samp{--phone=01020304}. When using the short form, the proper way of
503 providing an argument is to stick it right behind the option's name,
504 like this: @samp{-p01020304}. In both long and short form, we call these
505 arguments ``sticky''. All this should look familiar.
507 @cindex Separated Arguments
508 @cindex Arguments, separated
509 @cindex Options, arguments, separated
510 When the option's argument is mandatory, you also have the ability to
511 provide it in the next @cmdline{} item instead of sticking it to the
512 option's name. These arguments are said to be ``separated''. Back to the
513 previous example, this means that you can also say @samp{--phone
514 01020304} or @samp{-p 01020304}. Keep in mind that this is not possible
515 when the argument is optional (in the general case, it is not possible
516 to decide whether the next @cmdline{} item is an option's argument, a
517 new option or something else).
519 @cindex Arguments, looking like options
520 @cindex Options, as argument to other options
521 @cindex Options, arguments, looking like options
522 There is also another case where you can't use this alternate syntax,
523 even when the argument is mandatory: that is when the argument itself
524 looks like an option. @clon{} will think it is, and consequently will
525 also think that the previous one lacks its mandatory argument.
527 The phone example above would look like this in a standard help string
528 (but @pxref{Output}):
530 @example
531   -p, --phone=NUM    Set phone number to NUM.
532 @end example
534 And here is an example illustrating a typical output when the argument
535 is optional:
537 @example
538   -f, --fax[=NUM]    Set fax number to NUM, or same as phone.
539 @end example
541 @node Switches, , Valued Options, Option Arguments
542 @subsubsection Switches
543 @cindex Switches
544 @cindex Options, types, switches
545 For those of you who are not satisfied with short and long forms,
546 @clon{} provides a specific option type for Boolean values, along with
547 an additional call syntax. These options are called @emph{switches}.
549 Just like any other kind of valued option, a switch can have a short
550 and/or a long name, and its argument may be mandatory or optional.
551 However, the possible arguments for a switch are restricted to true or
552 false. In fact, you can freely use @samp{yes}, @samp{on}, @samp{true},
553 @samp{yup}, @samp{yeah} and @samp{no}, @samp{off}, @samp{false},
554 @samp{nope}, @samp{nah} respectively.@footnote{If you want more, a very
555 modest additional fee will be charged.}
557 @cindex Negated Form
558 @cindex Negated Short Form
559 @cindex Short Form, negated
560 @cindex Options, command-line, negated form
561 @cindex Options, command-line, negated short form
562 @cindex Options, command-line, short form, negated
563 @cindex Command-Line, options, negated form
564 @cindex Command-Line, options, negated short form
565 @cindex Command-Line, options, short form, negated
566 In addition to the standard short and long forms, a switch can be
567 provided in @emph{negated form}, that is, by appending its short name
568 behind a @samp{+} character. This form never takes any argument and
569 always means false (turn the switch off, if you prefer).
571 Although an application might do something different, the intended usage
572 for switches is to take an optional argument that defaults to true. A
573 typical example would look like this in a standard help string (but
574 @pxref{Output}):
576 @example
577   -(+)d, --debug[=yes/no]    Whether to enable debugging.
578 @end example
580 Given such an option, you can turn debugging on by saying just @samp{-d}
581 or @samp{--debug} (but you can also provide an explicit argument like
582 this: @samp{-dyes} or that: @samp{--debug=yes}). Similarly, to turn
583 debugging off, use @samp{+d} or @samp{--debug=no}.
585 One last word about switches: @clon{} lets application developers create
586 new options based on (but not limited to) switches. These options
587 typically accept Boolean arguments as well as some other value(s). As
588 soon as an option is switch-based (and has a short name), the negated
589 form becomes automatically available, and this should be advertised in
590 the application's help string.
593 @c ------------
594 @c Option Packs
595 @c ------------
596 @node Option Packs,  Option Separator, Option Calls, The Command Line
597 @section Option Packs
598 @cindex Packs
599 @cindex Command-Line, packs
600 @cindex Options, command-line, packed
602 In addition to using options individually (@pxref{Option Calls}),
603 @clon{} offers the possibility to group option calls together under some
604 circumstances. This feature is know as option @emph{packs}. @clon{}
605 offers two kinds of packs.
607 @menu
608 * Short Packs::         Grouping short forms together
609 * Negated Packs::       Grouping negated forms together
610 @end menu
612 @node Short Packs, Negated Packs, Option Packs, Option Packs
613 @subsection Short Packs
614 @cindex Short packs
615 @cindex Packs, short
616 @cindex Command-Line, short packs
617 @cindex Command-Line, packs, short
618 A short pack allows you to group multiple short forms in a single
619 @cmdline{} item. For instance, instead of calling your program like
620 this: @samp{program -c -u -p}, you can directly use: @samp{program
621 -cup}.
623 @cindex Options, names, short, one character
624 A short pack can only contain options the short names of which are
625 exactly one character long. Also, it should be obvious that you cannot
626 provide an argument to an option in a pack. As a consequence, only flags
627 and options with optional (and not provided) arguments may appear in a
628 short pack.
630 There is one exception however: it @emph{is} possible to provide an
631 argument to the @emph{last} option in the pack. If provided, this
632 argument must be located in the next @cmdline{} item. It cannot be
633 sticked to the option, so this means in particular that this option's
634 argument is mandatory (@pxref{Valued Options}).
636 Beware that using short packs comes at the risk of ambiguity. When
637 @clon{} parses a @cmdline{} item beginning with only one dash, it tries
638 to detect options first, options with a sticky argument next, and then
639 short packs. For that reason, you cannot possibly start a pack with a
640 valued option. Indeed, suppose that the option @samp{-c} takes an
641 argument. What you @emph{think} is a short pack (@samp{-cup}) will in
642 fact be interpreted as the option @samp{-c} with a sticky (and maybe
643 invalid) argument @samp{up}. On the other hand, if the option @samp{-u}
644 is only a flag (@pxref{Flags}), then you can safely pack your options in
645 a different order, like this: @samp{-ucp}.
647 A single @cmdline{} may contain as many short packs as you like, and
648 they can also be intermixed with regular option calls.
650 @node Negated Packs, , Short Packs, Option Packs
651 @subsection Negated Packs
652 @cindex Negated packs
653 @cindex Negated Short Packs
654 @cindex Negated packs, short
655 @cindex Packs, negated
656 @cindex Packs, short, negated
657 @cindex Command-Line, negated packs
658 @cindex Command-Line, negated short packs
659 @cindex Command-Line, short packs, negated
660 @cindex Command-Line, packs, negated
661 @cindex Command-Line, packs, short, negated
662 In a very similar way, a negated pack allows you to group multiple
663 negated forms in a single @cmdline{} item. As such, this feature only
664 applies to switches or switch-based options (@pxref{Switches}). For
665 instance, instead of calling your program like this: @samp{program +c +u
666 +p}, you can directly use: @samp{program +cup}.
668 @cindex Options, names, short, one character
669 A negated pack can only contain options the short names of which are
670 exactly one character long. Also, remember that negated forms never take
671 any argument.
673 Beware that using negated packs comes at the risk of ambiguity (although
674 much less than with short packs). When @clon{} parses a @cmdline{} item
675 beginning with a @samp{+}, it tries to detect options first, and then
676 negated packs. For that reason, the order in which you specify the
677 options in the pack is important. Indeed, suppose that your application
678 has a @samp{+cup} switch (this would be a very bad idea, but
679 still@dots{}). If you want to provide the same pack as above, then you
680 need to modify the options order, like this: @samp{+ucp}.
682 A single @cmdline{} may contain as many negated packs as you like, and
683 they can also be intermixed with regular option calls or short packs.
686 @c ----------------
687 @c Option Separator
688 @c ----------------
689 @node Option Separator, Option Retrieval, Option Packs, The Command Line
690 @section Option Separator
691 @cindex Separator
692 @cindex Command-Line, separator
693 @cindex Postfix
694 @cindex Command-Line, postfix
696 @clon{} separates the @cmdline{} in two parts. The left part contains
697 option calls and packs while the right part contains the rest. The right
698 part is also called the @emph{postfix}).
700 @cindex Explicit separator
701 @cindex Separator, explicit
702 @cindex Command-Line, explicit separator
703 @cindex Command-Line, separator, explicit
704 You can force this distinction by using the special construct @samp{--}
705 on the @cmdline{}. Everything that follows it will be completely ignored
706 by @clon{} (not necessarily by the application itself though).
708 @cindex Implicit separator
709 @cindex Separator, implicit
710 @cindex Command-Line, implicit separator
711 @cindex Command-Line, separator, implicit
712 In the case you don't split your @cmdline{} explicitly, @clon{} does
713 this for you automatically by noticing where the last option (or its
714 potential argument) stands. The behavior is different from that of
715 explicit splitting in one regard however: if the application is not
716 expecting any postfix and there's an implicit one, then @clon{} will
717 throw an error at your face.
719 @cindex Postfix, options in
720 @cindex Options, in postfix
721 @cindex Command-Line, postfix, options in
722 @cindex Command-Line, options, in postfix
723 One final note on @cmdline{} separation: in the case an application's
724 postfix is supposed to contain something looking like an option (perhaps
725 real options to pass on to another program), you @strong{need} an
726 explicit separator. Otherwise, @clon{} will be confused: it could for
727 instance wrongly detect unknown options, junk on the @cmdline{} @etc{}
729 You don't want to confuse @clon{}. @clon{} is nasty when it is scared.
733 @c ----------------
734 @c Option Retrieval
735 @c ----------------
736 @node Option Retrieval, , Option Separator, The Command Line
737 @section Option Retrieval
739 @cindex Retrieval
740 @cindex Options, retrieval
741 The process of getting a value for a specific option is called
742 @dfn{retrieval}. This section explains how it works.
744 @menu
745 * Value Sources::       The command-line, and more
746 * Error Management::    What to do when something goes wrong
747 @end menu
749 @node Value Sources, Error Management, Option Retrieval, Option Retrieval
750 @subsection Value Sources
751 The @cmdline{} is not the only place where @clon{} looks for option
752 @emph{values}. Other sources for option values are: @emph{fallback}
753 values, @emph{environment} variables and @emph{default} values. The
754 existence of a fallback value, environment variable or default value
755 should be advertised in the application's help string (@pxref{Output}).
757 @itemize @bullet
758 @item
759 @cindex Fallback values
760 @cindex Values, fallback
761 @cindex Retrieval, from fallback value
762 @cindex Options, retrieval, from fallback value
763 Fallback values are used when an option exists on the @cmdline{} without
764 a corresponding argument (so this applies only to options taking
765 @emph{optional} arguments only).
766 @item
767 @cindex Environment variables
768 @cindex Retrieval, from environment
769 @cindex Options, retrieval, from environment
770 Applications may also associate an option with a specific environment
771 variable which contains a value for it.
772 @item
773 @cindex Default values
774 @cindex Values, default
775 @cindex Retrieval, from default value
776 @cindex Options, retrieval, from default value
777 Finally, default values are used when every other source has failed.
778 @end itemize
780 When @clon{} attempts to retrieve a value for a particular option, it
781 always does so in a specific order: first, the @cmdline{} is searched.
782 If an argument is present, it is used. Otherwise, a fallback or default
783 value is used in that order (note that when an option's argument is
784 optional, the option is required to provide at least a fallback or a
785 default value). Next, an environment variable is tried (when
786 appropriate). Finally, when everything else fails, the option's default
787 value is used (if any).
789 @cindex Retrieval, from command-line
790 @cindex Command-Line, retrieval
791 @cindex Options, retrieval, from command-line
792 @clon{} always scans the @cmdline{} from left to right, and stops at the
793 first match. Please note that the match in question may be a regular
794 option call or a pack, depending on what appears first on the
795 @cmdline{}. There is no concept of priority amongst option forms.
797 @cindex Options, multiple calls
798 Also, note that it is possible to provide several calls to the same
799 option on a single @cmdline{}. Some applications may take advantage of
800 this: every consecutive request for an option will use the next match on
801 the @cmdline{} until there is none left.
803 @cindex Flags
804 @cindex Options, types, flags
805 @cindex Environment variables
806 @cindex Retrieval, from environment
807 @cindex Options, retrieval, from environment
808 Finally, note that fallback or default values don't make any sense for
809 flags, but flags can still be associated with environment variables. In
810 such a case, the very @emph{existence} of the variable in the
811 environment, regardless of its value, stands for the presence of the
812 corresponding option on the @cmdline{}.
814 @node Error Management, , Value Sources, Option Retrieval
815 @subsection Error Management
816 @cindex Error Management
817 @cindex Retrieval, errors
818 @cindex Options, retrieval, errors
819 OK, now you're completely overwhelmed by the power and flexibility of
820 @clon{}, to the point that the fact that you didn't write it (because
821 @emph{I} did) even starts to upset you. So I know what you're thinking:
822 ``there's gotta be a way to break it''. I don't know, like, giving a
823 value to a flag, using an unknown option, providing an invalid value for
824 an option, using an equal sign in a negated call @etc{}
826 Unfortunately for you, @clon{} is like a pitbull. Whatever you do to
827 beat it, it @emph{will} fight back. The behavior of @clon{} with respect
828 to error management during option retrieval is well defined, but
829 contrary to the traditional approach, @emph{you}, the end-user have
830 control over it. Not the application. Error handling may occur when the
831 @cmdline{} is parsed, but also when environment variables are used.
833 @cindex @t{--clon-error-handler}
834 @cindex Built-in Options, @t{--clon-error-handler}
835 @cindex Options, built-in, @t{--clon-error-handler}
836 @cindex CLON_ERROR_HANDLER
837 @cindex Environment Variables, CLON_ERROR_HANDLER
838 The error management behavior of @clon{} is controlled by a built-in
839 option named @option{--clon-error-handler}, and its accompanying
840 environment variable @code{CLON_ERROR_HANDLER}. Possibles values for it
841 are currently the following.
843 @table @t
844 @item quit
845 @cindex Error Management, quitting
846 This is the default. It means that when @clon{} encounters an error
847 related to option retrieval, it prints an informative message about the
848 error and terminates the application immediately (with an exit status of
849 1). This is the behavior of most programs out there I guess.
850 @item none
851 @cindex Debugger
852 @cindex Error Management, interactive debugging
853 A value of @code{none} literally means no particular error handler.
854 Here, I must apologize because I need to go into some technical details
855 about @cl{}, the language in which applications using @clon{} are
856 written. @cl{} mandates the existence of a @dfn{debugger} in which you
857 are dropped in when an unhandled error condition is thrown. However some
858 @cl{} implementations may disable the debugger when creating standalone
859 programs. So the situation when the @clon{} error handler is set to
860 @code{none} depends on the application (application developers are
861 encouraged @emph{not} to disable the debugger).
862 @itemize @bullet
863 @item
864 If the debugger is disabled, you will get more or less the same error
865 message as if the value were @code{quit}, only with an additional and
866 cryptic stack trace that you may simply disregard.
867 @item
868 @cindex Debugger, restarts
869 If on the other hand, you end up in the debugger, you're in luck.
870 @clon{} provides a very comprehensive set of so-called @dfn{restarts}
871 that will allow you to interactively fix the problem and proceed, as if
872 nothing ever happened. Such restarts include notably the ability to
873 modify an option's name or value (handy in case of @cmdline{} typo),
874 discard the call altogether and many others, depending on the exact
875 error.
876 @end itemize
877 Note that the debugger will also provide you with a cryptic stack trace
878 and other information that you can probably just disregard. Don't be
879 afraid, simply answer the question you are asked for and follow the
880 instructions.
882 When the error implies a bad value for a particular option, you will
883 notice that some of the choices that @clon{} proposes in order to fix
884 the problem involve providing another @emph{value} or another
885 @emph{argument}. Again, you need to remember the terminology here
886 (@pxref{Valued Options}). The argument is what you provide on the
887 @cmdline{}, and the value is the conversion of the argument to the
888 proper type. This means that most of the time, you will want to use the
889 ``argument'' choice. If you know the @cl{} language, you can also
890 provide a value directly, in which case what you type in is in fact
891 @cl{} code.
892 @end table
894 One last note about the @option{--clon-error-handler} option: we have a
895 chicken-and-egg problem with it. The error handler must be known for
896 parsing the @cmdline{}, but in order to get it, we need to retrieve the
897 option which implies parsing the @cmdline{}@dots{} Whoops. Because of
898 this problem, the option is treated in a very special way.
900 @enumerate
901 @item
902 First of all, a built-in default value of @code{quit} is used initially.
903 @item
904 However, if the @code{CLON_ERROR_HANDLER} environment variable is set,
905 its value will be used immediately, even before trying to get the option
906 on the @cmdline{} (if an error happens when trying the environment
907 variable, the @code{quit} handler is used).
908 @item
909 Finally, if the option is found on the @cmdline{} during the parsing of
910 it, its value is updated immediately (so it also applies for parsing the
911 rest of the @cmdline{}).
912 @end enumerate
914 Now you need to get some rest.
918 @c ====================================================================
919 @c Output
920 @c ====================================================================
921 @node Output, Conclusion, The Command Line, Top
922 @chapter Output
924 In the previous chapter, we have seen how to make the best usage of a
925 clonified application's command-line. The second aspect we need to look
926 at is @clon{}'s output, typically what you get when you type
927 @command{program --help}. From an end-user perspective, one key feature
928 of @clon{} is that control on the formatting of the help strings is
929 given to @emph{you} instead of being the programmer's responsibility.
930 What this means is that @emph{you} get to choose the way you want help
931 strings to be formatted, and all of a sudden, every clonified
932 application you use will conform to your specifications.
934 @ref{Output Elements} surveys the different items composing a @clon{}
935 help string by looking at examples in a default setting. @ref{Theme
936 Mechanism} explains how to switch between predefined layouts.
937 @ref{Global Control} describe two built-in options that give you some
938 control over the layout on a global scale. Finally, @ref{Theme Creation}
939 describes how to build your own layouts.
941 @menu
942 * Output Elements::     What appears in help strings
943 * Theme Mechanism::     Switching between available layouts
944 * Global Control::      Line width and highlighting
945 * Theme Creation::      Building your own layouts
946 @end menu
948 @c ---------------
949 @c Output Elements
950 @c ---------------
951 @node Output Elements, Theme Mechanism, Output, Output
952 @section Output Elements
953 Let's look at the output of @command{program --help} in a default
954 setting first:
956 @cartouche
957 @verbatim
958 Usage: program [-hdF] [+d] [OPTIONS] FILES...
960 A clonified program.
962   -h, --help                  Print this help and exit.
963 Runtime options:
964   -(+)d, --debug[=yes/no]     Turn debugging on or off.
965                               Fallback: yes
966                               Environment: DEBUG
967                               Default: no
968   --simulate=yes/no           Simulate only. Nothing will happen for real,
969                               except for log messages.
970 User identification:
971   -f, --first-name=STR        Set the user's first name to STR.
972   -F, --family-name[=NAME]    Set the user's family name to NAME.
973                               Fallback: unknown
974 @end verbatim
975 @end cartouche
977 @cindex Synopsis
978 @cindex Output, synopsis
979 @cindex Postfix
980 @cindex Short packs
981 @cindex Packs, short
982 @cindex Negated packs
983 @cindex Negated Short Packs
984 @cindex Negated packs, short
985 @cindex Packs, negated
986 @cindex Packs, short, negated
987 The first line of output is what's called the @emph{synopsis}. This
988 synopsis indicates that the program accepts a number of options and also
989 a postfix consisting of file names. The set of available options is not
990 detailed in the synopsis but for convenience, @clon{} shows the
991 available short and negated packs explicitly.
993 @cindex Text
994 @cindex Arbitrary Text
995 @cindex Text, arbitrary
996 The next non-empty line is just text. A clonified application is free to
997 put arbitrary text anywhere in its help string. This can be used to
998 describe what the application is about for instance.
1000 @cindex Groups
1001 @cindex Arbitrary Text, in groups
1002 @cindex Text, in groups
1003 @cindex Options, in groups
1004 @cindex Groups, in groups
1005 @cindex Groups, titles
1006 Two other lines in the help string look like arbitrary text, but in fact
1007 are not: ``Runtime options:'' and ``User identification:''. These are
1008 not arbitrary text, but @emph{group titles}. A group is a way of putting
1009 help string items together, for instance because they are related to the
1010 same topic. A group has an optional title, and may contain options,
1011 arbitrary text or even sub-groups.
1013 @cindex Groups
1014 @cindex Groups, built-in
1015 @cindex @t{--clon-help}
1016 @cindex Built-in Options, @t{--clon-help}
1017 @cindex Options, built-in, @t{--clon-help}
1018 In addition to displaying the full help string, a clonified application
1019 may display a group's help string only (in such a case, you don't get to
1020 see the synopsis). This is what happens when you type @command{program
1021 --clon-help} for instance. @clon{}'s built-in options belong to a
1022 reserved built-in group.
1024 @cindex Flags
1025 @cindex Options, types, flags
1026 @cindex Valued Options
1027 @cindex Options, types, valued
1028 @cindex Switches
1029 @cindex Options, types, switches
1030 @cindex Long Form
1031 @cindex Short Form
1032 @cindex Command-Line, options, long form
1033 @cindex Command-Line, options, short form
1034 @cindex Negated Form
1035 @cindex Negated Short Form
1036 @cindex Short Form, negated
1037 @cindex Options, command-line, negated form
1038 @cindex Options, command-line, negated short form
1039 @cindex Options, command-line, short form, negated
1040 @cindex Command-Line, options, negated form
1041 @cindex Command-Line, options, negated short form
1042 @cindex Command-Line, options, short form, negated
1043 Let's have a look at the options now. In the first column, you can see
1044 that depending on the option, the long, short and negated forms are
1045 advertised. Valued options also advertise their argument, enclosed in
1046 square brackets when it is optional. In this example, @samp{-h} is a
1047 flag, @samp{-d} and @samp{--simulate} are switches with different
1048 settings, while @samp{-f} and @samp{-F} are standard valued options.
1050 @cindex Options, description
1051 The second column of the help string provides each option's
1052 @emph{description}. Descriptions can span across several lines, as in
1053 the case of @samp{--simulate}. @clon{} takes care of properly aligning
1054 all the material that needs to be displayed.
1056 @cindex Fallback values
1057 @cindex Values, fallback
1058 @cindex Environment Variables
1059 @cindex Default values
1060 @cindex Values, default
1061 Finally, you can see that potential fallback values, environment
1062 variables and default values are also advertised in that order, when
1063 appropriate.
1067 @c ---------------
1068 @c Theme Mechanism
1069 @c ---------------
1070 @node Theme Mechanism, Global Control, Output Elements, Output
1071 @section Theme Mechanism
1072 @cindex Theme Mechanism
1074 @cindex Themes
1075 @cindex Themes, built-in
1076 @cindex Themes, built-in, @t{raw}
1077 @cindex Built-in themes
1078 @cindex Built-in themes, @t{raw}
1079 The output of @command{program --help} that we have seen in the previous
1080 section corresponds to a default setting, but is really just one
1081 possibility. As the user of a clonified application, you have the
1082 ability to customize the appearance of @clon{}'s output. The way things
1083 look is specified by so-called @emph{themes}. @clon{} has a theme named
1084 @t{raw} which every clonified application has built-in.
1086 @cindex Themes, files
1087 @cindex Themes, files, @t{cth} extension
1088 @cindex @t{cth} extension
1089 @cindex File Extension
1090 @cindex File Extension, @t{cth}
1091 Other themes are stored in files the standard extension of which is
1092 @samp{cth} (as in @b{C}lon @b{TH}eme). In fact, theme files can be named
1093 as you like; this is just a convention.
1095 @menu
1096 * Standard Themes::     Some example themes are provided
1097 * Search Path::         Where to find theme files
1098 * Theme Selection::     How to select a theme
1099 @end menu
1101 @node Standard Themes, Search Path, Theme Mechanism, Theme Mechanism
1102 @subsection Standard Themes
1103 @cindex Themes, files, standard
1104 @cindex Standard Themes
1105 @cindex Standard Themes, files
1106 @clon{} comes with several standard themes in files that can be used
1107 as-is or serve as the basis for creating new ones (@pxref{Theme
1108 Creation}). The list is given below.
1110 @table @t
1111 @item raw
1112 @cindex Standard Themes, files, @file{raw.cth}
1113 @cindex Themes, files, standard, @file{raw.cth}
1114 Exactly the same as the built-in one, only copied into a theme file.
1115 @item optlist
1116 @cindex Standard Themes, files, @file{optlist.cth}
1117 @cindex Themes, files, standard, @file{optlist.cth}
1118 Displays only a list of available options, one per line, without any
1119 description, group indication or arbitrary text. This can be used to
1120 quickly remember the name or the syntax of an option.
1121 @item refcard
1122 @cindex Standard Themes, files, @file{refcard.cth}
1123 @cindex Themes, files, standard, @file{refcard.cth}
1124 Displays a very compact help string. The synopsis is there, so are the
1125 group titles and arbitrary texts, but the options are displayed without
1126 any description, and the lines are filled as much as possible. The
1127 intent of this theme is to produce some sort of ``reference card'' that
1128 could be printed.
1129 @item roomy
1130 @cindex Standard Themes, files, @file{roomy.cth}
1131 @cindex Themes, files, standard, @file{roomy.cth}
1132 Displays a full help string occupying more space than the @t{raw} theme.
1133 Option descriptions don't start @emph{after} the option's name, but
1134 @emph{under} it. As a result, they occupy more horizontal space. Also,
1135 sub-groups are indented to the right.
1136 @item dvl
1137 @cindex Standard Themes, files, @file{dvl.cth}
1138 @cindex Themes, files, standard, @file{dvl.cth}
1139 This is my personal theme that I personally use myself in person.
1140 @item christmas
1141 @cindex Standard Themes, files, @file{christmas.cth}
1142 @cindex Themes, files, standard, @file{christmas.cth}
1143 This one is full of bells and whistles, which makes it essentially
1144 unusable. It exists only to provide a concrete example of all the
1145 available formatting and highlighting features of @clon{}. The
1146 @t{christmas} theme is only available once a year, at exactly 23:59:59
1147 on December the 24th.
1148 @end table
1150 @node Search Path, Theme Selection, Standard Themes, Theme Mechanism
1151 @subsection Search Path
1152 @cindex Search Path
1153 @cindex Search Path, themes
1154 @cindex Themes, search path
1155 @clon{} maintains a search path for looking up files. Theme files are
1156 supposed to be located in a @file{themes} directory of every
1157 directory in the search path. By default, the search path is as follows:
1158 @itemize @w{}
1159 @item
1160 @t{~/.clon/}
1161 @item
1162 @t{~/Library/Application Support/Clon/} (MacOS only)
1163 @item
1164 @t{~/share/clon/}
1165 @item
1166 @t{/Library/Application Support/Clon/} (MacOS only)
1167 @item
1168 @t{/usr/local/share/clon/}
1169 @item
1170 @t{/usr/share/clon/}
1171 @end itemize
1173 @cindex @t{--clon-search-path}
1174 @cindex Built-in Options, @t{--clon-search-path}
1175 @cindex Options, built-in, @t{--clon-search-path}
1176 @cindex CLON_SEARCH_PATH
1177 @cindex Environment Variables, CLON_SEARCH_PATH
1178 The search path can be modified with the @option{--clon-search-path}
1179 built-in option or its accompanying @env{CLON_SEARCH_PATH} environment
1180 variable. It takes a list of colon-separated directories as argument.
1181 This argument is in fact optional. Not providing an argument is
1182 equivalent to providing an empty one, which basically reduces the search
1183 path to the application's current directory.
1186 @node Theme Selection, , Search Path, Theme Mechanism
1187 @subsection Theme Selection
1188 @cindex @t{--clon-theme}
1189 @cindex Built-in Options, @t{--clon-theme}
1190 @cindex Options, built-in, @t{--clon-theme}
1191 @cindex CLON_THEME
1192 @cindex Environment Variables, CLON_THEME
1193 In order to select a theme, you can use the built-in option
1194 @option{--clon-theme} or its accompanying environment variable
1195 @env{CLON_THEME}. Just provide it with the theme name, and the
1196 corresponding theme file will be looked up in the search path
1197 (@pxref{Search Path}), stopping at the first match.
1199 @cindex File Extension, @t{cth}
1200 @cindex @t{cth} extension
1201 @cindex Themes, files, @t{cth} extension
1202 You can omit the @samp{cth} extension: @clon{} looks for a file named
1203 exactly as you said first and attempts to add the theme extension next.
1204 Note that searching with or without extension has priority over the
1205 search path. For instance, suppose that the following files exist:
1206 @itemize @w{}
1207 @item
1208 @t{/usr/local/share/clon/themes/foobar}
1209 @item
1210 @t{/usr/share/clon/themes/foobar.cth}
1211 @end itemize
1212 Using @samp{--clon-theme=foobar} will match the first one while
1213 @samp{--clon-theme=foobar.cth} will match the second.
1215 Now suppose that the following files exist:
1216 @itemize @w{}
1217 @item
1218 @t{/usr/local/share/clon/themes/foobar.cth}
1219 @item
1220 @t{/usr/share/clon/themes/foobar}
1221 @end itemize
1222 Using either @samp{--clon-theme=foobar} or
1223 @samp{--clon-theme=foobar.cth} will always match the first file. Which
1224 brings us to the next point (how clever).
1226 It is possible to bypass the search path when looking for a theme: just
1227 provide @option{--clon-theme} with a theme name starting with a path
1228 component (@ie{} @samp{/}, @samp{./} or @samp{../}). Even in that case,
1229 you can still omit the @samp{cth} extension.
1231 @cindex Built-in themes, @t{raw}
1232 @cindex Themes, built-in, @t{raw}
1233 @cindex Standard Themes, files, @file{raw.cth}
1234 @cindex Themes, files, standard, @file{raw.cth}
1235 Finally, here is an important precision about @option{--clon-theme}.
1236 This option has a fallback of @t{nil} and a default of @t{raw}. This
1237 means that if you don't use the option at all, a theme named @t{raw}
1238 will be looked up in the search path. This theme exists in the standard
1239 distribution and you are free to modify it. On the other hand, since
1240 this option has a fallback, it means that its argument is optional. If
1241 you don't provide any argument (that is, if you just use
1242 @samp{--clon-theme}), then the @emph{built-in} raw theme will be used.
1243 This theme is originally identical to the one provided in the file
1244 @file{raw.cth} but since it is built in every clonified application, you
1245 cannot change it.
1248 @c --------------
1249 @c Global Control
1250 @c --------------
1251 @node Global Control, Theme Creation, Theme Mechanism, Output
1252 @section Global Control
1254 In addition to selecting the appropriate theme, @clon{} provides two
1255 built-in options that give you additional control on the output. These
1256 options are orthogonal to themes: all themes implicitly honor them.
1257 Since their description is pretty self-explanatory, they are given
1258 below.
1260 The first one allows you to control the output's line width. Normally,
1261 @clon{} detects it for you, but it may not be possible in some
1262 situations.
1264 @cindex @t{--clon-line-width}
1265 @cindex Built-in Options, @t{--clon-line-width}
1266 @cindex Options, built-in, @t{--clon-line-width}
1267 @cindex CLON_LINE_WIDTH
1268 @cindex Environment Variables, CLON_LINE_WIDTH
1269 @cindex COLUMNS
1270 @cindex Environment Variables, COLUMNS
1271 @verbatim
1272   --clon-line-width=WIDTH     Set Clon's output line width.
1273                               If not given, the value of the COLUMNS
1274                               environment variable, the terminal size,
1275                               or a default of 80 columns will be used.
1276                               Environment: CLON_LINE_WIDTH
1277 @end verbatim
1279 The second one deals with @emph{highlighting} (@pxref{Highlight}).
1280 @clon{} has the ability to highlight the output through ISO/IEC 6429 SGR
1281 escape sequences. The built-in raw theme doesn't do highlighting but
1282 other do. Normally, @clon{} detects when highlighting is appropriate
1283 automatically, but you might want more control on that.
1284 @cindex @t{--clon-highlight}
1285 @cindex Built-in Options, @t{--clon-highlight}
1286 @cindex Options, built-in, @t{--clon-highlight}
1287 @cindex CLON_HIGHLIGHT
1288 @cindex Environment Variables, CLON_HIGHLIGHT
1290 @verbatim
1291   --clon-highlight[=ARG]      Set Clon's output highlighting to on/off/auto.
1292                               Auto (the default) means on for tty output and
1293                               off otherwise.
1294                               Fallback: yes
1295                               Default: auto
1296                               Environment: CLON_HIGHLIGHT
1297 @end verbatim
1300 @c ---------------
1301 @c Theme Creation
1302 @c ---------------
1303 @node Theme Creation, , Global Control, Output
1304 @section Theme Creation
1305 Perhaps the most exciting thing in Computer Science is to spend more
1306 time hacking a tool than actually using it. After reading this section,
1307 you will find yourselves spending days customizing theme files instead
1308 of using clonified applications.
1310 @menu
1311 * Theme Elements::      Faces, properties, comments
1312 * Faces::               Boy, you look just like your mother
1313 * Highlight::           Text Appearance
1314 * Layout::              Text geometry
1315 * Implicit Faces::      Missing definitions and siblings
1316 @end menu
1318 @node Theme Elements, Faces, Theme Creation, Theme Creation
1319 @subsection Theme Elements
1320 @cindex Faces
1321 @cindex Face Properties
1322 @cindex Themes, faces
1323 @cindex Themes, faces, properties
1324 Hear hear! If you understand what @command{M-x all-hail-[x]emacs} means,
1325 you're going to get quite comfy here. @clon{} themes are articulated
1326 around two basic concepts: @emph{faces} and (face) @emph{properties}. A
1327 property describes some visual attribute for some piece of text, for
1328 instance bold, red, indented by 2 columns to the right. A face is more
1329 or less a set of properties (but there's more to it than that; please
1330 hold your post). Every piece of text in @clon{}'s output is associated
1331 with a face, which in turn defines specific values for specific
1332 properties.
1334 @cindex Layout Properties
1335 @cindex Faces, properties, layout
1336 @cindex Themes, faces, properties, layout
1337 @cindex Highlight Properties
1338 @cindex Faces, properties, highlight
1339 @cindex Themes, faces, properties, highlight
1340 There are two property types in @clon{}: @emph{highlight properties},
1341 which describe the visual appearance of characters (color, font @etc{}),
1342 and @emph{layout properties}, which describe the text geometry (line
1343 width, indentation @etc{}). Please see @ref{Highlight Properties} and
1344 @ref{Layout Properties} for an exhaustive list of them.
1346 Let's have a look at a very simple theme file now.
1348 @cartouche
1349 @verbatim
1350 ;; A very simple theme file.
1352 :background black
1353 ;; ...
1355 :face (synopsis :foreground red
1356                 ;; ...
1357                 :face (header :bold t #| ...|#)
1358                 #| ... |#)
1359 ;; ...
1360 @end verbatim
1361 @end cartouche
1363 @cindex Themes, files, comments
1364 The first line is a comment. Comments begin with a semi-colon and extend
1365 to the end of the line. There is another syntax for comments, as show
1366 later in the file: a comment can be opened with @samp{#|} and closed
1367 with @samp{|#}. This form allows you to create comments that span across
1368 several lines, or just part of a single line.@footnote{By now, you have
1369 realized that a theme file is just a piece of @cl{} code@dots{} No,
1370 wait! Don't go!}
1372 @cindex Face Properties
1373 @cindex Themes, faces, properties
1374 @cindex Themes, files, keywords
1375 @cindex Themes, files, keywords, @t{:background}
1376 @cindex Faces, @t{toplevel}
1377 @cindex Themes, faces, @t{toplevel}
1378 The next line sets the @samp{background} property to @samp{black}. It
1379 means that @clon{}'s output will be displayed over a black background
1380 (no kidding). Every property in @clon{} has a name, which you specify by
1381 using a @emph{keyword} (@ie{} the name prepended with a colon). But
1382 wait, properties are supposed to belong to faces, right? So what is that
1383 property doing, floating around like that in the file? That's right,
1384 clever. In fact, the whole output of @clon{} is wrapped in a global face
1385 called @samp{toplevel}. You will never need to mention this face
1386 explicitly, though, because the contents of theme files is always
1387 enclosed in that face.
1389 @cindex Themes, files, keywords
1390 @cindex Themes, files, keywords, @t{:face}
1391 @cindex Themes, files, keywords, @t{:foreground}
1392 @cindex Themes, files, keywords, @t{:bold}
1393 @cindex Faces, @t{synopsis}
1394 @cindex Themes, faces, @t{synopsis}
1395 @cindex Faces, @t{header}
1396 @cindex Themes, faces, @t{header}
1397 Later in the file, you find yourself contemplating a face specification.
1398 Faces are specified by using the keyword @samp{:face}. What follows is a
1399 list beginning with the face name, and continuing with property
1400 specifications. In this particular example, we're specifying that the
1401 synopsis line (the one that says ``Usage: blah blah'') should appear in
1402 red, although as you can see, the story does not stop there.
1404 @cindex Faces, nesting
1405 @cindex Themes, faces, nesting
1406 @cindex Face properties, inheritance
1407 Indeed, there is also a @samp{header} face specification @emph{within}
1408 the @samp{synopsis} one. What it says it that the header part (the
1409 ``Usage:'' portion of the synopsis line) should additionally be
1410 displayed in bold font. So it turns out that face specifications can be
1411 nested. In fact, @emph{all} the faces you specify are sub-faces of the
1412 @samp{toplevel} face at some level. In this example, the @samp{header}
1413 face is a sub-face of the @samp{synopsis} one. This is important for two
1414 reasons:
1415 @enumerate
1416 @item
1417 face nesting leads to the notion of property inheritance
1418 (@pxref{Highlight Inheritance}),
1419 @item
1420 @clon{} makes use of faces with the same name in different (nesting)
1421 contexts. For instance, there are many places where the @samp{header}
1422 face is used (@pxref{Faces}), but this face can have very different
1423 specifications according to where it appears in a face tree.
1424 @end enumerate
1426 @node Faces, Highlight, Theme Elements, Theme Creation
1427 @subsection Faces
1428 @cindex Faces
1429 @cindex Themes, faces
1431 @cindex Built-in themes, @t{raw}
1432 @cindex Themes, built-in, @t{raw}
1433 @cindex Standard Themes, files, @file{raw.cth}
1434 @cindex Themes, files, standard, @file{raw.cth}
1435 @cindex Faces, @t{synopsis}
1436 @cindex Faces, @t{header}
1437 @cindex Faces, @t{program}
1438 @cindex Faces, @t{short-pack}
1439 @cindex Faces, @t{negated-pack}
1440 @cindex Faces, @t{options}
1441 @cindex Faces, @t{postfix}
1442 @cindex Faces, @t{text}
1443 @cindex Faces, @t{option}
1444 @cindex Faces, @t{syntax}
1445 @cindex Faces, @t{short}
1446 @cindex Faces, @t{name}
1447 @cindex Faces, @t{argument}
1448 @cindex Faces, @t{long}
1449 @cindex Faces, @t{usage}
1450 @cindex Faces, @t{description}
1451 @cindex Faces, @t{fallback}
1452 @cindex Faces, @t{value}
1453 @cindex Faces, @t{default}
1454 @cindex Faces, @t{environment}
1455 @cindex Faces, @t{variable}
1456 @cindex Themes, faces, @t{synopsis}
1457 @cindex Themes, faces, @t{header}
1458 @cindex Themes, faces, @t{program}
1459 @cindex Themes, faces, @t{short-pack}
1460 @cindex Themes, faces, @t{negated-pack}
1461 @cindex Themes, faces, @t{options}
1462 @cindex Themes, faces, @t{postfix}
1463 @cindex Themes, faces, @t{text}
1464 @cindex Themes, faces, @t{option}
1465 @cindex Themes, faces, @t{syntax}
1466 @cindex Themes, faces, @t{short}
1467 @cindex Themes, faces, @t{name}
1468 @cindex Themes, faces, @t{argument}
1469 @cindex Themes, faces, @t{long}
1470 @cindex Themes, faces, @t{usage}
1471 @cindex Themes, faces, @t{description}
1472 @cindex Themes, faces, @t{fallback}
1473 @cindex Themes, faces, @t{value}
1474 @cindex Themes, faces, @t{default}
1475 @cindex Themes, faces, @t{environment}
1476 @cindex Themes, faces, @t{variable}
1477 The following figure shows the full face tree defined by @clon{}. In
1478 fact, it is extracted from the theme file @file{raw.cth} (property
1479 specifications have been removed). By the way, that is why it is a good
1480 idea to start from this one when you want to create a new theme: all the
1481 faces are in there. It should be pretty easy to figure out what portion
1482 of text each face applies to.
1484 @cartouche
1485 @verbatim
1486 ;; Remember that everything in here belongs to the toplevel face.
1487 :face (synopsis :face header
1488                 :face program
1489                 :face short-pack
1490                 :face negated-pack
1491                 :face options
1492                 :face postfix)
1493 :face text
1494 :face (option :face (syntax :face (short :face name
1495                                          :face argument)
1496                             :face (long  :face name
1497                                          :face argument))
1498               :face (usage :face description
1499                            :face (fallback :face header
1500                                            :face value)
1501                            :face (default :face header
1502                                           :face value)
1503                            :face (environment :face header
1504                                               :face variable)))
1505 :face (group :face header
1506              :face (items #| :face text :face option :face group |#))
1507 @end verbatim
1508 @end cartouche
1510 As mentioned earlier, you can see that faces of the same name may appear
1511 at different places in the tree (@eg{} the @samp{header} one) and hence
1512 may have different specifications, depending on the context (their
1513 branch in the tree).
1515 Pushing this idea one step further, note the peculiarity of the
1516 @samp{group} face: since group items may be arbitrary text, options or
1517 even sub-groups, you can specify as many levels of group nesting as you
1518 want. In fact, you can spend your whole life specifying sub-groups,
1519 although it is very unlikely that a clonified application provides more
1520 than two or three levels of group imbrication.
1522 One last point to note: you might be surprised to find @emph{empty} face
1523 specifications like this one: @samp{:face description}. This @emph{is} a
1524 valid specification, and this @emph{is} different from not mentioning
1525 the face at all, or specifying some properties explicitly. See
1526 @ref{Layout Inheritance} for an explanation.
1529 @node Highlight, Layout, Faces, Theme Creation
1530 @subsection Highlight
1531 The first category of properties that we are going to describe deals
1532 with @emph{highlighting}, that is, modifying the visual aspect of
1533 characters in the output.
1535 @menu
1536 * Highlight Properties::        What is available
1537 * Highlight Inheritance::       What happens in a face tree
1538 @end menu
1540 @node Highlight Properties, Highlight Inheritance, Highlight, Highlight
1541 @subsubsection Highlight Properties
1542 @cindex Highlight Properties
1543 @cindex Faces, properties, highlight
1544 @cindex Themes, faces, properties, highlight
1545 @clon{} supports 10 highlight properties defined by the ISO/IEC 6429 SGR
1546 standard (under the assumption that your favorite terminal program
1547 supports them). Their description is given below.
1549 @table @t
1550 @item :foreground
1551 @cindex Face Properties, highlight, @t{foreground}
1552 @cindex Themes, faces, properties, highlight, @t{foreground}
1553 @cindex Themes, files, keywords, @t{:foreground}
1554 @item :background
1555 @cindex Face Properties, highlight, @t{background}
1556 @cindex Themes, faces, properties, highlight, @t{background}
1557 @cindex Themes, files, keywords, @t{:background}
1558 The face's foreground and background colors. Possible values are
1559 @t{black}, @t{red}, @t{green}, @t{yellow}, @t{blue}, @t{magenta},
1560 @t{cyan} and @t{white}. It is also possible to use the special values
1561 @t{nil} or @t{reset} to reset the color to the terminal's default value.
1562 @item :intensity
1563 @cindex Face Properties, highlight, @t{intensity}
1564 @cindex Themes, faces, properties, highlight, @t{intensity}
1565 @cindex Themes, files, keywords, @t{:intensity}
1566 The face's intensity. Possible values are @t{bold}, @t{normal} (or
1567 @t{nil}) and @t{faint}. Please note that @t{faint} is usually not very
1568 well supported.
1569 @cindex Face Properties, highlight, @t{bold}
1570 @cindex Themes, faces, properties, highlight, @t{bold}
1571 @cindex Themes, files, keywords, @t{:bold}
1572 For convenience, a @t{:bold} Boolean property is also provided which
1573 will set the face's intensity to @t{bold} if true (@t{t}) and @t{normal}
1574 if false (@t{nil}).
1575 @item :italic
1576 @cindex Face Properties, highlight, @t{italic}
1577 @cindex Themes, faces, properties, highlight, @t{italic}
1578 @cindex Themes, files, keywords, @t{:italic}
1579 Whether to display the face's contents in italics. This is a Boolean
1580 property. Possible values are @t{t} or @t{nil}. The effect of this
1581 property depends a lot on the font you use in your terminal application.
1582 @item :underline
1583 @cindex Face Properties, highlight, @t{underline}
1584 @cindex Themes, faces, properties, highlight, @t{underline}
1585 @cindex Themes, files, keywords, @t{:underline}
1586 Whether to underline the face's contents. Possible values are @t{single}
1587 (or @t{on} or @t{t}), @t{double} and @t{none} (or @t{off} or @t{nil}).
1588 Please note that @t{double} is usually not very well supported.
1589 @item :blink
1590 @cindex Face Properties, highlight, @t{blink}
1591 @cindex Themes, faces, properties, highlight, @t{blink}
1592 @cindex Themes, files, keywords, @t{:blink}
1593 The face's blink speed. Possible values are @t{slow} (or @t{on} or
1594 @t{t}), @t{rapid} and @t{off} (or @t{nil}). Please note that @t{rapid}
1595 is usually not very well supported.
1596 @item :inverse
1597 @cindex Face Properties, highlight, @t{inverse}
1598 @cindex Themes, faces, properties, highlight, @t{inverse}
1599 @cindex Themes, files, keywords, @t{:inverse}
1600 Whether to display the face's contents in inverse video. This is a
1601 Boolean property. Possible values are @t{t} or @t{nil}.
1602 @item :crossed-out
1603 @cindex Face Properties, highlight, @t{crossed-out}
1604 @cindex Themes, faces, properties, highlight, @t{crossed-out}
1605 @cindex Themes, files, keywords, @t{:crossed-out}
1606 Whether to display the face's contents crossed out. This is a Boolean
1607 property. Possible values are @t{t} or @t{nil}.
1608 @item :framed
1609 @cindex Face Properties, highlight, @t{framed}
1610 @cindex Themes, faces, properties, highlight, @t{framed}
1611 @cindex Themes, files, keywords, @t{:framed}
1612 Whether to display the face's contents framed or encircled. This is a
1613 Boolean property. Possible values are @t{t} or @t{nil}.
1614 @item :concealed
1615 @cindex Face Properties, highlight, @t{concealed}
1616 @cindex Themes, faces, properties, highlight, @t{concealed}
1617 @cindex Themes, files, keywords, @t{:concealed}
1618 Whether to conceal the face's contents. This is a Boolean property.
1619 Possible values are @t{t} or @t{nil}. In case it is not obvious,
1620 concealing means that the face's contents is not displayed, but still
1621 occupies its normal space, so this is different from hiding it
1622 (@pxref{Layout Properties}).
1623 @cindex Face Properties, highlight, @t{revealed}
1624 @cindex Themes, faces, properties, highlight, @t{revealed}
1625 @cindex Themes, files, keywords, @t{:revealed}
1626 Alternately, you can also use the opposite Boolean property named
1627 @t{:revealed}.
1628 @end table
1630 @node Highlight Inheritance, , Highlight Properties, Highlight
1631 @subsubsection Highlight Inheritance
1632 @cindex Face Properties, inheritance
1633 @cindex Face Properties, highlight, inheritance
1634 @cindex Themes, faces, properties, inheritance
1635 @cindex Themes, faces, properties, highlight, inheritance
1636 @cindex Themes, built-in, @t{raw}
1637 @cindex Built-in themes, @t{raw}
1638 By default (this is also the case in the @samp{raw} theme), all
1639 highlight properties are turned off: text is output in whatever way is
1640 standard on the current terminal.
1642 When you set a face's highlight property however, it is inherited by all
1643 the sub-faces. This is in fact the most natural behavior. For instance,
1644 if you set the foreground of the @samp{synopsis} face to red, you
1645 probably expect the whole synopsis line to be output in red, including
1646 the header, program @etc{} parts. If not, you need to explicitly
1647 neutralize the unwanted effect, for instance by saying something like
1648 this:
1650 @verbatim
1651 :face (synopsis :foreground red
1652                 :face (program :foreground reset)
1653                 :face (postfix :foreground cyan))
1654 @end verbatim
1656 In other words, you can consider that the way some piece of text is
1657 output is not specified exactly by its associated face, but rather by
1658 the merging of all active properties from the whole corresponding face
1659 tree. This is exactly how Emacs faces work by the way.
1661 @node Layout, Implicit Faces, Highlight, Theme Creation
1662 @subsection Layout
1663 The second category of properties that we are going to describe deals
1664 with @emph{layout}, that is, modifying the placement of text in the
1665 output.
1667 @menu
1668 * Layout Properties::   What is available
1669 * Layout Inheritance::  What happens in a face tree
1670 @end menu
1672 @node Layout Properties, Layout Inheritance, Layout, Layout
1673 @subsubsection Layout Properties
1674 @cindex Layout Properties
1675 @cindex Faces, properties, layout
1676 @cindex Themes, faces, properties, layout
1677 In addition to the 10 highlight properties described in the previous
1678 section, @clon{} defines 6 layout properties. Here are the first 4 of
1679 them, along with their description and default value.
1681 @table @t
1682 @item :visible
1683 @cindex Face Properties, layout, @t{visible}
1684 @cindex Themes, faces, properties, layout, @t{visible}
1685 @cindex Themes, files, keywords, @t{:visible}
1686 @cindex Face Properties, layout, @t{hidden}
1687 @cindex Themes, faces, properties, layout, @t{hidden}
1688 @cindex Themes, files, keywords, @t{:hidden}
1689 @cindex Standard Themes, files, @file{optlist.cth}
1690 @cindex Themes, files, standard, @file{optlist.cth}
1691 @cindex Standard Themes, files, @file{refcard.cth}
1692 @cindex Themes, files, standard, @file{refcard.cth}
1693 Whether the face's contents is visible. Possible values are @t{t} (the
1694 default), or @t{nil}. You can also use the opposite property named
1695 @t{:hidden}. The @samp{optlist} and @samp{refcard} themes make use of
1696 this to avoid printing the options descriptions.
1697 @cindex Face Properties, highlight, @t{display}
1698 @cindex Themes, faces, properties, highlight, @t{display}
1699 @cindex Themes, files, keywords, @t{:display}
1700 Since the notions of hiding, concealing or making text visible are
1701 somewhat intermixed, @clon{} also provides a ``bastard'' property which,
1702 depending on its value, would be considered either a layout, or a
1703 highlight one. This property is named @t{:display}. Possible values are:
1704 @t{visible} (or @t{revealed} or @t{t}), @t{concealed} and @t{hidden} (or
1705 @t{nil}).
1706 @item :padding-top
1707 @cindex Face Properties, layout, @t{padding-top}
1708 @cindex Themes, faces, properties, layout, @t{padding-top}
1709 @cindex Themes, files, keywords, @t{:padding-top}
1710 The face's top padding, that is, the number of lines to skip before
1711 opening it and displaying its contents. This property can take the
1712 following forms.
1713 @table @t
1714 @item nil
1715 This face may be opened anywhere, including on the current line. This is
1716 the default.
1717 @item 0
1718 This face should be opened on the next line.
1719 @item <num> @r{(positive)}
1720 This face should be opened after skipping @t{<num>} empty lines. Note
1721 that the empty lines are displayed in the enclosing face, @emph{not} the
1722 face which specifies the top padding.
1723 @end table
1724 @item :padding-bottom
1725 @cindex Face Properties, layout, @t{padding-bottom}
1726 @cindex Themes, faces, properties, layout, @t{padding-bottom}
1727 @cindex Themes, files, keywords, @t{:padding-bottom}
1728 This face's bottom padding, that is, the number of lines to skip before
1729 opening the next face and displaying its contents. This property can
1730 take the following forms.
1731 @table @t
1732 @item nil
1733 The next face may be opened anywhere, including on the current line.
1734 This is the default.
1735 @item 0
1736 The next face should be opened on the next line.
1737 @item <num> @r{(positive)}
1738 The next face should be opened after skipping @t{<num>} lines. Note that
1739 the empty lines are displayed in the enclosing face, @emph{not} the face
1740 which specifies the bottom padding.
1741 @end table
1742 @item :item-separator
1743 @cindex Face Properties, layout, @t{item-separator}
1744 @cindex Themes, faces, properties, layout, @t{item-separator}
1745 @cindex Themes, files, keywords, @t{:item-separator}
1746 The face's item separator, that is, a piece of text to insert between
1747 every sub-face's contents. The default value is @t{#\space} (a space
1748 character).
1749 @end table
1750 @cindex Themes, built-in, @t{raw}
1751 @cindex Built-in Themes, @t{raw}
1752 The default values above have been chosen because they are convenient
1753 for the majority of the faces, but not necessarily all the time. Let us
1754 now review some examples of non-default settings in the @samp{raw}
1755 theme.
1756 @itemize @bullet
1757 @item
1758 The @samp{synopsis} face has its bottom padding set to 1, which means to
1759 leave an empty line below it. Note that this line does not belong to the
1760 synopsis. It is output in the @samp{toplevel} face.
1761 @item
1762 The @samp{text}, @samp{option} and @samp{group} faces have both their
1763 top and bottom paddings set to 0. This means that all these items should
1764 start and end on lines of their own.
1765 @item
1766 Finally, the @samp{syntax} face has its item separator set to
1767 @w{@t{", "}}, which in this context is used to separate the short and
1768 long name syntax, as in @w{@samp{-h, --help}}.
1769 @end itemize
1771 @cindex Frames
1772 @cindex Layout, frames
1773 In order to describe the last two layout properties, we need to
1774 introduce the notion of @emph{frame} first. A frame is a rectangle in
1775 which @clon{} prints something. When @clon{} opens a face for printing
1776 its contents, it associates a frame with it. Usually, @clon{} doesn't
1777 know the frame's height because it doesn't know in advance how many
1778 lines of output will be necessary to display the face's contents.
1779 However, @clon{} usually knows the frame's width: a frame starts at a
1780 certain column (the left one) and stops at another (the right one).
1782 There is an isomorphic relation between frames and faces: when a face is
1783 a sub-face of a super-face, the corresponding frame is a sub-frame of
1784 the corresponding super-frame. Sub-frames are geometrically enclosed
1785 within their super-frames: a sub-frame can only draw in an equally large
1786 or narrower band than its super-frame. That's how @clon{} handles
1787 vertical alignment of text.
1789 In order to give you control on the starting and ending columns of every
1790 frame (in fact, every face), the following two layout properties are
1791 defined.
1793 @table @t
1794 @item :padding-left
1795 @cindex Face Properties, layout, @t{padding-left}
1796 @cindex Themes, faces, properties, layout, @t{padding-left}
1797 @cindex Themes, files, keywords, @t{:padding-left}
1798 A face's left padding determines its starting column. This property can
1799 take the following forms.
1800 @table @t
1801 @item <num>
1802 Skip @t{<num>} columns relatively to the enclosing face. The default
1803 value is 0, meaning to open this face at the same column number as the
1804 enclosing one.
1805 @item (<num> :relative-to <face>)
1806 As above, but relatively to a @emph{parent} face named @t{<face>}
1807 instead of just the enclosing one. This lets you go more than one level
1808 up in the face tree.
1809 @item (<num> absolute)
1810 Open this face exactly at column @t{<num>}.
1811 @item self
1812 This face may be opened anywhere, and when it is, its left column is set
1813 to the current column number.
1814 @end table
1815 @item :padding-right
1816 @cindex Face Properties, layout, @t{padding-right}
1817 @cindex Themes, faces, properties, layout, @t{padding-right}
1818 @cindex Themes, files, keywords, @t{:padding-right}
1819 A face's right padding, determines its ending column. This property can
1820 take the following forms.
1821 @table @t
1822 @item <num>
1823 Close this face @t{<num>} columns before the enclosing one.
1824 @item (<num> :relative-to <face>)
1825 As above, but relatively to a @emph{parent} face named @t{<face>}
1826 instead of just the enclosing one. This lets you go more than one level
1827 up in the face tree.
1828 @item (<num> absolute)
1829 Close this face exactly at column @t{<num>}.
1830 @item self
1831 This face may be closed anywhere. This is the default.
1832 @end table
1833 @end table
1834 @cindex Themes, built-in, @t{raw}
1835 @cindex Built-in Themes, @t{raw}
1836 The default values above have been chosen because they are convenient
1837 for the majority of the faces, but not necessarily all the time. Let us
1838 now review some examples of non-default settings in the @samp{raw}
1839 theme.
1840 @itemize @bullet
1841 @item
1842 The @samp{option} face has its left padding set to 2. Since all
1843 super-faces default to 0, this essentially mean an indentation of 2
1844 columns.
1845 @item
1846 The @samp{usage} face has its left padding set to @t{(30 absolute)}
1847 which means that the descriptive texts for all options start aligned at
1848 column 30.
1849 @end itemize
1851 @cindex Faces, self-ending
1852 There is one important point to understand about self-ending faces
1853 (which, again, is the default setting). A self-ending face typically
1854 doesn't know at which column it stops until it stops. In fact, this is
1855 not completely true: if the face's contents needs to span across several
1856 lines, then the ending column will be known at the end of the first
1857 line, when the ending column of the enclosing face is reached. However,
1858 for a piece of contents that fits on a single line, the point holds.
1860 Because of that, it is impossible for a face's right padding to be
1861 relative to a self-ending face. This would be like saying ``stop 2
1862 columns before I don't know where''. Here are two examples of such
1863 invalid settings (an error will be thrown if you try that in a theme):
1865 @verbatim
1866 :face (option :face (syntax :padding-right 2))
1867 :face (option
1868         :face (syntax
1869                 :face (short
1870                         :padding-right (2 :relative-to option))))
1871 @end verbatim
1873 @node Layout Inheritance, , Layout Properties, Layout
1874 @subsubsection Layout Inheritance
1875 @cindex Face Properties, inheritance
1876 @cindex Face Properties, layout, inheritance
1877 @cindex Themes, faces, properties, inheritance
1878 @cindex Themes, faces, properties, layout, inheritance
1879 This section is a misnomer. Contrary to highlight properties, there is
1880 @emph{no} inheritance for layout properties across a face tree. In other
1881 words, every missing layout property in a face specification has the
1882 property in question set to its default value.
1884 Again, this design decision has been adopted because it is the most
1885 natural thing to do. If you're not convinced, consider this: when you
1886 specify that the @samp{option} face has a top padding of 0, you mean
1887 that every option should be described on a line of its own. However, you
1888 probably do @emph{not} mean that every individual sub-part of the
1889 option's description (syntax part, usage part @etc{}) should also start
1890 on its own line.
1892 Now that we know all about highlight and layout inheritance, we are able
1893 to explain the face specification shortcut mentioned earlier, when a
1894 face is specified directly by name, without any explicit property
1895 specification:
1897 @verbatim
1898 :face description
1899 @end verbatim
1901 This syntactic shortcut actually lets you specify a face which gets all
1902 default values for layout properties, and inherits all current values
1903 from its super-faces for highlight properties. This is in fact a
1904 shortcut for this:
1906 @verbatim
1907 :face (description)
1908 @end verbatim
1910 This, however, does not explain why you would want to issue such a
1911 specification instead of just not mentioning the face at all. See
1912 @ref{Implicit Faces} for an explanation.
1915 @node Implicit Faces, , Layout, Theme Creation
1916 @subsection Implicit Faces
1917 @cindex Implicit Faces
1918 @cindex Faces, implicit
1919 @cindex Themes, faces, implicit
1920 @cindex Built-in themes, @t{raw}
1921 @cindex Themes, built-in, @t{raw}
1922 In order to fully understand how themes work, we need to tackle one last
1923 aspect of their conception: the case of @emph{implicit faces}. Although
1924 @clon{} itself needs a completely defined face tree to perform output
1925 correctly, a theme file is not required to define all of them (that is
1926 impossible by the way: because of group nesting, a complete theme file
1927 would be infinitely big). In fact, a theme file can be totally empty, in
1928 which case the output will effectively conform to the built-in
1929 @samp{raw} theme. When a face is ``missing'' from a theme, @clon{}
1930 arranges to define it in a sensible way. Such a face is said to be
1931 @emph{implicit}. The exact rules for defining implicit faces is what
1932 this section is all about.
1934 @menu
1935 * Face Tree Reuse::     Substituting previously specified faces
1936 * Sibling Faces::       Substituting built-in faces
1937 @end menu
1939 @node Face Tree Reuse, Sibling Faces, Implicit Faces, Implicit Faces
1940 @subsubsection Face Tree Reuse
1941 @cindex Faces, reuse
1942 @cindex Themes, faces, reuse
1943 Suppose that @clon{} needs to display an option's description, and that
1944 option belongs to a group. The corresponding face in a theme file would
1945 be the following one:
1947 @verbatim
1948 :face (group :face (items :face (option  #| ... |#)))
1949 @end verbatim
1951 This face describes how options belonging to a level 1 group are to be
1952 displayed. As such, it is not applicable to toplevel options. When this
1953 face is missing from the theme file, @clon{} tries to find a @emph{more
1954 general} one. In that particular case, the theme file might define a
1955 ``toplevel'' @samp{option} face like this:
1957 @verbatim
1958 :face (option #| ... |#)
1959 @end verbatim
1961 This face is more general because it lies at the toplevel. As such, it
1962 is considered applicable to toplevel options, but also to options
1963 belonging to groups at any level. In the same vein, specifying an
1964 @samp{option} face within a @samp{group} face implicitly makes it
1965 applicable at any higher group level.
1967 This face reuse mechanism applies to @emph{any} face in a theme; not
1968 only to the ones used in the examples above. For instance, if you decide
1969 that all headers in @clon{}'s output should be displayed in the same
1970 way, you can very well specify a @samp{header} face at the toplevel of a
1971 theme file (although @clon{} never has anything to display in a
1972 @samp{header} face at the toplevel), and this face will be used in
1973 synopsis headers, group headers, fallback headers @etc{}.
1975 @cindex Faces, tree, reuse
1976 @cindex Themes, faces, tree, reuse
1977 Now, I must confess that the face reuse mechanism described above was
1978 over-simplified. What really happens is not exactly face reuse, but
1979 @emph{face tree} reuse. Here is a more complicated example to clarify
1980 things a little.
1982 Suppose @clon{} needs to display the syntax part of an option that
1983 belongs to a level 1 group. The corresponding face in a theme file would
1984 be the following:
1986 @verbatim
1987 :face (group :face (items :face (option :face (syntax #| ... |#))))
1988 @end verbatim
1990 If that face is missing, then @clon{} will in fact attempt to find a
1991 more general one @emph{while preserving as much context as possible}. In
1992 other words, the following specifications will be tried, in that order:
1994 @verbatim
1995 :face (items :face (option :face (syntax #| ... |#)))
1996 :face (option :face (syntax #| ... |#))
1997 :face (syntax #| ... |#)
1998 @end verbatim
2000 I hope this makes sense to you because again, it is the most natural
2001 thing to do. What this roughly means is that when you are looking for a
2002 way to display an option's syntax part, you should reuse a more general
2003 option's syntax face first, and only as a very last resort fall back to
2004 a @samp{syntax} face specification that would be floating around on its
2005 own.
2007 @node Sibling Faces, , Face Tree Reuse, Implicit Faces
2008 @subsubsection Sibling Faces
2009 @cindex Sibling Faces
2010 @cindex Faces, siblings
2011 @cindex Themes, faces, siblings
2012 @cindex Built-in themes, @t{raw}
2013 @cindex Themes, built-in, @t{raw}
2014 Now, what happens when the face you're looking for is not specified
2015 @emph{at all}, not even at a more general level? In such a situation,
2016 @clon{} uses a @emph{sibling}. A sibling face is a face that plays the
2017 same role as the one you're looking for, only it is extracted from the
2018 built-in @samp{raw} theme. The built-in @samp{raw} theme ensures that
2019 every face is defined at least once, so all faces will eventually be
2020 found. When a sibling face is not found in the exact context in which it
2021 is needed (for instance, the @samp{group} face is empty in the
2022 @samp{raw} theme), then the same process of face tree reuse as described
2023 in the previous section occurs on the sibling face tree.
2027 @c ====================================================================
2028 @c Conclusion
2029 @c ====================================================================
2030 @node Conclusion,  Concept Index, Output, Top
2031 @chapter Conclusion
2032 So that's it I guess. Enjoy using clonified applications, don't spend
2033 too much time hacking themes, and please contribute to the @cl{} world
2034 by developing standalone programs with @clon{}. Read @userref{Top} to
2035 learn how to do that.
2037 Hmmm. What kind of conclusion was that@dots{}
2041 @c ====================================================================
2042 @c Concept Index
2043 @c ====================================================================
2044 @node Concept Index, , Conclusion, Top
2045 @unnumbered Concept Index
2047 @printindex cp
2049 @bye
2051 @c  LocalWords:  Clon clon cmdline Clonification tty emph CmdLine clonified SGR
2052 @c  LocalWords:  clonfiscated clonistified clonificated clonificationated samp
2053 @c  LocalWords:  cindex subsubsection pxref Didier Nuker postfix Runtime cth
2054 @c  LocalWords:  cartouche toplevel prepended IEC
2056 @c enduser.texi ends here