- Subject: Re: L4J: nested environment closing...
- From: Romano Giannetti <romano@xxxxxxxxxxxxxxxx>
- Date: Mon, 7 Jul 2003 18:07:51 +0200
On Tue, Jun 03, 2003 at 09:50:26PM +0000, Joerg Sommer wrote:
> but this patch isn't correct. It doesn't work with nested environments in
> all cases. Here is a new one:
Thanks! I just started again to write LaTeX things, and discover that the
J4L did not manage to "close" (with ctrl-c ]) nested environment. So that I
had changed the original Guido's latex_close_env () with this: (is almost
all Jörg code):
#v+
define latex_close_env ()
{
insert ("\n");
push_spot ();
ERROR_BLOCK {
pop_spot();
}
% Idea: increase for every \end we found and decrease for ever \begin
% we found. If we have 0, the founded \begin is for our \end.
variable ends=1;
forever {
push_mark();
!if ( bsearch("\\begin{") ) {
pop_mark(1);
error("no \\begin{} found");
}
--ends;
push_spot();
variable tmp = bufsubstr(), pos=0;
% see if there are any \ends between our \end and the found \begin
do {
variable ret = is_substr(tmp[[pos:]], "\\end{");
pos += ret;
if (ret > 0) ++ends;
} while (ret > 0);
pop_spot();
if (ends == 0) {
() = right(7);
push_mark();
if ( ffind_char('}') == 0 ) {
pop_mark(1);
error("malformed \\begin{}");
}
variable completion = bufsubstr();
break;
}
}
pop_spot ();
if (completion != NULL)
insert("\\end{" + completion + "}\n");
return;
}
#v-
And now ctl-c ] works for nested environment. Guido, I think Jörg suggestion
is a good addition...
Thanks to all,
Romano
--------------------------
To unsubscribe send email to <jed-users-request@xxxxxxxxxxx> with
the word "unsubscribe" in the message body.
Need help? Email <jed-users-owner@xxxxxxxxxxx>.
[2003 date index]
[2003 thread index]
[Thread Prev] [Thread Next]
[Date Prev] [Date Next]