[TxMt] textmate and R.app again
    Kevin Owens 
    kevin.j.owens at gmail.com
       
    Thu Feb  6 02:50:30 UTC 2014
    
    
  
I'm still having some trouble with the R bundle.
I'm getting, what to me is unexpected behavior, from the command that 
says "Send Selection/Line to" and in the sub-menu says "R.app & Step" 
(this is the one that has the default key binding of option+shift+enter. 
Here is the code in my bundle:
    #!/usr/bin/env bash
    [[ -f "${TM_SUPPORT_PATH}/lib/bash_init.sh" ]] && .
    "${TM_SUPPORT_PATH}/lib/bash_init.sh"
    # input is selection or document
    rawText="`cat`"
    curDir=''
    if [[ ${#TM_DIRECTORY} -gt 0 ]]; then
         curDir="$TM_DIRECTORY"
    fi
    osascript -e 'on run(theCode)' \
               -e 'tell application "R" to activate' \
               -e 'if (item 2 of theCode) is not "" then tell
    application "R" to cmd "setwd('\''" & (item 2 of theCode) & "'\'')"' \
               -e 'tell application "R" to cmd (item 1 of theCode)' \
               -e 'end run' -- "$rawText" "$curDir"
    if [ "$TM_LINE_NUMBER" != "" ]; then
         open  "${TM_MATE:-$TM_SUPPORT_PATH/bin/mate} -l
    ?line?&column=1000000" &
    elif [[ $TM_SELECTION =~ [1-9][0-9]*:?[0-9]*-([1-9][0-9]*):?[0-9]*
    ]]; then
          # Regular Selection
         open "txmt://open?line=$((${BASH_REMATCH[1]}+1))&column=1000000" &
    elif [[ $TM_SELECTION =~ [1-9][0-9]*:?[0-9]*x([1-9][0-9]*):?[0-9]*
    ]]; then
         # Block (option) selection
         open "txmt://open?line=$((${BASH_REMATCH[1]}+1))&column=1000000" &
    else
         open "txmt://open"
    fi
If I don't have anything selected, i.e. just send the line, it will send 
the line to R.app, but then retain focus on R.app. If I run it on a 
selection it does the same thing, but also opens Textmate 1. I'd like it 
to not open Textmate 1, and to return focus to the original window/tab 
after the line or selection has been sent.
The command that says ""Send Selection/Document to" in the sub-menu 
R.app (default keybinding command+option+shift+R) also sends focus to R.app.
I would appreciate if someone could show me how to change the code to 
send focus back to Textmate2, that is my biggest complaint. I really 
like the package in Textmate 1. The few times I've considered going to 
Emacs+ESS I've always given up because Textmate can do everything I 
want. I want to move to Textmate2, but at least for this bundle, it 
seems like a step backwards. I don't mean to sound like a downer, I do 
appreciate the program.
Thank you,
Kevin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macromates.com/textmate/attachments/20140205/13a4e0cf/attachment.html>
    
    
More information about the textmate
mailing list