Todd Ruston said:

> Would using your regexps in the Text->Process Lines Containing… feature do
> what you want (using the copy to new document option, and then you could
> print that)?
>

Thank you so much for pointing that out to me! Despite my using BBEdit
since the early days, I never even knew about "Process Lines Containing" --
I had it disabled in the Preferences. It definitely moves this forward...
it even uses tabs to include the indentations (nesting of functions),
although it's probably just copying tabs that I put into the source to
indent them. Now I'll have to refine my regexps, for example using negative
assertions to exclude comments and so forth.

Charlie Garrison said:

> IOW, javascript knows the functions it just parsed, so let it give you the
> list. Will almost always be more accurate than a regex solution.
>

I'm sure you're right... in theory that would be more accurate. Of course I
don't know any way to run JavaScript on a BBEdit file directly; BBEdit
doesn't contain an internal JS engine. I guess I could run a
list-the-functions function in Firebug's command line, feeding off the web
page rather than directly off the BBEdit source. However, there might be a
couple of drawbacks to that. When a web page sucks in multiple JS files,
the browser's JS engine combines them all together into one unified
program; I don't think a JS meta-function run on the web page could
separate them out again. So I'd end up with a list of all the functions
from *all* the JS files -- and even, I'd guess, from any generated
functions that weren't literally in *any* of the JS files -- not focusing
on one JS file like I want.

The other drawback would (I think) be that I'd have to leave BBEdit
entirely to do that, and since my ultimate goal is one script (probably an
AppleScript) that I could run from inside BBEdit with a single command --
"Create Functions-List Document" -- that might complicate the script. I
don't even know if Firebug *is* AppleScript-able.

Anyway, thanks to both of you for your useful replies. It gives me some
direction for more explorations.

Lawrence





Lawrence San
Business Writing: Santhology.com
Cartoon Stories for Thoughtful People: Sanstudio.com



On Sun, Mar 23, 2014 at 1:39 PM, Todd Ruston <[email protected]> wrote:

> Would using your regexps in the Text->Process Lines Containing… feature do
> what you want (using the copy to new document option, and then you could
> print that)?
>
> - Todd
>
> On Mar 22, 2014, at 8:33 PM, Lawrence San <[email protected]> wrote:
>
> I have a long, complex JS file and, in an attempt to figure out what's
> going on, I'd like to print out just a list of active function names (by
> "active" I mean not commented out). In other words, something like the
> functions popdown menu in BBEdit -- but in an editable text form that I can
> laser print with lots of space between the function names to draw arrows,
> scribble notes on, etc. (Actually BBEdit's popdown is better, because it
> shows nesting through indentation, and in desperation I've resorted to
> making a screenshot of it and printing that.)
>
> So far I've created three regexps that seem to work, more or less:
>
> Find all regular function definitions:
> function\s?\w+\s?\(.*\)
>
> Find all function expressions:
> (var\s)?.*\s?=\s?function\(.*\)
>
> Combine the first two, to find all function declarations of either kind:
> function\s?\w+\s?\(.*\)|(var\s)?.*\s?=\s?function\(.*\)
>
> In case you're wondering, I'm not concerned with anonymous functions in
> this file.
>
> Of course that's pretty limited. In addition to not screening out
> commented-out functions (I could probably figure out how to do that), it
> doesn't get me very far -- it doesn't tell me what to _do_ with the found
> results in order to generate a text list (in a separate file). All it does
> is find the functions one at a time...
>
> I've googled a fair amount, but couldn't find any complete solution for
> doing this. (Others have asked too -- though not in a BBEdit context -- but
> I couldn't find anyone who got a real answer.) Rather than use regexps,
> some people suggested doing it in JavaScript itself, searching for function
> types or something like that.
>
> Can anyone point me in the right direction... Can I build on the regexps
> I've created so far? What should I be trying next?
>
> Thank you.
>
> --
> This is the BBEdit Talk public discussion group. If you have a
> feature request or would like to report a problem, please email
> "[email protected]" rather than posting to the group.
> Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>
>
> ---
> You received this message because you are subscribed to the Google Groups
> "BBEdit Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
>
>
>

-- 
This is the BBEdit Talk public discussion group. If you have a 
feature request or would like to report a problem, please email
"[email protected]" rather than posting to the group.
Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>

--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].

Reply via email to