On Wednesday, September 21, 2011 6:07:34 AM UTC-7, Alex Popescu wrote:
>
> Lesson learned: don't use the tags generation script as a 
> documentDidSave event, except you can filter an actual source file 
> save. 


> 2.  The conclusion above made me think that a better event to attach 
> the tags generation would be the Save action. So I've transformed it 
> into a File • Save script. 
>
> This approach has solved the above issue, but the script in the 
> current form was not able to make the difference between a real 
> project (with a folder structure) and a bunch a separate files opened 
> in the current window.  


> 3. This is the part where I'm asking for help. The script in the 
> current form can be found at the end of the post. What I'd need help 
> with is: 
>
> 3.1 Is there a way to determine if the current window belongs to a 
> real project vs a set of random files? 
>

My script was trying to guess just that. But it relies on some 
circumstantial evidence. If there is a real project file, the line:

set projectDocument to project document of activeWindow

This should set projectDocument to a "project" that is on-disk or an 
insta-project.

It gets dicey after that. I am a Rails and Python programmer mostly. So I 
use insta-projects on the root of my Rails source tree typically. So in 
general, finding the first item's parent directory works. But that is not a 
very reliable means. There doesn't appear to be any other way.

A more complicated method would be to walk all the items of the project and 
find the actual tree or tree, running tags from the lowest part of the tree 
that is in common.

I think the safest bet is to create a real BBEdit project document where you 
want to run tags. That would serve as a placeholder. Alternately, maybe 
searching for your ".git" folder or some other identifying file could help 
the script automagically find the root to run tags.
 

>
> 3.2. Could someone validate the following code snippet which tries to 
> get the parent folder if the main script result is a file: 
>
>
> if kind of (info for theFile) is "folder" then 
> -- Run the maketags script 
> set thePath to POSIX path of theFile 
> else 
> set thePath to POSIX path of (container of theFile) 
> end if 
> set cmd to "cd " & thePath & "; /usr/local/bin/bbedit --maketags" 
>
>
Are you sure you ever get into a state where the folder is the active 
document?

 

> 3.3 Is there a way to install this script and trigger it through a 
> menu item/shortcut against the current project instead of having it 
> automatically triggered by the Save action? 
>
>
I just put this script in my BBEdit/Scripts folder so it shows up in the 
scripts menu. From there, I just assigned a shortcut key.
 

>
> Many thanks in advance for the help, 
>
> A://

-- 
You received this message because you are subscribed to the 
"BBEdit Talk" discussion group on Google Groups.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
<http://groups.google.com/group/bbedit?hl=en>
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>

Reply via email to