[Geany-devel] R Tags

Lex Trotman elextr at xxxxx
Thu Nov 11 21:45:06 UTC 2010


On 12 November 2010 02:32, Nick Treleaven <nick.treleaven at btinternet.com> wrote:
> On Thu, 11 Nov 2010 09:11:30 +1100
> Lex Trotman <elextr at gmail.com> wrote:
>
>> > However, even if geany -g worked on .R files, the approach would be
>> > difficult to apply in practice. It requires the user to specify .R
>> > files, and given the structure of R packages this could be a quickly
>> > become tedious. It would have been much easier if Geany accepted a
>> > path in which it could recursively scan (and parse) R files. The
>> > rtags() function can do that, so it might make sense to find a
>> > conversion route for etags files.
>> >
>>
>> Whats the structure of R packages?
>>
>> Presuming from the above that it is lot of files in nested directories
>> you could use find to run geany -g on them all.  Whilst that gives you
>> lots of tag files to open, I don't expect it to be too much slower
>> than one huge file.
>>
>> Otherwise patches are welcome.
>
> I'm not sure that reimplementing Unix find is something Geany should be
> doing really. But documenting how to do that in the manual would
> be a good idea.
>
> Supporting CTags format is something on the TODO list.
>
> You can 'see' the format in tagmanager/tm_tag.c in the tm_tag_write()
> function. That is just called repeatedly for each tag entry in the file.

Bah missed it :-)

The R source reveals

write.etags <-
    function(src,
             tokens, startlines, lines, nchars,
             ...,
             shorten.lines = c("token", "simple", "none"))
{
    ## extra 1 for newline
    shorten.lines <- match.arg(shorten.lines)
    offsets <- (cumsum(nchars + 1L) - (nchars + 1L))[startlines]
    lines <-
        switch(shorten.lines,
               none = lines,
               simple = sapply(strsplit(lines, "function", fixed =
TRUE), "[", 1),
               token = mapply(shorten.to.string, lines, tokens))
    tag.lines <-
        paste(sprintf("%s\x7f%s\x01%d,%d",
                      lines, tokens, startlines,
                      as.integer(offsets)),
              collapse = "\n")
    ## simpler format: tag.lines <- paste(sprintf("%s\x7f%d,%d",
lines, startlines, as.integer(offsets)), collapse = "\n")
    tagsize <- nchar(tag.lines, type = "bytes") + 1L
    cat("\x0c\n", src, ",", tagsize, "\n", tag.lines, "\n", sep = "", ...)
}

So someone who reads C and R can write a converter :-)

Cheers
Lex

>
> Nick
> _______________________________________________
> Geany-devel mailing list
> Geany-devel at uvena.de
> http://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel
>



More information about the Devel mailing list