From richcalaway at revolution-computing.com  Thu Jul 30 00:45:08 2009
From: richcalaway at revolution-computing.com (Richard Calaway)
Date: Wed, 29 Jul 2009 15:45:08 -0700
Subject: [Rd] Oops...a better (working, this time) patch for setRepositories
Message-ID: <31DE65C3-241C-4BE2-A69A-17284C4EDCA3@revolution-computing.com>

My previous suggested patch worked fine for the text-menu case, but  
broke the graphics case; the following one, that moves the definition  
of nc outside of the if...else clauses, works for both:

Index: packages.R
===================================================================
--- packages.R  (revision 49021)
+++ packages.R  (working copy)
@@ -639,7 +639,7 @@
      }

      default <- a[["default"]]
-
+    nc <- length(default)
      if(length(ind)) res <- as.integer(ind)
      else {
          res <- integer(0L)
@@ -654,20 +654,19 @@
                                                     multiple = TRUE,  
"Repositories"),
                               a[, 1L])
          }
-        if(!length(res)) {
+        else {
              ## text-mode fallback
              cat(gettext("--- Please select repositories for use in  
this session ---\n"))
-            nc <- length(default)
              cat("", paste(seq_len(nc), ": ",
                            ifelse(default, "+", " "), " ", a[, 1L],
                            sep=""),
                  "", sep="\n")
-            cat(gettext("Enter one or more numbers separated by spaces 
\n"))
+            cat(gettext("Enter one or more numbers separated by  
spaces, or 0 to cancel\n"))
              res <- scan("", what=0, quiet=TRUE, nlines=1L)
-            if(!length(res) || (length(res) == 1L && !res[1L]))
-                return(invisible())
-            res <- res[1 <= res && res <= nc]
          }
+        if(!length(res) || (length(res) == 1L && !res[1L]))
+            return(invisible())
+        res <- res[1 <= res && res <= nc]
      }
      if(length(res)) {
          repos <- a[["URL"]]

Rich Calaway
Documentation Manager
REvolution Computing, Inc.
richcalaway at revolution-computing.com
206-577-4778 x3204



[Rd] Oops...a better (working, this time) patch for setRepositories
Richard Calaway