rename do-applescript,do_applescript in keeping with NS code conventions
authorAdrian Robert <Adrian.B.Robert@gmail.com>
Sun, 27 Jul 2008 19:20:38 +0000 (19:20 +0000)
committerAdrian Robert <Adrian.B.Robert@gmail.com>
Sun, 27 Jul 2008 19:20:38 +0000 (19:20 +0000)
lisp/ChangeLog
lisp/term/ns-win.el
src/ChangeLog
src/nsfns.m

index 30680d7..9cee8b4 100644 (file)
@@ -1,3 +1,7 @@
+2008-07-27  Adrian Robert  <Adrian.B.Robert@gmail.com>
+
+       * term/ns-win.el (do-applescript): New alias in carbon-compat section.
+
 2008-07-27  Dan Nicolaescu  <dann@ics.uci.edu>
 
        Remove support for Mac Carbon.
index 6b33297..bdea472 100644 (file)
@@ -319,6 +319,8 @@ this defaults to \"printenv\"."
 (defvaralias 'mac-control-modifier 'ns-control-modifier)
 (defvaralias 'mac-option-modifier 'ns-option-modifier)
 (defvaralias 'mac-function-modifier 'ns-function-modifier)
+(defalias 'do-applescript 'ns-do-applescript)
+
 
 (defvar menu-bar-ns-file-menu)         ; below
 
@@ -328,7 +330,6 @@ this defaults to \"printenv\"."
   "Toggle Nextstep extended platform support features.
    When this mode is active (no modeline indicator):
    - File menu is altered slightly in keeping with conventions.
-   - Meta-up, meta-down are bound to scroll window up and down one line.
    - Screen position is preserved in scrolling.
    - Transient mark mode is activated"
   :init-value nil
index dff7b73..49c13b4 100644 (file)
@@ -1,3 +1,8 @@
+2008-07-27  Adrian Robert  <Adrian.B.Robert@gmail.com>
+
+       * nsfns.m (do-applescript, do_applescript): Rename to
+       ns-do-applescript, ns_do_applescript, and move within file.
+
 2008-07-27  Dan Nicolaescu  <dann@ics.uci.edu>
 
        Remove support for Mac Carbon.
index b8e28f1..493885f 100644 (file)
@@ -1999,6 +1999,93 @@ DEFUN ("ns-convert-utf8-nfd-to-nfc", Fns_convert_utf8_nfd_to_nfc,
 }
 
 
+#ifdef NS_IMPL_COCOA
+
+/* Compile and execute the AppleScript SCRIPT and return the error
+   status as function value.  A zero is returned if compilation and
+   execution is successful, in which case *RESULT is set to a Lisp
+   string or a number containing the resulting script value.  Otherwise,
+   1 is returned. */
+static int
+ns_do_applescript (script, result)
+     Lisp_Object script, *result;
+{
+  NSAppleEventDescriptor *desc;
+  NSDictionary* errorDict;
+  NSAppleEventDescriptor* returnDescriptor = NULL;
+
+  NSAppleScript* scriptObject =
+    [[NSAppleScript alloc] initWithSource:
+                            [NSString stringWithUTF8String: SDATA (script)]];
+
+  returnDescriptor = [scriptObject executeAndReturnError: &errorDict];
+  [scriptObject release];
+  
+  *result = Qnil;
+  
+  if (returnDescriptor != NULL)
+    {
+      // successful execution
+      if (kAENullEvent != [returnDescriptor descriptorType])
+        {
+         *result = Qt;
+         // script returned an AppleScript result
+         if ((typeUnicodeText == [returnDescriptor descriptorType]) ||
+             (typeUTF16ExternalRepresentation 
+              == [returnDescriptor descriptorType]) ||
+             (typeUTF8Text == [returnDescriptor descriptorType]) ||
+             (typeCString == [returnDescriptor descriptorType]))
+           {
+             desc = [returnDescriptor coerceToDescriptorType: typeUTF8Text];
+             if (desc)
+               *result = build_string([[desc stringValue] UTF8String]);
+           }
+         else
+            {
+             /* use typeUTF16ExternalRepresentation? */
+             // coerce the result to the appropriate ObjC type
+             desc = [returnDescriptor coerceToDescriptorType: typeUTF8Text];
+             if (desc)
+               *result = make_number([desc int32Value]);
+            }
+        }
+    }
+  else
+    {
+      // no script result, return error
+      return 1;
+    }
+  return 0;
+}
+
+DEFUN ("ns-do-applescript", Fns_do_applescript, Sns_do_applescript, 1, 1, 0,
+       doc: /* Execute AppleScript SCRIPT and return the result.  If
+compilation and execution are successful, the resulting script value
+is returned as a string, a number or, in the case of other constructs,
+t.  In case the execution fails, an error is signaled. */)
+    (script)
+    Lisp_Object script;
+{
+  Lisp_Object result;
+  long status;
+
+  CHECK_STRING (script);
+  check_ns ();
+
+  BLOCK_INPUT;
+  status = ns_do_applescript (script, &result);
+  UNBLOCK_INPUT;
+  if (status == 0)
+    return result;
+  else if (!STRINGP (result))
+    error ("AppleScript error %d", status);
+  else
+    error ("%s", SDATA (result));
+}
+#endif
+
+
+
 /* ==========================================================================
 
     Miscellaneous functions not called through hooks
@@ -2121,92 +2208,6 @@ x_sync (Lisp_Object frame)
    ========================================================================== */
 
 
