summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/gmutils/gmenvir.sty
blob: 3348e8b00054cf45d98e7849311e1b39aa1d5656 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
%% 
%% \iffalse ^^A we skip the debug setting
\IfFileExists{\string~/bin/gen_and_xela}{\errorcontextlines=1000 }{}
%% \fi
%% ^^A $Id: TheUltimateMaster.gmd,v 0.250 2010/10/24 14:42:35 natror Exp natror $
%% This is file “gmenvir.sty” generated with the DocStrip utility.
%% 
%%
%% The original source files were:
%%
%% gmutils/gmutils.gmd  (with options: `envir')
%%
%% 
%% Copyright ©  
%% by Grzegorz ‘Natror’ Murzynowski
%% natror (at) o2 (dot) pl
%% 
%% This program is subject to the LaTeX Project Public License.
%% See http://www.ctan.org/tex-archive/help/Catalogue/licenses.lppl.html
%% for the details of that license.
%%
%% LPPL status: "author-maintained".
%%
%% 
%% 
%% For the documentation please refer to the file(s)
%% gmutils.{gmd,pdf}.
%% 
%% 
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{gmenvir}
    [2010/10/24 v0.993 redefinition of \string \begin \space and \string \end  (GM)]


%%
%%
%%     ^^A\typeout{\unexpanded{#4}}%%

\RequirePackage{gmbase, gmampulex} % the low-level macros



\emptify\@envirstack

\def\@pushenvir{%
  %^^V\edef\@currenvir{\@currenvir}% is already expanded.
  \xdef\@envirstack{%
    {\@xa\detokenize\@xa{\@currenvir}}%
    {\the\currentgrouplevel}%
    {\@currenvline}%
    \@envirstack
  }%
}

\def\@popenvir#1#2#3{%
  \@XA{\@popenvir@#1#2#3}\@envirstack\@nil
}

\def\@popenvir@#1#2#3#4#5#6#7\@nil{%
  \gdef#1{#4}% |#1| carries last envir name
  \gdef#2{#5}% |#2| carries last envir level
  \gdef#3{#6}% |#3| carries last envir beginnig line
  \gdef\@envirstack{#7}% and we update the stack
}

\long\def\@begnamedgroup#1{%
  \edef\@prevgrouplevel{\the\currentgrouplevel}% added 2009/03/24 to
  % handle special pseudo-environments that don't increase
  % \incmd\currentgrouplevel (such as \inenv{document}). Note it's
  % |\edef|ed \emph{outside} the environment's group.
  \@ignorefalse% not to ignore blanks after group
  \begingroup\@endpefalse
  \edef\@prevenvir{\@currenvir}% Note we |\edef| it inside the group
  % (for obvious reason), unlike the ‘previous’ grouplevel.
  \edef\@currenvir{#1}% We could do recatcoding
  % through\inverb|\string| or \nlperc\cmd\detokenize\ but all the name
  % `other' and 10 could affect
  % a~thousand packages so we don't do that and we'll recatcode in
  % a~testing macro, see line \ref{@ifenvir}.
  \edef\@currenvline{\on@line}%
  \@pushenvir % we put current envir to |\@envirstack|.
  \csname #1\endcsname}% if the argument is a~command's name (an

\def\begin{\gmu@ifstar{\@begnamedgroup}{%
      \@begnamedgroup@ifcs}}

\def\@begnamedgroup@ifcs#1{%
  \ifcsname#1\endcsname\afterfi{\@begnamedgroup{#1}}%
  \else\afterfi{\@latex@error{Environment #1 undefined}\@eha}%
  \fi}%


\long\def\@fourthofmany#1#2#3#4#5\@nil{#4}%

\lpdef\@ifprevenvir#1{%\label{@ifenvir}\
  % \begin{enumargs}
  %   \mand enquired environment name which will be confronted with
  %   \incs{@prevenvir}
  %   \mand what if true (if the names are
  %   equivalent\qfootnote{The names are checked whether they produce
  %     the same \cmd\csname. They don't have to have the same
  %     catcodes.})
  %   \mand what if false
  % \end{enumargs}
  %
  % \changes{v0.92}{2009/09/04}{added}
  % \chgs{2010/06/09 v0.993 made use \cmd\@envirstack}
  %
  % % \CH{2010/09/23 v0.993 to be precise, it's not a change but
  % % rather a staus quo action: \cmd\gmu@ifedetokens suddenly turned
  % % to be expandable and un\cmd\protected so we make \emph{this}
  % % macro \cmd\protected}
  \gmu@ifedetokens
  {\@xa\@fourthofmany\@envirstack\relax\relax\relax\relax\@nil}%
  {#1}}


\def\@checkend#1{%
  \@ifenvir{#1}%
  {}%
  {\@badend{#1}}%
}

\ampulexdef\end[#1][#1]\endcsname\@checkend{%
\endcsname
\@popenvir\gmu@drain\gmu@drain\gmu@drain
\@checkend}

\pdef\@endif#1{\@ifenvir{#1}{\end{#1}}{}}

\pdef\@endifprev#1{\@ifprevenvir{#1}{\end{#1}}{}}


%%% (For my GNU Emacs:)
%%% Local Variables:
%%% mode: doctex
%%% coding: utf-8
%%% End:
\endinput
%%
%% End of file `gmenvir.sty'.