• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: saving front window using osascript...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: saving front window using osascript...


  • Subject: Re: saving front window using osascript...
  • From: Rick Ballard <email@hidden>
  • Date: Fri, 9 Nov 2007 08:48:28 -0800

On Nov 9, 2007, at 3:16 AM, Fons Rademakers wrote:
#!/bin/sh
#
# Removes trailing blanks (spaces and tabs) from the file.
#

osascript << ENDOFSCRIPT
tell application "Xcode"
set myFile to associated file name of front window
save the front document
do shell script "perl -pe 's/[\t ]+$//g' " & quoted form of myFile & " > ~/.xc-save.$$; mv ~/.xc-save.$$ " & quoted form of myFile
end tell
ENDOFSCRIPT


but this leaves my editor window empty since no buffer gets written back in. But as soon as something gets written back in the buffer is modified, hence not saved. Is there a catch-22 here?

Hi Fons,

I'm not completely sure I understand what you mean. Xcode won't notice that you've overwritten the file on disk right away, so maybe that's what you're seeing. Switching applications will trigger a refresh of the file on disk, as will closing and re-opening it.

You don't need to replace the file on disk in order to modify its contents, however; you can manipulate the text of the document directly via applescript. If you browse Xcode's scripting dictionary in script editor and look at the Text Document class, you should see what you need. Specificially, you can "set text of front text document to" whatever you want.

	- Rick
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: saving front window using osascript...
      • From: Fons Rademakers <email@hidden>
    • Re: saving front window using osascript...
      • From: Fons Rademakers <email@hidden>
References: 
 >saving front window using osascript... (From: Fons Rademakers <email@hidden>)
 >Re: saving front window using osascript... (From: Rick Ballard <email@hidden>)
 >Re: saving front window using osascript... (From: Fons Rademakers <email@hidden>)
 >Re: saving front window using osascript... (From: Rick Ballard <email@hidden>)
 >Re: saving front window using osascript... (From: Fons Rademakers <email@hidden>)

  • Prev by Date: java reference
  • Next by Date: Re: XCode 2.0 and .pbxproj files
  • Previous by thread: Re: saving front window using osascript...
  • Next by thread: Re: saving front window using osascript...
  • Index(es):
    • Date
    • Thread