-#ifdef NS_IMPL_COCOA
-
-/* Compile and execute the AppleScript SCRIPT and return the error
-   status as function value.  A zero is returned if compilation and
-   execution is successful, in which case *RESULT is set to a Lisp
-   string or a number containing the resulting script value.  Otherwise,
-   1 is returned. */
-
-static int
-do_applescript (script, result)
-     Lisp_Object script, *result;
-{
-  NSAppleEventDescriptor *desc;
-  NSDictionary* errorDict;
-  NSAppleEventDescriptor* returnDescriptor = NULL;
-
-  NSAppleScript* scriptObject =
-    [[NSAppleScript alloc] initWithSource:
-                            [NSString stringWithUTF8String: SDATA (script)]];
-
-  returnDescriptor = [scriptObject executeAndReturnError: &errorDict];
-  [scriptObject release];
-  
-  *result = Qnil;
-  
-  if (returnDescriptor != NULL)
-    {
-      // successful execution
-      if (kAENullEvent != [returnDescriptor descriptorType])
-        {
-         *result = Qt;
-         // script returned an AppleScript result
-         if ((typeUnicodeText == [returnDescriptor descriptorType]) ||
-             (typeUTF16ExternalRepresentation 
-              == [returnDescriptor descriptorType]) ||
-             (typeUTF8Text == [returnDescriptor descriptorType]) ||
-             (typeCString == [returnDescriptor descriptorType]))
-           {
-             desc = [returnDescriptor coerceToDescriptorType: typeUTF8Text];
-             if (desc)
-               *result = build_string([[desc stringValue] UTF8String]);
-           }
-         else
-            {
-             /* use typeUTF16ExternalRepresentation? */
-             // coerce the result to the appropriate ObjC type
-             desc = [returnDescriptor coerceToDescriptorType: typeUTF8Text];
-             if (desc)
-               *result = make_number([desc int32Value]);
-            }
-        }
-    }
-  else
-    {
-      // no script result, return error
-      return 1;
-    }
-  return 0;
-}
-
-DEFUN ("do-applescript", Fdo_applescript, Sdo_applescript, 1, 1, 0,
-       doc: /* Execute AppleScript SCRIPT and return the result.  If
-compilation and execution are successful, the resulting script value
-is returned as a string, a number or, in the case of other constructs,
-t.  In case the execution fails, an error is signaled. */)
-    (script)
-    Lisp_Object script;
-{
-  Lisp_Object result;
-  long status;
-
-  CHECK_STRING (script);
-  check_ns ();
-
-  BLOCK_INPUT;
-  status = do_applescript (script, &result);
-  UNBLOCK_INPUT;
-  if (status == 0)
-    return result;
-  else if (!STRINGP (result))
-    error ("AppleScript error %d", status);
-  else
-    error ("%s", SDATA (result));
-}
-#endif
-
 DEFUN ("xw-color-defined-p", Fxw_color_defined_p, Sxw_color_defined_p, 1, 2, 0,
        doc: /* Return t if the current Nextstep display supports the color COLOR.
 The optional argument FRAME is currently ignored.  */)
@@ -2313,6 +2314,7 @@ If omitted or nil, that stands for the selected frame's display.  */)
   return make_number ((int) [ns_get_screen (display) frame].size.height);
 }
 
+
 DEFUN ("display-usable-bounds", Fns_display_usable_bounds,
        Sns_display_usable_bounds, 0, 1, 0,
        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.  */);
   defsubr (&Sns_font_name);
   defsubr (&Sns_list_colors);
 #ifdef NS_IMPL_COCOA
-  defsubr (&Sdo_applescript);
+  defsubr (&Sns_do_applescript);
 #endif
   defsubr (&Sxw_color_defined_p);
   defsubr (&Sxw_color_values);