displaying function name
Offer Kaye
offer.kaye at gmail.com
Tue Aug 31 18:25:36 CEST 2004
On Tue, 31 Aug 2004 08:34:15 +1000, Michael Smith wrote:
>
> Some functions in that macro file should be considered work in progress,
> they serve as examples only. The functions which use tags and cvs work
> ok.
I couldn't understand what your open_file_at_cursor function was
trying to do, so I rewrote it from scratch rather than debug it,
according to my understanding of what is meant by "open file at
cursor". Here is my version:
# F11
# Open the file named at the cursor
define open_file_at_cursor
{
name_start = search( "[ \t]|^", $cursor , "regex","backward" )
name_end = search( "[ \t\n]", $cursor , "regex" )
filename = get_range( name_start, name_end )
filename = replace_in_string( filename , "[ \t]" , "" , "regex" , "copy" )
if (name_start == name_end )
{
dialog( "No string under cursor!", "OK" )
}
else
{
open( filename )
}
}
Fairly simple- the file name is assumed to be delimited by whitespace
(either a space or a tab), where the "replace_in_string" line is used
to remove any leading whitespace char. Once I have the limiting
positions of the file name I get it open it (or open an error dialog
if there was no text under the cursor).
Bugs:
1. I tried using "\s" to match whitespace, but it didn't work for some
reason. Anyone know why?
2. If the filename DOES contain a whitespace, this function will of
course fail. Since I hardly ever use filenames with whitespace in
them, this isn't a major problem for me.
Comments?
Regards,
--
Offer Kaye
More information about the Discuss
mailing list