Hi,

  try calling display on the tree itself, like this:

(kbd-map ("C-8" (display (selection-tree))))


That should give you the raw text.
________________
Miguel de  Benito.


On Thu, Jul 28, 2011 at 00:28, Michael Lachmann <lachm...@eva.mpg.de> wrote:

>
> On 27 Jul 2011, at 11:15PM, Miguel de Benito Delgado wrote:
>
> Hi,
>
>   I'm not sure if it could help, but in a recent post about bookmarks I
> posted some scheme code which lists all tags of a given kind in a document.
> Might this not be used to list all the R input lines? Just a possibility, I
> wouldn't know...
>
>
> Here is my feeble attempt:
>
> (kbd-map ("C-8"
>   (for-each (lambda (item)
>       (display (tree->string (tree-ref item 0))))
>     (selection-tree)
>     )
>   )
>  )
>
> But, it doesn't work. I get an error:
>  In procedure for-each in expression (for-each (lambda # #)
> (selection-tree)):
>  Wrong type argument in position 2: <tree <math|x<rsup|2>> Hello>
>
> Which is kind of funny, since the error statement contains the string I'd
> like to get :) all I want is a string like that:
>
> <tree <math|x<rsup|2>> Hello>
>
> MIchael
>
> P.S. Just a comment. I think there is a bug in the scheme session, in that
> expressions such as "tree->string" are converted to
> "tree-<gtr>string", and then you get an error that that function is not
> defined.
>
>
> ________________
> Miguel de  Benito.
>
>
> On Wed, Jul 27, 2011 at 15:54, Michael Lachmann <lachm...@eva.mpg.de>wrote:
>
>> I managed to do what I asked for, though it is a hack, and currently only
>> works on a mac.
>>
>> Attached is a perl script. It should be saved as convert_pb2R.pl somewhere
>> in the path.
>>
>> Then, add this to my-init-texmacs.scm:
>> (kbd-map ("R R ." (shell "convert_pb2R.pl")
>>          (clipboard-paste "primary")
>>          ))
>>
>> What you can do then is select several input/output cells in an R session
>> (or even several R sessions). Copy them.
>> Then go to the place you want to insert them (for example an empty input
>> cell) and type "RR.". TeXmacs will insert only the R commands in the copied
>> cells.
>>
>> Michael
>>
>>
>> On 27 Jul 2011, at 2:19AM, Michael Lachmann wrote:
>>
>> > I am trying to make it easier to work with R in TeXmacs. What often
>> happens is that in an interactive session I type
>> > in many commands one after the other - each in its own input. at some
>> point everything works, and I'd like to just copy them all into a script, or
>> maybe into one multiline input.
>> >
>> > So, I'd like to be able to select text, and copy just the R part. That
>> would be parts between
>> > <|input>
>> > and
>> > </input>
>> >
>>
>>
>>
>> ---
>> #!/usr/bin/perl
>>
>> open(PB, "pbpaste|") ;
>>
>> $in_section = 0 ;
>> $sec_name = "" ;
>> $section = "" ;
>>
>> $clip = "" ;
>>
>> while( <PB> ) {
>>  $line =~ s/\s*$// ;
>>  $line = $_ ;
>> #  print "line: $line |||\n" ;
>>  if( $line =~ s/[<][|]([^>]*)[>]// ) {
>>    $in_section = 1 ;
>>    $prev_section = $section ;
>>    $section = "" ;
>>  }
>>  if( $line =~ s/[<]\/([^>]*)[>]// ) {
>>    $in_section = 0 ;
>>    if( $1 eq "input" ) {
>>      $clip .= $section ;
>>    }
>>    if( $1 eq "unfolded-io" ) {
>>      $clip .= $prev_section ;
>>    }
>>  }
>>  if( $in_section == 1 ) {
>>    if( !($line =~ /^\s*$/ ) ) {
>>      $line =~ s/^  // ;
>>      $line =~ s/\\ / /g ;
>>      $section = $section .  $line."\n\n" ;
>>    }
>>  }
>> }
>>
>> close(PB) ;
>>
>> open(PB,"|pbcopy") ;
>> print PB $clip ;
>> close(PB) ;
>>
>>
>> ----
>> _______________________________________________
>> Texmacs-dev mailing list
>> Texmacs-dev@gnu.org
>> https://lists.gnu.org/mailman/listinfo/texmacs-dev
>>
>
> _______________________________________________
> Texmacs-dev mailing list
> Texmacs-dev@gnu.org
> https://lists.gnu.org/mailman/listinfo/texmacs-dev
>
>
>
> _______________________________________________
> Texmacs-dev mailing list
> Texmacs-dev@gnu.org
> https://lists.gnu.org/mailman/listinfo/texmacs-dev
>
>
_______________________________________________
Texmacs-dev mailing list
Texmacs-dev@gnu.org
https://lists.gnu.org/mailman/listinfo/texmacs-dev

Reply via email to