displaying function name
Offer Kaye
offer.kaye at gmail.com
Tue Aug 31 19:19:51 CEST 2004
On Tue, 31 Aug 2004 12:51:58 -0400, Tony Balinski wrote:
First of all Tony, thanks for the helpful comments!
>
> The original, it seems to me, was looking for a "grep" output line,
> of form
> file-name: found-line-content
>
As Homer would say- Doh! Seems obvious now :-)
> I have similar macros to open a file from a grep output-line and position
> the cursor on the line that grep found.
>
Could you post the code (or a link to it)? Sound useful :-)
> You want to double-up the backslash - when reading the string, the macro
> language parser turns \s into s.
Ahh, that explains it. My newbie mistake number 1 ;-)
> The grep output lists the file-name followed by a colon, so the colon
> becomes the delimiter there.
True, and because filenames with an embedded colon as part of the name
are just as rare for me as those with embedded whitespace, here's a
fixed version that will correctly open a filename with a colon inside
(I also fixed the \s mistake):
# F11
# Open the file named at the cursor
define open_file_at_cursor
{
name_start = search( "\\s|^", $cursor , "regex","backward" )
name_end = search( "[\\s\\n]", $cursor , "regex" )
filename = get_range( name_start, name_end )
filename = replace_in_string( filename , "^\\s" , "" , "regex" , "copy" )
filename = replace_in_string( filename , ":.*$" , "" , "regex" , "copy" )
if (name_start == name_end )
{
dialog( "No string under cursor!", "OK" )
}
else
{
open( filename )
}
}
The reason I replace ":.*$" is that grep (at least the version I use)
doesn't leave a space between the colon and the quoted line, so unless
it starts with a whitespace, I would have any characters after the
colon. So I simply get rid the whole lot :-)
Regards,
--
Offer Kaye
More information about the Discuss
mailing list