Add function declaration search flag
ericandrewlewis opened this issue · 2 comments
To search for a function declaration, you would do something like this:
ack "function myfunction("
As function definitions share the same syntax mostly across languages, perhaps we could simplify this into an option in ack search? so that you could do something like
ack --function myfunction
Of course the option could be something shorter, just a start for discussion.
What's the use case for this? Only wanting to find the one place a given function was declared? Like
ack --function write_record
and then the single hit would come back
records.pm:47: sub write_record {
Is that a big enough win to make it better than
ack '^sub write_record'
?
Not arguing. Trying to understand.
Yeah it's debatable.
I used a custom shell command to do my searching through WordPress core before using ack, and I just prefer the ease of syntax to add a one letter option rather than spelling out "function function_name" as a parameter