- Subject: Re: Template function
- From: Paul Boekholt <p.boekholt@xxxxxxxxx>
- Date: Tue, 3 Dec 2002 16:56:38 +0100
On Mon, Dec 02, 2002 at 03:58:24AM +0100, Mikael Hultgren wrote:
> I've written a template function for inserting text into buffers,
> depending on the ext of the buffer.
...
if( rc >= 0 )
{
push_spot();
...
if( fsearch("@point@" ))
{
push_spot();
replace("@point@", "");
}
...
% Return us to or original place
pop_spot();
It seems to me that if you have a @point@, you leave something on the "point
stack", or whatever.
Your function got me thinking so I wrote this:
public variable point = 0;
static define find_point_hook ()
{
if( point)
goto_line( point);
point = 0;
}
add_to_hook( "_jed_find_file_after_hooks", &find_point_hook);
static define save_point_hook()
{
variable line = what_line;
variable modeline;
(); %filename arg
push_spot_bob;
push_mark_eol;
modeline = bufsubstr;
if( string_match( modeline, "\\(.*-\\*-.*\\)point: ?[0-9]+\\(.*-\\*-.*\\)", 1))
{
delete_line;
variable pos, len;
(pos, len) = string_match_nth( 1);
substr( modeline, pos+1, len);
sprintf( "point: %d", line);
(pos, len) = string_match_nth( 2);
substr( modeline, pos+1, len);
insert( () + () + () + "\n"); %apparently the () are filled right to left
}
pop_spot;
}
add_to_hook( "_jed_save_buffer_before_hooks", &save_point_hook);
This raises a question with me: if you have a bunch of ()'s with operators
between them, in what order are values popped off the stack?
--------------------------
To unsubscribe send email to <jed-users-request@xxxxxxxxxxx> with
the word "unsubscribe" in the message body.
Need help? Email <jed-users-owner@xxxxxxxxxxx>.
[2002 date index]
[2002 thread index]
[Thread Prev] [Thread Next]
[Date Prev] [Date Next]