jed-users mailing list

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

Re: L4J: nested environment closing...


begin  Romano Giannetti <romano@xxxxxxxxxxxxxxxx> wrote:
> On Mon, Jul 07, 2003 at 06:14:27PM +0000, Joerg Sommer wrote:
> 
> Works for me (I haven't tested \\e\\n, will comment on this later), with a
> little glitch: I use to split my xjed windows in two parts, one where I edit
> the preamble and the other one with the text. If I do a ctrl-c ] in the text
> part, the position is changed in the two parts... I do not know if I

Yes, that's the "bug" you described in another mail. But I want from John
or someone else a word about it. Is it a bug or is it a feature?

I've got another idea for searching the begin and end. And a perfomance
test shows, it is better then the old one and better then the one with
narrow. Here are some numbers:

All with 1000 cycles:
mark:0.87, mark2:0.83, string:23.65, narrow:1.42
mark:0.13, mark2:0.11, string:1.43, narrow:0.16
mark:0.05, mark2:0.04, string:0.11, narrow:0.11

mark is finding begin with user marks,
mark2 is the same with better evalution of start conditions
string is cutting out an search in the string (bufsubstr(), is_substr())
narrow search in a narrow.

Who's interessted in the test, say something. I can send it to you.

And here are the new rename and boenv functions. They aren't the fastest
variants, but the differ with neary constantly factor near zero from the
fastest and they are shorter and better to read.

#v+
private define boenv ()
{
   variable start_mark, begin_mark, end_mark;
   start_mark = create_user_mark();
   begin_mark = start_mark;
   end_mark = start_mark;
   do {
      goto_user_mark(begin_mark);
      !if ( bsearch("\\begin{") ) {
	 goto_user_mark(start_mark);
	 return 0;
      }
      begin_mark = create_user_mark();
      
      goto_user_mark(end_mark);
      !if ( bsearch("\\end{") )
	break;
      end_mark = create_user_mark();
   } while (begin_mark < end_mark);
   goto_user_mark(begin_mark);
   
   return 1;
}

define latex_rename_environment ()
{
   variable spot = create_user_mark();
   
   EXIT_BLOCK {
      goto_user_mark(spot);
   }
   
   variable old_name = env_name(1);
   
   if ( old_name == NULL )
     error("You aren't within an environment");
   
   variable new_name =
     read_with_completion(std_env, "Which environment (TAB to list)?",
			  old_name, "", 's');
   
   if ( new_name == old_name )
     return;
   
   () = right(7);
   delete_word();
   insert(new_name);
   
   goto_user_mark(spot);

   variable begin_mark, end_mark, begin_name, end_name;
   () = left(1);
   begin_mark = create_user_mark();
   end_mark = begin_mark;
   begin_name = "\\begin{" + old_name + "}";
   end_name = "\\end{" + old_name + "}";
   do {
      goto_user_mark(end_mark);
      () = right(1);
      !if ( fsearch(end_name) )
	error("No "+end_name+" found");
      end_mark = create_user_mark();
      
      goto_user_mark(begin_mark);
      () = right(1);
      if ( fsearch(begin_name) )
	begin_mark = create_user_mark();
      else
	break;
   } while (begin_mark < end_mark);
   goto_user_mark(end_mark);   
   
   () = right(5);                 % go over \end{
   delete_word();
   insert(new_name);
}
#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]