• 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: Fons Rademakers <email@hidden>
  • Date: Fri, 09 Nov 2007 12:16:24 +0100
  • Keywords: CERN SpamKiller Note: -51 Charset: west-latin
  • Organization: CERN

Hi Rick,

  I now do:

#!/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?

Cheers, Fons.


Rick Ballard wrote:
The problem with your current script is that the output of an Xcode user script is buffered until the end of the script, as is appropriate in most cases. In your case, since you want to execute more actions (an applescript save command) after the output goes to the document, I'd suggest using another applescript command to dump your output to the document instead of doing so with the user script's output destination. You can manipulate text documents in Xcode with applescript similarly to how you can in other applications.

    - Rick

On Nov 8, 2007, at 1:51 AM, Fons Rademakers wrote:

Hi Rick,

many thanks that help, to use "document". However, what I try to achieve is to have a user script that:

- strips all trailing blanks and tabs from a file
- saves the file

I tried:

- Input: "Entire Document"
- Directory: "Home Directory"
- Script:

#!/bin/sh
#
# Removes trailing blanks (spaces and tabs) from the file + save.
#

perl -pe 's/[\t ]+$//g' <&0

osascript << ENDOFSCRIPT
tell application "Xcode"
  save the front document
end tell
ENDOFSCRIPT

but this does not work as the save is of the document before the perl modified text is pasted in. How can I make such a two step script?

Cheers, Fons.




Rick Ballard wrote:
On Nov 7, 2007, at 5:02 PM, Fons Rademakers wrote:
Hi,

something very trivial. I want to save the Xcode front window via osascript:

tell application "Xcode"
 save front window
 close front window
end tell

only closes but does not save the window. What script command should I use? write to file? If so how do I get the type?
tell application "Xcode"
   close front document saving <yes/no/ask>
end tell
   - Rick


-- Org: CERN, European Laboratory for Particle Physics. Mail: 1211 Geneve 23, Switzerland E-Mail: email@hidden Phone: +41 22 7679248 WWW: http://fons.rademakers.org Fax: +41 22 7669640 _______________________________________________ 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: Rick Ballard <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>)

  • Prev by Date: Re: IB 3.0 wiping .svn
  • Next by Date: 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