[Rd] feature request for page() and options()

Deepayan Sarkar deepayan.sarkar at gmail.com
Thu May 31 22:54:44 CEST 2007


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.


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

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."))
         local.print(x, ...)

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


More information about the R-devel mailing list