Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Greater (user-configurable) flexibility for interaction between TextMate and Stata (suggested by Ben Jann) #6

Open
pschumm opened this issue Mar 24, 2013 · 0 comments

Comments

@pschumm
Copy link

pschumm commented Mar 24, 2013

On May 25, 2011, at 4:39 PM, Ben Jann wrote:

Furthermore, I use a quite different approach for "Do Line/Selection". The reason is that I did not want Stata to change the working directory (which it does if you "tell application ... to open POSIX file ..."). Also, I prefer to use a fixed tempfile because this enables me to run code over and over from Stata by just pressing pageup+enter over and over which is useful to me in some developing contexts. (And also prevents that accidentally undeleted tempfiles will lie about in the system.) (In addition, I added translation from UTF-8, my TextMate default, to macroman, which is expected by Stata.)

STATA_DIR="$HOME/Library/Application Support/Stata"
TMMPFILE="$STATA_DIR/tm-stata0.do"
TMPFILE="$STATA_DIR/tm-stata.do"
if [[ -n "$TM_SELECTED_TEXT" ]]
    then echo "$TM_SELECTED_TEXT" > "$TMMPFILE"
    else echo "$TM_CURRENT_LINE" > "$TMMPFILE"
fi
iconv -f UTF-8 -t MACROMAN "$TMMPFILE" > "$TMPFILE"
rm "$TMMPFILE"
osascript <<-APPLESCRIPT
    local oldClipBoard
    set oldClipBoard to the clipboard
    set the clipboard to "do \"$TMPFILE\""
    try
        tell application "System Events"
            tell application id "com.stata.stata11" to activate
            keystroke "4" using command down
            keystroke "v" using command down
            delay 0.2
            keystroke return
        end tell
    end try
    delay 0.2
    set the clipboard to oldClipBoard
APPLESCRIPT

Ben's workflow is obviously different from mine, though no less legitimate, and there might be others too. I think the first step here is to define what the basic differences are across the different workflows, and then see if we can construct a user-configurable preference for each. Note that Stata's default behavior (i.e., for it's do-file editor) should be easily obtainable through these settings (perhaps even the default), to facilitate moving back-and-forth between the two.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant