jed-users mailing list

[2003 Date Index] [2003 Thread Index] [Other years]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]

Re: L4J: complete \end with \begin


begin  Joerg Sommer <joerg@xxxxxxxxxxxx> wrote:
> Hi,
> 
> I hate it to enter the same after \end what I wrote after \begin. So I
> thourght jed can do that for me. Here is my patch for it:

but this patch isn't correct. It doesn't work with nested environments in
all cases. Here is a new one:

#v+
   if ( blooking_at("\\end{") ) {
      push_spot();

      ERROR_BLOCK {
	 pop_spot();
      }
      
      () = left(5);

      % 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{}");
	    }
	    completion = bufsubstr() + "}";
	    break;
	 }
      }

      pop_spot();
      if (completion != NULL)
	insert(completion);

      return;
   }
#v-

Jörg.

--------------------------
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]