jed-users mailing list

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

Re: How to set lines as readonly?


On Tue, Jun 17, 2003 at 06:11:25PM -0700, Robert Wishlaw wrote:

> When loading a file, I would like to apply the Jed set_line_readonly
> function to lines containing specified words. 

How about

% set readonly all lines that match the regexp pat   
public define set_matching_readonly() %(ro=1, [pat])
{
   % optional arguments
   variable ro, pat;
   !if (_NARGS)
     1; % push on stack
   if (_NARGS < 2)
     {   
	variable prompt = ["Set readonly", "Set read-write"];
	prompt = prompt[dup] + " lines containing regexp:";
	read_mini(prompt, "", ".*"); % push on stack
     }
   (ro, pat) = (,); % get values from stack
   
   push_spot_bob();
   while (andelse{not(eobp())}{re_fsearch(pat)})
     {
	set_line_readonly(ro);
	eol;
     }
   pop_spot();
}

If you only need it automatically invocated, you can leave out the part with
the optional arguments when defining set_matching_readonly(ro, pat).

If you dont need regexp search, things speed up by replacing it with fsearch.

To call it after loading a file use the jed_find_file_hook. See the file
under Help>Browse_Docs>hooks.

Günter


-- 
Milde at ife.et.tu-dresden.de

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