From 136c73ea7e0df701be27067ce68cb18e28a43dc1 Mon Sep 17 00:00:00 2001
From: Benjamin Cullen-Kerney <ben.kerney@gmail.com>
Date: Wed, 21 Jul 2010 09:46:35 -0700
Subject: [PATCH] Support for Cocoa Standard AS Dictionary

This provides, among other things, support for moving/resizing windows
via AppleScript, making the app a better OS X citizen in general.
---
 src/MacVim/Info.plist                       |   40 +++------------------------
 src/MacVim/MacVim.sdef                      |    5 +++
 src/MacVim/MacVim.xcodeproj/project.pbxproj |    4 +++
 3 files changed, 13 insertions(+), 36 deletions(-)
 create mode 100644 src/MacVim/MacVim.sdef

diff --git a/src/MacVim/Info.plist b/src/MacVim/Info.plist
index 7008e61..9ee2ee4 100644
--- a/src/MacVim/Info.plist
+++ b/src/MacVim/Info.plist
@@ -4,17 +4,6 @@
 <dict>
 	<key>CFBundleDevelopmentRegion</key>
 	<string>English</string>
-
-	<!-- When adding support for a new file type:
-	     1. Add entry to CFBundleDocumentTypes
-	     2. Add entry to UTExportedTypeDeclarations below (for Quick Look)
-	     3. Add entry to icons/make_icons.py script (for document icon)
-
-	     For a list of UTIs, see
-	     http://developer.apple.com/documentation/Carbon/Conceptual/
-		    understanding_utis/utilist/chapter_4_section_1.html#//
-		    apple_ref/doc/uid/TP40001319-CH205-CHDIJFGJ
-	-->
 	<key>CFBundleDocumentTypes</key>
 	<array>
 		<dict>
@@ -1016,21 +1005,6 @@
 			<key>CFBundleTypeRole</key>
 			<string>Editor</string>
 		</dict>
-        <!--<dict>
-			<key>CFBundleTypeName</key>
-			<string>Property list</string>
-			<key>CFBundleTypeExtensions</key>
-			<array>
-				<string>dict</string>
-				<string>plist</string>
-				<string>scriptSuite</string>
-				<string>scriptTerminology</string>
-			</array>
-			<key>CFBundleTypeIconFile</key>
-			<string>MacVim-plist</string>
-			<key>CFBundleTypeRole</key>
-			<string>Editor</string>
-          </dict>-->
 		<dict>
 			<key>CFBundleTypeName</key>
 			<string>Scheme source</string>
@@ -1224,7 +1198,7 @@
 				<string>NSStringPboardType</string>
 			</array>
 			<key>NSRequiredContext</key>
-			<dict></dict>
+			<dict/>
 		</dict>
 		<dict>
 			<key>NSMenuItem</key>
@@ -1243,21 +1217,15 @@
 			<key>NSUserData</key>
 			<string>Window</string>
 			<key>NSRequiredContext</key>
-			<dict>
-			</dict>
+			<dict/>
 		</dict>
 	</array>
 	<key>SUFeedURL</key>
 	<string>http://bjorn.winckler.googlepages.com/macvim_latest.xml</string>
 	<key>NSAppleScriptEnabled</key>
 	<true/>
-
-	<!-- In order for Quick Look to work we must add entries to
-             UTExportedTypeDeclarations.  When possible a "proper" UTI is used,
-             but in case one could not be found just use "org.vim.*-file".
-	     This array is quite huge and it would be nice to come up with
-	     another way of supporting Quick Look without this.
-	-->
+	<key>OSAScriptingDefinition</key>
+	<string>MacVim.sdef</string>
 	<key>UTExportedTypeDeclarations</key>
 	<array>
 		<dict>
diff --git a/src/MacVim/MacVim.sdef b/src/MacVim/MacVim.sdef
new file mode 100644
index 0000000..d02562a
--- /dev/null
+++ b/src/MacVim/MacVim.sdef
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE dictionary SYSTEM "file://localhost/System/Library/DTDs/sdef.dtd">
+<dictionary xmlns:xi="http://www.w3.org/2003/XInclude">
+  <xi:include href="file:///System/Library/ScriptingDefinitions/CocoaStandard.sdef" xpointer="xpointer(/dictionary/suite)"/>
+</dictionary>
\ No newline at end of file
diff --git a/src/MacVim/MacVim.xcodeproj/project.pbxproj b/src/MacVim/MacVim.xcodeproj/project.pbxproj
index 2331c99..26e06c4 100644
--- a/src/MacVim/MacVim.xcodeproj/project.pbxproj
+++ b/src/MacVim/MacVim.xcodeproj/project.pbxproj
@@ -77,6 +77,7 @@
 		8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */; };
 		8D11072D0486CEB800E47090 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; settings = {ATTRIBUTES = (); }; };
 		8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */; };
+		B59228A611F7572F00E7F584 /* MacVim.sdef in Resources */ = {isa = PBXBuildFile; fileRef = B59228A511F7572F00E7F584 /* MacVim.sdef */; };
 		BD476E300DAAD74400F08A5C /* RBSplitSubview.m in Sources */ = {isa = PBXBuildFile; fileRef = BD476E2C0DAAD74400F08A5C /* RBSplitSubview.m */; };
 		BD476E310DAAD74400F08A5C /* RBSplitView.m in Sources */ = {isa = PBXBuildFile; fileRef = BD476E2E0DAAD74400F08A5C /* RBSplitView.m */; };
 		BD943D530DA3050B00A02D9B /* PlugInImpl.m in Sources */ = {isa = PBXBuildFile; fileRef = BD943D520DA3050B00A02D9B /* PlugInImpl.m */; };
@@ -261,6 +262,7 @@
 		32CA4F630368D1EE00C91783 /* MacVim_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MacVim_Prefix.pch; sourceTree = "<group>"; };
 		8D1107310486CEB800E47090 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
 		8D1107320486CEB800E47090 /* MacVim.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = MacVim.app; sourceTree = BUILT_PRODUCTS_DIR; };
+		B59228A511F7572F00E7F584 /* MacVim.sdef */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.sdef; path = MacVim.sdef; sourceTree = "<group>"; };
 		BD476E2B0DAAD74400F08A5C /* RBSplitSubview.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RBSplitSubview.h; sourceTree = "<group>"; };
 		BD476E2C0DAAD74400F08A5C /* RBSplitSubview.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RBSplitSubview.m; sourceTree = "<group>"; };
 		BD476E2D0DAAD74400F08A5C /* RBSplitView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RBSplitView.h; sourceTree = "<group>"; };
@@ -477,6 +479,7 @@
 		29B97317FDCFA39411CA2CEA /* Resources */ = {
 			isa = PBXGroup;
 			children = (
+				B59228A511F7572F00E7F584 /* MacVim.sdef */,
 				1D384A0D100D671700D3C22F /* KeyBinding.plist */,
 				1D9C602E0EF79C0C0034AD44 /* MacVim.icns */,
 				1D8BEA73104992290069B072 /* FindAndReplace.nib */,
@@ -636,6 +639,7 @@
 				1D8BEA74104992290069B072 /* FindAndReplace.nib in Resources */,
 				1D9C60520EF79C0C0034AD44 /* MacVim.icns in Resources */,
 				1D384A0E100D671700D3C22F /* KeyBinding.plist in Resources */,
+				B59228A611F7572F00E7F584 /* MacVim.sdef in Resources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
-- 
1.7.1

