jed-users mailing list

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

L4J: complete \end with \begin


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:

#v+
--- latex.sl.orig	2003-05-22 00:00:41.000000000 +0200
+++ latex.sl	2003-06-01 14:09:45.000000000 +0200
@@ -102,6 +102,49 @@
   variable symbol, completion;
   variable insertbuf = whatbuf(), searchbuf = "*ltx-comp*";
    
+   if ( blooking_at("\\end{") ) {
+      push_spot();
+      
+      () = left(5);
+      
+      forever {
+	 push_mark();
+	 !if ( bsearch("\\begin{") ) {
+	    pop_mark(1);
+	    break;
+	 }
+	 push_spot();
+      
+	 () = right(7);       % step over \begin{
+	 push_mark();
+      
+	 !if ( ffind_char('}') ) {
+	    % \begin{ doesn't have a }
+	    pop_mark(0);      % mark after \begin{
+	    pop_spot();       % before \begin
+	    pop_mark(1);      % where we started
+	 
+	    break;
+	 }
+      
+	 () = right(1);
+	 variable endmark = bufsubstr();  % the region of \begin{}
+      
+	 !if ( is_substr(bufsubstr(), "\\end{" + endmark) ) {
+	    pop_spot();      % before \begin
+	    completion = endmark;
+	    break;
+	 }
+	 pop_spot();
+      }
+      
+      pop_spot();
+      if (completion != "")
+	insert(completion);
+
+      return;
+   }
+   
   !if (bufferp(searchbuf)) {
     sw2buf(searchbuf);
     insert_file( expand_jedlib_file("ltx-comp.dat") ); bob();
#v-

Is there a way to check if I left a spot or a mark on the stack?

Bye, Joerg.

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