[TxMt] [Service] Edit Safari page source in TM

Andreas Wahlin andreaswahlin at bredband.net
Fri Sep 23 12:22:34 UTC 2005


How can I get my "user" accont, I want it to save to
~/Desktop/
but I tried that and it didn't work ...

Andreas

On Sep 20, 2005, at 19:44 , Fred B. wrote:

>
> On 20 sept. 05, at 18:57, Eric Peden wrote:
>
>> On Tue, Sep 20, 2005 at 01:47:49PM +0200, José Campos wrote:
>>
>>>    Is it yet, or will it be possible to get a item like this in
>>> Safari->Services : "Edit page source in TextMate"?
>>>
>>
>> Did you see this?
>>
>> http://comox.textdrive.com/pipermail/textmate/2005-September/ 
>> 005718.html
>>
>> You could use the AppleScript menu to get an actual menu item for  
>> it, as
>> opposed to just having a keystroke. At that point, the only  
>> difference
>> between the AppleScript solution and a service would be which menu it
>> appeared on. ;)
>>
>
> Here is a more sophisticated version, it saves the source of the  
> front page of Safari in a temp folder then opens it in TM.
> If there is no window in Safari or if it's empty, it warns you.
> If the name of the page contains slashs, it replaces them with colons.
>
> There's maybe better ways to achieve that, but that's I come up  
> with after encountering numerous problems.
> AS is useful but can really suck!
>
> tell application "Safari"
>     if not (exists document 1) then
>         display dialog "You need to open a web location first!"  
> buttons {"OK"} default button 1
>         return
>     end if
>     set mySource to the source of front document as text
>     if (length of mySource is 0) then
>         display dialog "You need to open a web location first!"  
> buttons {"OK"} default button 1
>         return
>     end if
>     set myName to name of front document as text
> end tell
>
> try
>     tell application "TextMate" to activate
>
>     set myName to replace_chars(myName, "http://", "")
>     set myName to replace_chars(myName, "/", ":")
>
>     if (myName ends with ".html") or (myName ends with ".htm") then
>         set myPath to "/tmp/" & myName
>     else
>         set myPath to "/tmp/" & myName & ".html"
>     end if
>
>     do shell script "rm -f " & quoted form of myPath
>     do shell script "echo " & quoted form of mySource & " >> " &  
> quoted form of myPath
>     do shell script "open -a TextMate " & quoted form of myPath
> end try
>
> on replace_chars(this_text, search_string, replacement_string)
>     set AppleScript's text item delimiters to the search_string
>     set the item_list to every text item of this_text
>     set AppleScript's text item delimiters to the replacement_string
>     set this_text to the item_list as string
>     set AppleScript's text item delimiters to ""
>     return this_text
> end replace_chars
>
>
>
>
>
>
> ______________________________________________________________________
> For new threads USE THIS: textmate at lists.macromates.com
> (threading gets destroyed and the universe will collapse if you don't)
> http://lists.macromates.com/mailman/listinfo/textmate

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macromates.com/textmate/attachments/20050923/f74f0e7e/attachment.html>


More information about the textmate mailing list