On Feb 15, 2013, at 04:55, David Donachie <[email protected]> wrote:
>> BBEdit isn't too sanguine about adding temp files to a project.
> 
> The odd thing is that the document path of Fetch's temp files (as displayed 
> at the top of the BBEdit window) is the SFTP path, and if you drag that icon 
> into a project then the project also reports it as being a file at that SFTP 
> location... till you close it, and then suddenly the project reports the (now 
> missing) temp file location instead.
______________________________________________________________________

Hey David,

Yeah.  That's not exactly intuitive.

>> Give the attached Applescript a try...
> 
> That does indeed work, but usually I tend to have a file open already and 
> then decide I need it in a Project.

Good.  My ability to test was a bit limited, so that's reassuring.

> Any way to extract the URL from a currently open Fetch tmp file (open in 
> BBEdit) and then open it using BBEdit's browser?

Not as far as I can see.  There appears to be no way to acquire the 'File Path' 
from the front window, and the UI inspector doesn't see the static text — so 
System Events doesn't seem to be an option either.

Fetch is fairly scriptable, so theoretically you could parse through the file 
names or urls of the files in the front window.  Yeah, it's doable.

The script is looking for the BBEdit window opened WITH Fetch to be frontmost 
in BBEdit.

It will verify that the editing session is via Fetch and then use the file name 
to parse through the names of the remote items in the front Fetch window.  If a 
match is made it will grab the url of the remote item and pop-up a list of 
available BBEdit Projects.  If you make a selection the remote file will be 
added to that project.

It's not pretty, but it works.

--
Best Regards,
Chris

-------------------------------------------------------------------------------------------

try
  
  set continueBool to false
  
  tell application "BBEdit"
    tell front project window
      set _file to its file as text
    end tell
  end tell
  
  if _file contains "Fetch Temporary Folder:" then
    tell application "Finder" to set fName to name of (alias _file)
    
    tell application "Fetch"
      tell front window
        set fileList to name of remote items
        
        if fileList contains fName then
          set _url to url of remote item fName
          set continueBool to true
        end if
        
      end tell
    end tell
    
  end if
  
  if continueBool = true then
    tell application "BBEdit"
      
      # Uncomment to close the editing window attached to Fetch.
      # close front window
      
      set projectList to name of project documents whose name ends with 
"bbprojectd"
      set _project to choose from list projectList with title ¬
        "Project Document List" with prompt "Pick One:" default items (item 1 
of projectList) ¬
        with empty selection allowed without multiple selections allowed
      
      if _project ≠ false then
        set _project to item 1 of _project
        tell project document _project
          set index of it's window to 1
          make new project item with properties {URL:_url}
        end tell
      end if
      
    end tell
    
  end if
  
on error e number n
  set e to e & return & return & "Num: " & n
  tell me to set dDlg to display dialog e with title "ERROR!" buttons 
{"Cancel", "Copy", "OK"} default button "OK"
  if button returned of dDlg = "Copy" then set the clipboard to e
end try

-------------------------------------------------------------------------------------------

-- 
-- 
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>

--- 
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].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to