aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdrian Robert2008-07-27 19:20:38 +0000
committerAdrian Robert2008-07-27 19:20:38 +0000
commit583ff3c3ba1cfdbf6a7d809a402c5cddc40427da (patch)
tree242f65fcd37e7bf863191677c5587c616f174156
parent9e2a2647758db83b490e2993aa31cd4607305a82 (diff)
downloademacs-583ff3c3ba1cfdbf6a7d809a402c5cddc40427da.tar.gz
emacs-583ff3c3ba1cfdbf6a7d809a402c5cddc40427da.zip
rename do-applescript,do_applescript in keeping with NS code conventions
-rw-r--r--lisp/ChangeLog4
-rw-r--r--lisp/term/ns-win.el3
-rw-r--r--src/ChangeLog5
-rw-r--r--src/nsfns.m176
4 files changed, 100 insertions, 88 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 30680d79a62..9cee8b49b90 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,7 @@
12008-07-27 Adrian Robert <Adrian.B.Robert@gmail.com>
2
3 * term/ns-win.el (do-applescript): New alias in carbon-compat section.
4
12008-07-27 Dan Nicolaescu <dann@ics.uci.edu> 52008-07-27 Dan Nicolaescu <dann@ics.uci.edu>
2 6
3 Remove support for Mac Carbon. 7 Remove support for Mac Carbon.
diff --git a/lisp/term/ns-win.el b/lisp/term/ns-win.el
index 6b332976a4e..bdea472904d 100644
--- a/lisp/term/ns-win.el
+++ b/lisp/term/ns-win.el
@@ -319,6 +319,8 @@ this defaults to \"printenv\"."
319(defvaralias 'mac-control-modifier 'ns-control-modifier) 319(defvaralias 'mac-control-modifier 'ns-control-modifier)
320(defvaralias 'mac-option-modifier 'ns-option-modifier) 320(defvaralias 'mac-option-modifier 'ns-option-modifier)
321(defvaralias 'mac-function-modifier 'ns-function-modifier) 321(defvaralias 'mac-function-modifier 'ns-function-modifier)
322(defalias 'do-applescript 'ns-do-applescript)
323
322 324
323(defvar menu-bar-ns-file-menu) ; below 325(defvar menu-bar-ns-file-menu) ; below
324 326
@@ -328,7 +330,6 @@ this defaults to \"printenv\"."
328 "Toggle Nextstep extended platform support features. 330 "Toggle Nextstep extended platform support features.
329 When this mode is active (no modeline indicator): 331 When this mode is active (no modeline indicator):
330 - File menu is altered slightly in keeping with conventions. 332 - File menu is altered slightly in keeping with conventions.
331 - Meta-up, meta-down are bound to scroll window up and down one line.
332 - Screen position is preserved in scrolling. 333 - Screen position is preserved in scrolling.
333 - Transient mark mode is activated" 334 - Transient mark mode is activated"
334 :init-value nil 335 :init-value nil
diff --git a/src/ChangeLog b/src/ChangeLog
index dff7b738860..49c13b4fdfe 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,8 @@
12008-07-27 Adrian Robert <Adrian.B.Robert@gmail.com>
2
3 * nsfns.m (do-applescript, do_applescript): Rename to
4 ns-do-applescript, ns_do_applescript, and move within file.
5
12008-07-27 Dan Nicolaescu <dann@ics.uci.edu> 62008-07-27 Dan Nicolaescu <dann@ics.uci.edu>
2 7
3 Remove support for Mac Carbon. 8 Remove support for Mac Carbon.
diff --git a/src/nsfns.m b/src/nsfns.m
index b8e28f1d13f..493885f3531 100644
--- a/src/nsfns.m
+++ b/src/nsfns.m
@@ -1999,6 +1999,93 @@ DEFUN ("ns-convert-utf8-nfd-to-nfc", Fns_convert_utf8_nfd_to_nfc,
1999} 1999}
2000 2000
2001 2001
2002#ifdef NS_IMPL_COCOA
2003
2004/* Compile and execute the AppleScript SCRIPT and return the error
2005 status as function value. A zero is returned if compilation and
2006 execution is successful, in which case *RESULT is set to a Lisp
2007 string or a number containing the resulting script value. Otherwise,
2008 1 is returned. */
2009static int
2010ns_do_applescript (script, result)
2011 Lisp_Object script, *result;
2012{
2013 NSAppleEventDescriptor *desc;
2014 NSDictionary* errorDict;
2015 NSAppleEventDescriptor* returnDescriptor = NULL;
2016
2017 NSAppleScript* scriptObject =
2018 [[NSAppleScript alloc] initWithSource:
2019 [NSString stringWithUTF8String: SDATA (script)]];
2020
2021 returnDescriptor = [scriptObject executeAndReturnError: &errorDict];
2022 [scriptObject release];
2023
2024 *result = Qnil;
2025
2026 if (returnDescriptor != NULL)
2027 {
2028 // successful execution
2029 if (kAENullEvent != [returnDescriptor descriptorType])
2030 {
2031 *result = Qt;
2032 // script returned an AppleScript result
2033 if ((typeUnicodeText == [returnDescriptor descriptorType]) ||
2034 (typeUTF16ExternalRepresentation
2035 == [returnDescriptor descriptorType]) ||
2036 (typeUTF8Text == [returnDescriptor descriptorType]) ||
2037 (typeCString == [returnDescriptor descriptorType]))
2038 {
2039 desc = [returnDescriptor coerceToDescriptorType: typeUTF8Text];
2040 if (desc)
2041 *result = build_string([[desc stringValue] UTF8String]);
2042 }
2043 else
2044 {
2045 /* use typeUTF16ExternalRepresentation? */
2046 // coerce the result to the appropriate ObjC type
2047 desc = [returnDescriptor coerceToDescriptorType: typeUTF8Text];
2048 if (desc)
2049 *result = make_number([desc int32Value]);
2050 }
2051 }
2052 }
2053 else
2054 {
2055 // no script result, return error
2056 return 1;
2057 }
2058 return 0;
2059}
2060
2061DEFUN ("ns-do-applescript", Fns_do_applescript, Sns_do_applescript, 1, 1, 0,
2062 doc: /* Execute AppleScript SCRIPT and return the result. If
2063compilation and execution are successful, the resulting script value
2064is returned as a string, a number or, in the case of other constructs,
2065t. In case the execution fails, an error is signaled. */)
2066 (script)
2067 Lisp_Object script;
2068{
2069 Lisp_Object result;
2070 long status;
2071
2072 CHECK_STRING (script);
2073 check_ns ();
2074
2075 BLOCK_INPUT;
2076 status = ns_do_applescript (script, &result);
2077 UNBLOCK_INPUT;
2078 if (status == 0)
2079 return result;
2080 else if (!STRINGP (result))
2081 error ("AppleScript error %d", status);
2082 else
2083 error ("%s", SDATA (result));
2084}
2085#endif
2086
2087
2088
2002/* ========================================================================== 2089/* ==========================================================================
2003 2090
2004 Miscellaneous functions not called through hooks 2091 Miscellaneous functions not called through hooks
@@ -2121,92 +2208,6 @@ x_sync (Lisp_Object frame)
2121 ========================================================================== */ 2208 ========================================================================== */
2122 2209
2123 2210
2124#ifdef NS_IMPL_COCOA
2125
2126/* Compile and execute the AppleScript SCRIPT and return the error
2127 status as function value. A zero is returned if compilation and
2128 execution is successful, in which case *RESULT is set to a Lisp
2129 string or a number containing the resulting script value. Otherwise,
2130 1 is returned. */
2131
2132static int
2133do_applescript (script, result)
2134 Lisp_Object script, *result;
2135{
2136 NSAppleEventDescriptor *desc;
2137 NSDictionary* errorDict;
2138 NSAppleEventDescriptor* returnDescriptor = NULL;
2139
2140 NSAppleScript* scriptObject =
2141 [[NSAppleScript alloc] initWithSource:
2142 [NSString stringWithUTF8String: SDATA (script)]];
2143
2144 returnDescriptor = [scriptObject executeAndReturnError: &errorDict];
2145 [scriptObject release];
2146
2147 *result = Qnil;
2148
2149 if (returnDescriptor != NULL)
2150 {
2151 // successful execution
2152 if (kAENullEvent != [returnDescriptor descriptorType])
2153 {
2154 *result = Qt;
2155 // script returned an AppleScript result
2156 if ((typeUnicodeText == [returnDescriptor descriptorType]) ||
2157 (typeUTF16ExternalRepresentation
2158 == [returnDescriptor descriptorType]) ||
2159 (typeUTF8Text == [returnDescriptor descriptorType]) ||
2160 (typeCString == [returnDescriptor descriptorType]))
2161 {
2162 desc = [returnDescriptor coerceToDescriptorType: typeUTF8Text];
2163 if (desc)
2164 *result = build_string([[desc stringValue] UTF8String]);
2165 }
2166 else
2167 {
2168 /* use typeUTF16ExternalRepresentation? */
2169 // coerce the result to the appropriate ObjC type
2170 desc = [returnDescriptor coerceToDescriptorType: typeUTF8Text];
2171 if (desc)
2172 *result = make_number([desc int32Value]);
2173 }
2174 }
2175 }
2176 else
2177 {
2178 // no script result, return error
2179 return 1;
2180 }
2181 return 0;
2182}
2183
2184DEFUN ("do-applescript", Fdo_applescript, Sdo_applescript, 1, 1, 0,
2185 doc: /* Execute AppleScript SCRIPT and return the result. If
2186compilation and execution are successful, the resulting script value
2187is returned as a string, a number or, in the case of other constructs,
2188t. In case the execution fails, an error is signaled. */)
2189 (script)
2190 Lisp_Object script;
2191{
2192 Lisp_Object result;
2193 long status;
2194
2195 CHECK_STRING (script);
2196 check_ns ();
2197
2198 BLOCK_INPUT;
2199 status = do_applescript (script, &result);
2200 UNBLOCK_INPUT;
2201 if (status == 0)
2202 return result;
2203 else if (!STRINGP (result))
2204 error ("AppleScript error %d", status);
2205 else
2206 error ("%s", SDATA (result));
2207}
2208#endif
2209
2210DEFUN ("xw-color-defined-p", Fxw_color_defined_p, Sxw_color_defined_p, 1, 2, 0, 2211DEFUN ("xw-color-defined-p", Fxw_color_defined_p, Sxw_color_defined_p, 1, 2, 0,
2211 doc: /* Return t if the current Nextstep display supports the color COLOR. 2212 doc: /* Return t if the current Nextstep display supports the color COLOR.
2212The optional argument FRAME is currently ignored. */) 2213The optional argument FRAME is currently ignored. */)
@@ -2313,6 +2314,7 @@ If omitted or nil, that stands for the selected frame's display. */)
2313 return make_number ((int) [ns_get_screen (display) frame].size.height); 2314 return make_number ((int) [ns_get_screen (display) frame].size.height);
2314} 2315}
2315 2316
2317
2316DEFUN ("display-usable-bounds", Fns_display_usable_bounds, 2318DEFUN ("display-usable-bounds", Fns_display_usable_bounds,
2317 Sns_display_usable_bounds, 0, 1, 0, 2319 Sns_display_usable_bounds, 0, 1, 0,
2318 doc: /*Return the bounds of the usable part of the screen. 2320 doc: /*Return the bounds of the usable part of the screen.
@@ -2639,7 +2641,7 @@ be used as the image of the icon representing the frame. */);
2639 defsubr (&Sns_font_name); 2641 defsubr (&Sns_font_name);
2640 defsubr (&Sns_list_colors); 2642 defsubr (&Sns_list_colors);
2641#ifdef NS_IMPL_COCOA 2643#ifdef NS_IMPL_COCOA
2642 defsubr (&Sdo_applescript); 2644 defsubr (&Sns_do_applescript);
2643#endif 2645#endif
2644 defsubr (&Sxw_color_defined_p); 2646 defsubr (&Sxw_color_defined_p);
2645 defsubr (&Sxw_color_values); 2647 defsubr (&Sxw_color_values);