[TxMt] Re: Send variable to R app

Hans-Jörg Bibiko bibiko at eva.mpg.de
Fri Apr 4 17:52:24 UTC 2014


Hi Ross,

On 03 Apr 2014, at 21:05, Ross Ahmed <rossahmed at googlemail.com> wrote:

> 
> Lets say I have this code: 
> 
> summary(lm(mpg ~ drat  + hp, mtcars))
> 
> How can select 'mtcars’ and ‘hp’ simultaneously, press a keyboard shortcut and run this code in R app:
> 
> mtcars$hp

unfortunately up to now it would be a stony way to achieve this - due to TM's "alpha" status I think. The point here is that if you have more than one selection the TM variable "TM_SELECTION" holds "only" the information about the line number-start of selection:length of selection. In addition to that - even if all selections are in the SAME line - TM 2.0 doesn't set the TM variable "TM_CURRENT_LINE". This would mean if you want to get the actual content of the selections you have to calculate the contents by yourself. This could be done maybe by:
- set the tmCommand's "Input:" to "Document"
- get the entire document content
- iterate through each selection in "TM_SELECTION" by
- - get line number -> get the content of the line based on the document's content
- - get start and length of your selection
- - get the substring (content) for each selection
- concatenate the selections by "$" to cmd
- send cmd to R.app

Kind regards,
Hans





More information about the textmate mailing list