Re: do-applescript

[email protected] Thu, 13 Jun 2002 07:50:51 +0100
Newsgroups gmane.emacs.macintosh.user
Organization none
Message-ID <[email protected]>
* [email protected] [2002-06-11 21:10:15]
> [...I couldn't get "do-applescript" to work...]
> Please take a look at this message in the mailing list archive:
>   http://sourceforge.net/mailarchive/forum.php?thread_id=257726&forum_id=5271
> I don't think the patch described in it has been tested and included
> into the CVS code yet.

Thanks for the pointer.  Using the patch below (which is based on
that in the thread you indicated), do-applescript now works for me
just fine.

Could this be committed to CVS ?

> You can probably also use the Lisp function call-process with the
> osascript command.

This also worked, though I preferred to use the internal function.

Index: mac.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/mac.c,v
retrieving revision 1.3
diff -u -r1.3 mac.c
--- mac.c	6 May 2002 06:48:57 -0000	1.3
+++ mac.c	13 Jun 2002 06:48:21 -0000
@@ -2443,6 +2443,9 @@
 
   *result = 0;
 
+  if (!as_scripting_component)
+    initialize_applescript();
+
   error = AECreateDesc (typeChar, script, strlen(script), &script_desc);
   if (error)
     return error;
@@ -2499,10 +2502,10 @@
         }
       HUnlock (result_desc.dataHandle);
 #endif /* not TARGET_API_MAC_CARBON */
+      AEDisposeDesc (&result_desc);    
     }
 
   AEDisposeDesc (&script_desc);
-  AEDisposeDesc (&result_desc);    
 
   return osaerror;
 }
@@ -2527,7 +2530,7 @@
   if (status)
     {
       if (!result)
-        error ("AppleScript error %ld", status);
+        error ("AppleScript error %d", status);
       else
         {
           /* Unfortunately only OSADoScript in do_applescript knows how



_______________________________________________________________

Don't miss the 2002 Sprint PCS Application Developer's Conference
August 25-28 in Las Vegas - http://devcon.sprintpcs.com/adp/index.cfm?source=osdntextlink