Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: st: Stata and Emacs interactively
From
Bill Rising <[email protected]>
To
[email protected]
Subject
Re: st: Stata and Emacs interactively
Date
Wed, 20 Oct 2010 09:06:29 -0500
On Oct 20, 2010, at 7:31 , Neil Shephard wrote:
> Bit more hunting around suggests that xsel and xclip may be the tools
> for achieving this, see
> http://linuxtidbits.wordpress.com/2008/02/22/command-line-to-clipboard/
> for some details.
Hi all,
Here is a little clarification about my ado-mode.
It can send commands from emacs directly to a GUI version of Stata under Mac OS X and MS Windows. As Uli said, it tries to be smart and detect the start and end of a command when the command runs across many lines. [1]
The method by which it sends commands to Stata is:
Within Emacs (all platforms):
If there is a region selected, it uses the selected region.
Otherwise, it finds the beginning and the end of each command, and makes that region into the selected region.
It strips out all the /* */, //, and ///-style comments, and makes sure that multi-line commands are turned into single-line commands.
It puts the result on the clipboard.
Outside Emacs (platform specific):
It uses a platform-specific script/executable to call Stata to the front and paste the clipboard contents into the Command window.
On the Mac, it uses applescript.
On MS Windows, it uses a compiled Autoit script.
Within Emacs:
Depending on a preference setting, it either leaves Stata as the frontmost application or leaves Emacs as the frontmost application. The latter is useful for having Stata on one monitor and Emacs on the other, using Emacs as a complete substitute for the Command window. [2]
The reasons I have not gotten the middle step working in Unix are twofold:
1. I'm not as versant in Unix as I should be.
2. Stata doesn't listen for input, so it is up to the window manager to put the commands into Stata's Command window. In both Mac OS X and MS Windows, there is only one windows manager, and there are easy tools to use. [3] In Unix, there are many windows managers, so creating the scripts would require good knowledge of every windows manager and its tools.
If there are people out there who could point me to good scripting tools for at least some of the windows managers in Unix, I'd be happy to try to get code passed directly from emacs to Stata. All that is needed is something that can check for the existence of a running GUI Stata, bring it to the foreground, and paste the clipboard into the Command window.
Neil's suggestion seems to be good for interacting with a bash shell in the terminal, but I'm not sure how to get it to talk to the GUI version of Stata.
If anyone has suggestions, I'm all ears.
Cheers,
Bill Rising
[email protected]
[1] The parsing for start and end of commands is good for most all normal situations. It can be fooled by bizarre comments.
[2] ado-mode pastes commands into the Command window by default, so that the Review window gets populated as though the user were working in the Command window itself.
[3] Well, applescript is not easy. Autoit is quite easy.
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/