From 51311c087740f79517514fabb9848ca1f4f42f67 Mon Sep 17 00:00:00 2001
From: Karl Berry <karl@freefriends.org>
Date: Wed, 11 Jan 2006 23:55:26 +0000
Subject: trunk/Master/texmf-dist/source/latex/namespc

git-svn-id: svn://tug.org/texlive/trunk@405 c570f23f-e606-0410-a88d-b1316a301751
---
 Master/texmf-dist/source/latex/namespc/namespc.dtx | 365 +++++++++++++++++++++
 1 file changed, 365 insertions(+)
 create mode 100644 Master/texmf-dist/source/latex/namespc/namespc.dtx

(limited to 'Master/texmf-dist/source/latex/namespc/namespc.dtx')

diff --git a/Master/texmf-dist/source/latex/namespc/namespc.dtx b/Master/texmf-dist/source/latex/namespc/namespc.dtx
new file mode 100644
index 00000000000..108682aeb20
--- /dev/null
+++ b/Master/texmf-dist/source/latex/namespc/namespc.dtx
@@ -0,0 +1,365 @@
+% \iffalse meta-comment
+%
+% Copyright (C) 2003 by Alexander Dreyer <adreyer@web.de>
+% --------------------------------------------------
+% 
+% This file may be distributed and/or modified under the
+% conditions of the LaTeX Project Public License, either version 1.2
+% of this license or (at your option) any later version.
+% The latest version of this license is in:
+%
+%    http://www.latex-project.org/lppl.txt
+%
+% and version 1.2 or later is part of all distributions of LaTeX 
+% version 1999/12/01 or later.
+%
+% \fi
+%
+% \iffalse
+%<package>\NeedsTeXFormat{LaTeX2e}[1998/12/01]
+%<package>\ProvidesPackage{namespc}
+%<package>   [2003/10/03 namespace environment] 
+%
+%<*batchfile>
+\begingroup
+\input docstrip.tex
+\keepsilent
+
+\usedir{tex/latex/namespc}
+
+\preamble
+
+\iffalse meta-comment
+
+This is a generated file.
+
+Copyright (C) 2003 by  Alexander Dreyer <adreyer@web.de>
+
+This file may be distributed and/or modified under the conditions of
+the LaTeX Project Public License, either version 1.2 of this license
+or (at your option) any later version.  The latest version of this
+license is in:
+
+   http://www.latex-project.org/lppl.txt
+
+and version 1.2 or later is part of all distributions of LaTeX version
+1999/12/01 or later.
+
+\fi
+
+\endpreamble
+\askforoverwritefalse
+\generate{\usepreamble\empty
+          \usepostamble\empty
+          \file{namespc.ind}{\from{namespc.dtx}{indexfile}}}
+\generate{\file{namespc.sty}{\from{namespc.dtx}{package}}}
+
+\obeyspaces
+\Msg{*************************************************************}
+\Msg{*                                                           *}
+\Msg{* To finish the installation you have to move the following *}
+\Msg{* file into a directory searched by TeX:                    *}
+\Msg{*                                                           *}
+\Msg{*     namespc.sty                                           *}
+\Msg{*                                                           *}
+\Msg{* To produce the documentation run the file namespc.dtx     *}
+\Msg{* through LaTeX.                                            *}
+\Msg{*                                                           *}
+\Msg{* Happy TeXing!                                             *}
+\Msg{*                                                           *}
+\Msg{*************************************************************}
+\endgroup
+%</batchfile>
+%<*driver>
+\documentclass{ltxdoc}
+\usepackage{namespc}
+\usepackage{a4}
+\WideMargins
+\EnableCrossrefs         
+\CodelineIndex
+\RecordChanges
+\begin{document}
+  \DocInput{namespc.dtx}
+\end{document}
+%</driver>
+%
+%<*package>
+% \fi
+%
+% \CheckSum{46}
+%
+% \CharacterTable
+%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
+%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
+%   Digits        \0\1\2\3\4\5\6\7\8\9
+%   Exclamation   \!     Double quote  \"     Hash (number) \#
+%   Dollar        \$     Percent       \%     Ampersand     \&
+%   Acute accent  \'     Left paren    \(     Right paren   \)
+%   Asterisk      \*     Plus          \+     Comma         \,
+%   Minus         \-     Point         \.     Solidus       \/
+%   Colon         \:     Semicolon     \;     Less than     \<
+%   Equals        \=     Greater than  \>     Question mark \?
+%   Commercial at \@     Left bracket  \[     Backslash     \\
+%   Right bracket \]     Circumflex    \^     Underscore    \_
+%   Grave accent  \`     Left brace    \{     Vertical bar  \|
+%   Right brace   \}     Tilde         \~}
+%
+% \changes{v1.0}{2003/10/03}{Initial version}
+%
+% \GetFileInfo{namespc.sty}
+%
+% \DoNotIndex{\newcommand,\newenvironment,\def,\csname,\endcsname,
+% \endcsname,\expandafter,\long,\relax,\:}
+% 
+%
+% \title{The \textsf{namespc} package\thanks{This document
+%   corresponds to \textsf{namespc}~\fileversion, dated \filedate.}}
+% \author{Alexander Dreyer \\ \texttt{adreyer@web.de}}
+%
+% \maketitle
+%
+% \begin{abstract}
+%
+% The \textsf{namespc} package adds rudimentary \emph{c++}-like namespace
+% functionality to \LaTeX. It may be used to declare local \LaTeX{} commands,
+% which can be made accessible in a later contexts without defining them 
+% globally.
+%
+% \end{abstract}
+%
+% \section{Introduction}
+% This package can be used to declare local \LaTeX{} commands,
+% which may be reused in a later context without polluting the global
+% namespace, as an equivalent to \emph{c++}-like namespaces.
+%
+% \section{Usage}
+%
+% \DescribeMacro{\namespace}
+% This command is used to instantiate and reuse a certain namespace. 
+% The |\namespace| command has the following syntax:
+%
+% |\namespace{|\emph{spcname}|}{|\emph{before}|}{|\emph{body}|}|
+%\\
+% The first parameter corresponds to the name of the namespace 
+% to be started or used.
+% The \emph{before} arguments of the current call of |\namespace| are appended 
+% to the preamble of namespace \emph{spcname}, which is processed
+% before the text in \emph{body} gets processed.
+%
+% \DescribeEnv{\emph{spcname}}
+% With the first call of
+% |\namespace{|\emph{spcname}|}{|\ldots|}{|\emph{\ldots}|}| the
+% corresponding environment \emph{spcname} is defined which processes 
+% all \emph{before} arguments within its preamble.
+%
+% \DescribeMacro{\namespace*}
+% Essentially the same as the |\namespace| command but without generation 
+% of the corresponding environment.
+%
+% \DescribeMacro{\usingnamespace}
+% By using |\usingnamespace{|\emph{spcname}|}| one can force \LaTeX{} to 
+% process the namespace preamble of \emph{spcname}.
+%
+% \StopEventually{\PrintChanges\PrintIndex}
+%
+% \section{Implementation}
+%
+% We first make |@| to a character in order to use and define internal 
+% commands:
+%
+%    \begin{macrocode}
+\makeatletter
+%    \end{macrocode}
+%
+% \begin{macro}{\@defnamespace@ifundef}
+%
+% First we define an internal macro which will be used to instatiate the 
+% (internal) namespace preamble macro |\@namespace@|\emph{spcname} 
+%
+%    \begin{macrocode}
+\def\@defnamespace@ifundef#1{
+  \@ifundefined{#1}{
+    \long\expandafter\def\csname#1\endcsname{}
+  }{}
+}
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@n@mesp@cestar}
+% Now we are able to define the internal version of the starred |\namespace|
+% command.
+%
+%    \begin{macrocode}
+\newcommand{\@n@mesp@cestar}[3]{
+  \@defnamespace@ifundef{@namespace@#1}
+  \expandafter\g@addto@macro\csname @namespace@#1\endcsname{#2}%
+  {
+    \expandafter\relax\csname @namespace@#1\endcsname
+    #3
+  }
+}
+%    \end{macrocode}
+%    \end{macro}
+%
+% \begin{macro}{\usingnamespace}
+% The user command |\usingnamespace| just forces initiatiation and processing 
+% of the namespace preamble.
+%
+%    \begin{macrocode}
+\newcommand{\usingnamespace}[1]{
+  \@defnamespace@ifundef{@namespace@#1}
+  \csname @namespace@#1\endcsname
+}
+%    \end{macrocode}
+%    \end{macro}
+%
+% \begin{macro}{\@provide@namespace@env}
+% This is an internal command which provides the corresponding environment.
+%
+%    \begin{macrocode}
+\def\@provide@namespace@env#1{
+  \@ifundefined{#1} {
+   \newenvironment{#1}{\usingnamespace{#1}}{}  
+  }{}
+}
+%    \end{macrocode}
+%    \end{macro}
+%
+% \begin{macro}{\::}
+% The double colon notation may be used to access commands defined within a
+% namespace preamble once. Note that the command's arguments have to be
+% surrounded by colons:
+%    \begin{macrocode}
+\def\::#1::#2:#3:{%
+  {\csname @namespace@#1\endcsname
+   \csname#2\endcsname#3}
+}
+%    \end{macrocode}
+%    \end{macro}
+%
+% \begin{macro}{\@n@mesp@ce}
+% Next we just add the definition of the respective environment to |\namespace*|
+% in order to obtain the internal version of |\namespace|:
+%
+%    \begin{macrocode}
+\newcommand{\@n@mesp@ce}[3]{
+  \@provide@namespace@env{#1}
+  \@n@mesp@cestar{#1}{#2}{#3}
+}
+%    \end{macrocode}
+%    \end{macro}
+%
+% \begin{macro}{\namespace}
+% Finally we use the |\@ifstar| macro to define the user commands
+% |\namespace| and |\namespace*|:
+%
+%    \begin{macrocode}
+\newcommand*{\namespace}{\@ifstar\@n@mesp@cestar\@n@mesp@ce}
+%    \end{macrocode}
+%    \end{macro}
+% |@| is made special character again:
+%    \begin{macrocode}
+\makeatother
+%    \end{macrocode}
+%
+% \section{Example}
+%
+% This is example code for the use of the \textsf{namespc}~package:
+%
+%\begin{verbatim}
+%\namespace{spcname}
+%{\newcommand{\spcwidecmd}{\emph{command}\xspace}}{
+% Using \spcwidecmd for the first time.
+%} % end of namespace
+%
+% % not defined here: \spcwidecmd
+%
+%\namespace{spcname}{}{
+%  \spcwidecmd may be used again later.
+%} % end of namespace
+%
+%\begin{spcname}
+%  We can also use \spcwidecmd within the corresponding environment\ldots
+%\end{spcname}
+%
+%  Alternatively we may use the double colon notation: \::spcname::spcwidecmd::
+%
+%\usingnamespace{spcname}
+%\ldots{} or globally: \spcwidecmd.
+%
+%\end{verbatim}
+%
+% And here's the corresponding \LaTeX{} output:
+% \\
+%\namespace{spcname}
+%{\newcommand{\spcwidecmd}{\emph{command}\ }}{
+%
+% Using \spcwidecmd for the first time.
+%} 
+%
+%
+%\namespace{spcname}{}{
+%  \spcwidecmd may be used again later.
+%} 
+%
+%\begin{spcname}
+%  We can also use \spcwidecmd within the corresponding environment\ldots
+%\end{spcname}
+%
+%  Alternatively we may use the double colon notation: \::spcname::spcwidecmd::
+%
+%\usingnamespace{spcname}
+%\ldots{} or globally: \spcwidecmd
+%
+% \Finale
+% 
+% \endinput
+%</package>
+%
+%<*indexfile>
+
+ \begin{theindex} 
+ \makeatletter\scan@allowedfalse
+{\bfseries\hfil Symbols\hfil}\nopagebreak
+
+  \item \verb*+\::+\pfill \main{24}
+  \item \verb*+\@defnamespace@ifundef+\pfill \main{2}, 8, 16
+  \item \verb*+\@ifstar+\pfill 32
+  \item \verb*+\@ifundefined+\pfill 3, 20
+  \item \verb*+\@n@mesp@ce+\pfill \main{28}, 32
+  \item \verb*+\@n@mesp@cestar+\pfill \main{7}, 30, 32
+  \item \verb*+\@provide@namespace@env+\pfill \main{19}, 29
+  \item {\ttfamily \emph  {spcname}} (environment)\pfill \usage{1}
+
+  \indexspace
+{\bfseries\hfil E\hfil}\nopagebreak
+
+  \item environments:\efill 
+ \subitem {\ttfamily \emph  {spcname}}\pfill \usage{1}
+
+  \indexspace
+{\bfseries\hfil G\hfil}\nopagebreak
+
+  \item \verb*+\g@addto@macro+\pfill 9
+
+  \indexspace
+{\bfseries\hfil M\hfil}\nopagebreak
+
+  \item \verb*+\makeatletter+\pfill 1
+  \item \verb*+\makeatother+\pfill 33
+
+  \indexspace
+{\bfseries\hfil N\hfil}\nopagebreak
+
+  \item \verb*+\namespace+\pfill \usage{1}, \main{32}
+  \item \verb*+\namespace*+\pfill \usage{1}
+
+  \indexspace
+{\bfseries\hfil U\hfil}\nopagebreak
+
+  \item \verb*+\usingnamespace+\pfill \usage{1}, \main{15}, 21
+
+ \end{theindex}
+
+
+%</indexfile>
-- 
cgit v1.2.3

