[prev in list] [next in list] [prev in thread] [next in thread] 

List:       r-devel
Subject:    [Rd] feature request for page() and options()
From:       "Deepayan Sarkar" <deepayan.sarkar () gmail ! com>
Date:       2007-05-31 20:54:44
Message-ID: eb555e660705311354v5648c82fj4c5aca2bf726747f () mail ! gmail ! com
[Download RAW message or body]

Hi,

I have been playing around with a Qt based pager. One of the things I
would like to be able to do is syntax highlighting for R code. This is
mostly relevant with the page function, e.g.

page(ls)

The problem in this case is that the pager has no way of knowing
whether the file it is showing contains R code (e.g. page(,
method="print") need not produce valid R code); the name of the file
is always produced by tempfile("Rpage."), so it looks like
"/tmp/RtmpQfmyH8/Rpage.4a43d33f".

A simple solution is to use an appropriate file extension. Here's a
trivial patch that implements this:

Index: src/library/utils/R/page.R
===================================================================
--- src/library/utils/R/page.R  (revision 41765)
+++ src/library/utils/R/page.R  (working copy)
@@ -19,10 +19,12 @@
     } else {
         subx <- deparse(substitute(x))
     }
-    file <- tempfile("Rpage.")
-    if(match.arg(method) == "dput")
+    if(match.arg(method) == "dput") {
+        file <- sprintf("%s.R", tempfile("Rpage."))
         local.dput(x, file, ...)
+    }
     else {
+        file <- sprintf("%s.txt", tempfile("Rpage."))
         sink(file)
         local.print(x, ...)
         sink()

Unless there is a downside (or a better solution), I would like to see
this feature added.


My second feature request is a bit more involved. options("pager") can
be a function, which is how I have implemented my pager. I would like
options("browser") and options("editor") to behave similarly, i.e. to
have them be settable to functions as well. This seems to allow more
flexibility, be consistent with S philosophy, and there shouldn't be
any incompatibility as the defaults do not change.

This needs changes in a few different places, but if the idea seems
acceptable, I am happy to supply a patch (I have a working
implementation).

-Deepayan

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic