jed-users mailing list

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

Re: How do I get text from the buffer? SLang?


On Mon, Sep 27, 2004 at 08:02:00PM -0400, jeremy@xxxxxxxxxx wrote:
> I have taken the portions of code I thought were necessary and created
> the following function:
> 
> define change_name()
I think this is easier with regular expressions:

define change_name()
{
   variable fname, lname, bvcd_line;
      
   !if (bol_bsearch("BEGIN:VCARD")) { beep; return; }
   push_mark;
   !if (bol_fsearch("END:VCARD")) { pop_mark; beep; return; }
   narrow();
   bob;
   EXIT_BLOCK
     {
	widen;
     }
   
   bvcd_line = what_line ();
	    
   % ===
   % Find the N:John;Doe; line
   if (re_fsearch("^N:\\([^;]*\\);?\\([^;]*\\);?"))
     {
	fname = regexp_nth_match(1);
	lname = regexp_nth_match(2);
	% Read the new first/last name
	fname = read_mini("First Name:", fname, "");
	lname = read_mini("Last Name:",  lname, "");
	!if (replace_match(sprintf("N:%s;%s;", fname, lname), 0))
	  error("replace failed");
     }
   else
     add_name();
}

The disadvantage of this is that regular expression searching does not cross
lines (I believe a vcard can look like 
N:John;
 Cowgar
).

--------------------------
To unsubscribe send email to <jed-users-request@xxxxxxxxxxx> with
the word "unsubscribe" in the message body.
Need help? Email <jed-users-owner@xxxxxxxxxxx>.


[2004 date index] [2004 thread index]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]