[OS X Emacs] Aquamacs and applescript

Daniel Stegmueller d.stegmueller at gmail.com
Tue May 13 07:33:37 EDT 2008


thanks a lot!

Of course this is nothing compared to the level of integration I have  
using R and ESS.
But there are some things I am only able to do in Stata right now, so  
I am glad I do not have to leave ESS for that...


Am May 13, 2008 um 12:46 PM schrieb David Reitter:

> On 13 May 2008, at 10:01, Daniel Stegmueller wrote:
>> Hello List,
>> I have a function using applescript to copy marked parts of a file  
>> into an external application.  It worked with (Carbon) Emacs but  
>> does not work with Aquamacs.
>> Is there an obvious error that I am missing?
> Yes, your code is buggy.
> The code relies on `copy-region-as-kill' to copy text into the  
> system-wide pasteboard, which it only does if certain other  
> conditions are true.
> The code below should do what you want.
> I don't have Stata (I'm an R person), so I couldn't test the whole  
> thing.
> - Dave
> --
> http://aquamacs.org -- Aquamacs: Emacs on Mac OS X
> http://aquamacs.org/donate -- Could we help you? Return the favor  
> and support the Aquamacs Project!
> (defun ado-send-region-to-Stata ()
>  (interactive)
>  (clipboard-kill-ring-save (point) (mark))
>  (do-applescript "try \r tell application \"Finder\" \r set  
> theDummyDo to (((path to desktop folder) as text) & \".eraseme.do\")  
> \r set theContents to the clipboard \r if not (the last character of  
> theContents = return) then \r set theContents to theContents &  
> return \r end if \r end tell \r try \r set the open_target_file to  
> open for access file theDummyDo with write permission \r set eof of  
> the open_target_file to 0 \r write theContents to the  
> open_target_file starting at eof \r close access the  
> open_target_file \r on error \r try \r close access file theDummyDo  
> \r end try \r end try \r tell application \"StataSE\" \r activate \r  
> open file theDummyDo \r end tell \r on error error_message number  
> error_number \r return \"Error: \" & error_number & \". \" &  
> error_message & return \r end try"))

Daniel Stegmueller
Landgrafenstr. 14, App.45
60486 Frankfurt a.M.
d.stegmueller at gmail.com

More information about the MacOSX-Emacs mailing list