Permalink
Browse files

Updated workflow applescript to use a simpler method of retrieving th…

…e frontmost document, and piping the current text contents via stdin to uncrustify, rather than passing and saving the whole document. This prevents saving the document by default.
  • Loading branch information...
1 parent ea1cd7e commit 24c93e975fc03a487804a929e6f71aa2731d4ff0 @tonyarnold committed May 15, 2012
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -3,9 +3,9 @@
<plist version="1.0">
<dict>
<key>AMApplicationBuild</key>
- <string>330</string>
+ <string>339.2</string>
<key>AMApplicationVersion</key>
- <string>2.2.1</string>
+ <string>2.2.4</string>
<key>AMDocumentVersion</key>
<string>2</string>
<key>actions</key>
@@ -51,7 +51,7 @@
<key>ActionParameters</key>
<dict>
<key>source</key>
- <string>on menu_click(mList) local appName, topMenu, r -- Validate our input if mList's length &lt; 3 then error "Menu list is not long enough" -- Set these variables for clarity and brevity later on set {appName, topMenu} to (items 1 through 2 of mList) set r to (items 3 through (mList's length) of mList) -- This overly-long line calls the menu_recurse function with -- two arguments: r, and a reference to the top-level menu tell application "System Events" to my menu_click_recurse(r, ((process appName)'s ¬ (menu bar 1)'s (menu bar item topMenu)'s (menu topMenu)))end menu_clickon menu_click_recurse(mList, parentObject) local f, r -- `f` = first item, `r` = rest of items set f to item 1 of mList if mList's length &gt; 1 then set r to (items 2 through (mList's length) of mList) -- either actually click the menu item, or recurse again tell application "System Events" if mList's length is 1 then click parentObject's menu item f else my menu_click_recurse(r, (parentObject's (menu item f)'s (menu f))) end if end tellend menu_click_recurseglobal current_documentglobal current_text_selection-- Get the currently frontmost source code document, and run uncrustify on it but rather than replacing the document, capture the formatted source and use AppleScript to update the document's contents before savingtell application "Xcode" set current_document to source document 1 whose name ends with (word -1 of (get name of window 1)) set current_text_selection to selection of current_document save current_document set current_document_path to path of current_document set raw_source to text of current_document set formatted_source to do shell script "/usr/local/bin/uncrustify -c ~/.uncrustify.cfg -l OC -f " &amp; quoted form of current_document_path set text of current_document to formatted_sourceend tell-- I wish there were a better way to do this, but Xcode's indenting is much better than uncrustify's for Objective-C source codetell application "Xcode" to activatemenu_click({"Xcode", "Edit", "Select All"})menu_click({"Xcode", "Editor", "Structure", "Re-Indent"})tell application "Xcode" to save current_document-- Deselect all texttell application "System Events" to keystroke (key code 126)</string>
+ <string>on menu_click(mList) local appName, topMenu, r -- Validate our input if mList's length &lt; 3 then error "Menu list is not long enough" -- Set these variables for clarity and brevity later on set {appName, topMenu} to (items 1 through 2 of mList) set r to (items 3 through (mList's length) of mList) -- This overly-long line calls the menu_recurse function with -- two arguments: r, and a reference to the top-level menu tell application "System Events" to my menu_click_recurse(r, ((process appName)'s ¬ (menu bar 1)'s (menu bar item topMenu)'s (menu topMenu)))end menu_clickon menu_click_recurse(mList, parentObject) local f, r -- `f` = first item, `r` = rest of items set f to item 1 of mList if mList's length &gt; 1 then set r to (items 2 through (mList's length) of mList) -- either actually click the menu item, or recurse again tell application "System Events" if mList's length is 1 then click parentObject's menu item f else my menu_click_recurse(r, (parentObject's (menu item f)'s (menu f))) end if end tellend menu_click_recurseglobal current_documentglobal current_text_selection-- Get the currently frontmost source code document, and run uncrustify on it but rather than replacing the document, capture the formatted source and use AppleScript to update the document's contents before savingtell application "Xcode" set current_document to last source document set current_document_path to path of current_document set raw_source to quoted form of (text of current_document as Unicode text) set formatted_source to do shell script "echo " &amp; raw_source &amp; " | /usr/local/bin/uncrustify -l OC -q -c ~/.uncrustify.cfg" set text of current_document to formatted_sourceend tell-- I wish there were a better way to do this, but Xcode's indenting is much better than uncrustify's for Objective-C source codetell application "Xcode" to activatemenu_click({"Xcode", "Edit", "Select All"})menu_click({"Xcode", "Editor", "Structure", "Re-Indent"})tell application "Xcode" to save current_document-- Deselect all texttell application "System Events" to keystroke (key code 126)</string>
</dict>
<key>BundleIdentifier</key>
<string>com.apple.Automator.RunScript</string>
@@ -107,7 +107,7 @@ end run</string>
<key>isViewVisible</key>
<true/>
<key>location</key>
- <string>572.500000:761.000000</string>
+ <string>531.500000:832.000000</string>
<key>nibPath</key>
<string>/System/Library/Automator/Run AppleScript.action/Contents/Resources/English.lproj/main.nib</string>
</dict>
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -3,9 +3,9 @@
<plist version="1.0">
<dict>
<key>AMApplicationBuild</key>
- <string>330</string>
+ <string>339.2</string>
<key>AMApplicationVersion</key>
- <string>2.2.1</string>
+ <string>2.2.4</string>
<key>AMDocumentVersion</key>
<string>2</string>
<key>actions</key>
@@ -51,7 +51,7 @@
<key>ActionParameters</key>
<dict>
<key>source</key>
- <string>tell application id "com.apple.dt.Xcode" set current_document to text document 1 whose name ends with (word -1 of (get name of window 1)) save current_document set current_document_path to path of current_document set raw_source to text of current_document set formatted_source to do shell script "/usr/local/bin/uncrustify -c ~/.uncrustify.cfg -l OC -f " &amp; quoted form of current_document_path set text of current_document to formatted_sourceend tell</string>
+ <string>tell application "Xcode" set current_document to last source document set current_document_path to path of current_document set raw_source to quoted form of (text of current_document as Unicode text) set formatted_source to do shell script "echo " &amp; raw_source &amp; " | /usr/local/bin/uncrustify -l OC -q -c ~/.uncrustify.cfg" set text of current_document to formatted_sourceend tell</string>
</dict>
<key>BundleIdentifier</key>
<string>com.apple.Automator.RunScript</string>
@@ -107,7 +107,7 @@ end run</string>
<key>isViewVisible</key>
<true/>
<key>location</key>
- <string>309.500000:554.000000</string>
+ <string>531.500000:832.000000</string>
<key>nibPath</key>
<string>/System/Library/Automator/Run AppleScript.action/Contents/Resources/English.lproj/main.nib</string>
</dict>

0 comments on commit 24c93e9

Please sign in to comment.