[Distr-commits] r562 - branches/distr-2.2/pkg/SweaveListingUtils branches/distr-2.2/pkg/SweaveListingUtils/R branches/distr-2.2/pkg/SweaveListingUtils/chm branches/distr-2.2/pkg/SweaveListingUtils/inst branches/distr-2.2/pkg/SweaveListingUtils/inst/doc branches/distr-2.2/pkg/SweaveListingUtils/man branches/distr-2.2/pkg/distr/inst branches/distr-2.2/pkg/distrDoc/inst branches/distr-2.2/pkg/distrEllipse/inst branches/distr-2.2/pkg/distrEx/inst branches/distr-2.2/pkg/distrMod/inst branches/distr-2.2/pkg/distrSim/inst branches/distr-2.2/pkg/distrTEst/inst branches/distr-2.2/pkg/distrTeach/inst branches/distr-2.2/pkg/startupmsg/inst branches/distr-2.2/pkg/utils pkg/SweaveListingUtils pkg/SweaveListingUtils/R pkg/SweaveListingUtils/inst pkg/SweaveListingUtils/inst/doc pkg/SweaveListingUtils/man pkg/distr/inst pkg/distrDoc/inst pkg/distrEllipse/inst pkg/distrEx/inst pkg/distrMod/inst pkg/distrSim/inst pkg/distrTEst/inst pkg/distrTeach/inst pkg/startupmsg/inst

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Sep 4 01:07:38 CEST 2009


Author: ruckdeschel
Date: 2009-09-04 01:07:35 +0200 (Fri, 04 Sep 2009)
New Revision: 562

Added:
   branches/distr-2.2/pkg/SweaveListingUtils/R/lstset.R
   branches/distr-2.2/pkg/SweaveListingUtils/R/taglist.R
   branches/distr-2.2/pkg/SweaveListingUtils/inst/TOBEDONE
   branches/distr-2.2/pkg/distr/inst/TOBEDONE
   branches/distr-2.2/pkg/distrDoc/inst/TOBEDONE
   branches/distr-2.2/pkg/distrEllipse/inst/TOBEDONE
   branches/distr-2.2/pkg/distrEx/inst/TOBEDONE
   branches/distr-2.2/pkg/distrMod/inst/TOBEDONE
   branches/distr-2.2/pkg/distrSim/inst/TOBEDONE
   branches/distr-2.2/pkg/distrTEst/inst/TOBEDONE
   branches/distr-2.2/pkg/distrTeach/inst/TOBEDONE
   branches/distr-2.2/pkg/startupmsg/inst/TOBEDONE
   branches/distr-2.2/pkg/utils/readsvnlog.sh
   branches/distr-2.2/pkg/utils/tobedonePaste.R
   pkg/SweaveListingUtils/R/lstset.R
   pkg/SweaveListingUtils/R/taglist.R
   pkg/SweaveListingUtils/inst/TOBEDONE
   pkg/distr/inst/TOBEDONE
   pkg/distrDoc/inst/TOBEDONE
   pkg/distrEllipse/inst/TOBEDONE
   pkg/distrEx/inst/TOBEDONE
   pkg/distrMod/inst/TOBEDONE
   pkg/distrSim/inst/TOBEDONE
   pkg/distrTEst/inst/TOBEDONE
   pkg/distrTeach/inst/TOBEDONE
   pkg/startupmsg/inst/TOBEDONE
Modified:
   branches/distr-2.2/pkg/SweaveListingUtils/NAMESPACE
   branches/distr-2.2/pkg/SweaveListingUtils/R/SweaveListingOptions.R
   branches/distr-2.2/pkg/SweaveListingUtils/R/SweaveListingUtils.R
   branches/distr-2.2/pkg/SweaveListingUtils/R/keywordsStyle.R
   branches/distr-2.2/pkg/SweaveListingUtils/chm/00Index.html
   branches/distr-2.2/pkg/SweaveListingUtils/chm/0SweaveListingUtils-package.html
   branches/distr-2.2/pkg/SweaveListingUtils/chm/SweaveListingUtils.chm
   branches/distr-2.2/pkg/SweaveListingUtils/chm/SweaveListingUtils.toc
   branches/distr-2.2/pkg/SweaveListingUtils/chm/lstset.html
   branches/distr-2.2/pkg/SweaveListingUtils/inst/doc/ExampleSweaveListingUtils.Rnw
   branches/distr-2.2/pkg/SweaveListingUtils/man/lstset.Rd
   pkg/SweaveListingUtils/DESCRIPTION
   pkg/SweaveListingUtils/NAMESPACE
   pkg/SweaveListingUtils/R/SweaveListingOptions.R
   pkg/SweaveListingUtils/R/SweaveListingUtils.R
   pkg/SweaveListingUtils/R/keywordsStyle.R
   pkg/SweaveListingUtils/inst/doc/ExampleSweaveListingUtils.Rnw
   pkg/SweaveListingUtils/man/lstset.Rd
Log:
++ added TOBEDONE (sic!) files for each package (by accident also in trunc; these are empty so far)
++ new utils: readsvnlog.sh -- a bash-shell script for reading out svn logs, 
   and more important: in tobedonePaste.R: 
   + showAllFiles : concatenates all files of same kind in one output (like NEWS, TOBEDONE)
   + showsvnlog   : reads out svn log information / works with bash shell 
                   (@Matthias: pls check Linux!) 
++ SweaveListingUtils 
 + a little enhanced; makes temporarily changes (like background color) easier...
 +-> new functions lstdefRstyle to change Rstyle
                  lstsetRall to change all R-like styles (i.e. Rstyle, Rinstyle, Routstyle, Rcodestyle)
 +-> in lstset.R: new internal functions to standardize behavior and make maintenance easier (start with ".") 
 +-> with lstdefRstyle Rstyle is no longer only changed after require(), library() -> rename .numberofRequires to .numberofRstyleDefs
 +-> moved parts of former SweaveListingUtils.R to taglist.R and lstset.R
 +href inserted for my mail address (otherwise some wrong link was produced; remarked by A. Hausmann)


Modified: branches/distr-2.2/pkg/SweaveListingUtils/NAMESPACE
===================================================================
--- branches/distr-2.2/pkg/SweaveListingUtils/NAMESPACE	2009-09-01 23:44:19 UTC (rev 561)
+++ branches/distr-2.2/pkg/SweaveListingUtils/NAMESPACE	2009-09-03 23:07:35 UTC (rev 562)
@@ -1,6 +1,7 @@
 import("startupmsg")
 export("taglist", "lstset", "lstsetR", "lstsetRd",
        "lstsetRin", "lstsetRout", "lstsetRcode", 
+       "lstdefRstyle", "lstsetRall",
        "SweaveListingPreparations", "readSourceFromRForge",
        "copySourceFromRForge", "lstinputSourceFromRForge", 
        "readPkgVersion",  "SweaveListingOptions",

Modified: branches/distr-2.2/pkg/SweaveListingUtils/R/SweaveListingOptions.R
===================================================================
--- branches/distr-2.2/pkg/SweaveListingUtils/R/SweaveListingOptions.R	2009-09-01 23:44:19 UTC (rev 561)
+++ branches/distr-2.2/pkg/SweaveListingUtils/R/SweaveListingOptions.R	2009-09-03 23:07:35 UTC (rev 562)
@@ -3,7 +3,7 @@
 .CacheFiles <- NULL
 .alreadyDefinedPkgs <- NULL
 .tobeDefinedPkgs <- NULL
-.numberofRequires <- NULL
+.numberofRstyleDefs <- NULL
 
 .SweaveListingOptions <- list(
 Rset = list("fancyvrb" = "true", "escapechar" = "`",

Modified: branches/distr-2.2/pkg/SweaveListingUtils/R/SweaveListingUtils.R
===================================================================
--- branches/distr-2.2/pkg/SweaveListingUtils/R/SweaveListingUtils.R	2009-09-01 23:44:19 UTC (rev 561)
+++ branches/distr-2.2/pkg/SweaveListingUtils/R/SweaveListingUtils.R	2009-09-03 23:07:35 UTC (rev 562)
@@ -13,7 +13,7 @@
 
      unlockBinding(".keywordsR", asNamespace("SweaveListingUtils"))
      unlockBinding(".alreadyDefinedPkgs", asNamespace("SweaveListingUtils"))
-     unlockBinding(".numberofRequires", asNamespace("SweaveListingUtils"))
+     unlockBinding(".numberofRstyleDefs", asNamespace("SweaveListingUtils"))
      unlockBinding(".tobeDefinedPkgs", asNamespace("SweaveListingUtils"))
      unlockBinding(".CacheFiles", asNamespace("SweaveListingUtils"))
      unlockBinding(".CacheLength", asNamespace("SweaveListingUtils"))
@@ -41,306 +41,183 @@
 }
 
 
-print.taglist <- function(x, LineLength = getOption("width"), offset.start = 0,
-                          withFinalLineBreak = TRUE, first.print = NULL,
-                          ErrorOrWarn = "warn", ...){
-   xc <- as.character(deparse(substitute(x)))
-   ll <- length(x)
-   LineL <- max(LineLength-2,0)
-   LineBreak <- NULL
-   mi50 <- min(LineLength,50)
-   maL <- max(3*LineLength,getOption("width"))
-   if(ll){
-      offS <- paste(rep(" ", offset.start), collapse = "")
-      for(i in 1:ll){
-          trystr0 <- paste(names(x[i]),x[[i]],sep = "=")
-          if(i==1){
-            actstr <-  trystr  <- trystr0
-            trystr0 <- NULL
-            if(length(first.print))
-               cat(first.print)                 
-          }else{
-             trystr  <- paste(actstr, trystr0, sep = ",")
-          }
 
-          ntry <- nchar(trystr) + offset.start
-          if (ntry < LineL){
-              actstr <- trystr
-          }else{
-              WarnOrErrorFct <- if(pmatch(tolower(ErrorOrWarn),
-                                   c("warn","error"))==1)
-                                   warning else stop
-              if(ntry > maL) WarnOrErrorFct(gettextf(
-                      "Some elements of %s are too long", 
-                       if(nchar(xc)> mi50) paste(substr(xc,1,mi50),"...") else
-                                xc))
-              if(actstr!=offS) cat(LineBreak, actstr,",%",sep="")
-              LineBreak <- "\n"
-              actstr <- paste(offS, trystr0, sep = "")
-          }
-      }
-      if(nzchar(actstr)) {
-         if(i>1) cat("\n")
-         cat(actstr, sep="")
-         if(withFinalLineBreak) cat("\n")
-      }
-   }
-   return(invisible())
-}
+#------------------------------------------------------------------------------
+# SweaveListingPreparations
+#------------------------------------------------------------------------------
 
-taglist <- function(..., list = NULL, defname = "V"){
-  dots <-  c(list,match.call(call = sys.call(),
-                       expand.dots = FALSE)$"...")
-  ldots <- length(dots)
-  if(ldots){
-     defname <- unique(defname)
-     defnames <- if(length(defname)<ldots){
-            paste(rep(defname,length.out=ldots), 1:ldots, sep = "")} else defname
-     nms <- names(dots)
-     if(is.null(nms)) nms <- rep("", ldots)
-     nms[ nms == "" ] <- defnames[nms == ""]
-     names(dots) <- nms
-     return(structure(as.list(dots), class = c("taglist","list")))
-  }
-  return(invisible())
-}
+SweaveListingPreparations <- function(
+      withOwnFileSection = FALSE,
+      withVerbatim = FALSE,
+      withSchunkDef = TRUE,
+      gin = TRUE,
+      ae = TRUE,
+      LineLength = getOption("width"),
+      Rset = getSweaveListingOption("Rset"),
+      Rdset = getSweaveListingOption("Rdset"),
+      Rin = getSweaveListingOption("Rin"),
+      Rout = getSweaveListingOption("Rout"),
+      Rcode = getSweaveListingOption("Rcode"),
+      Rcolor = getSweaveListingOption("Rcolor"),
+      RRecomdcolor = getSweaveListingOption("RRecomdcolor"),
+      Rbcolor = getSweaveListingOption("Rbcolor"),
+      Routcolor = getSweaveListingOption("Routcolor"),
+      Rcommentcolor = getSweaveListingOption("Rcommentcolor"),
+      pkg = getSweaveListingOption("pkg"),
+      pkv = getSweaveListingOption("pkv"),
+      fileCommand = getSweaveListingOption("fileCommand"),
+      pkgCommand = getSweaveListingOption("pkgCommand"),
+      lib.loc = NULL){
 
-lstset <- function(taglist, LineLength = getOption("width"), startS = "\\lstset{"){
-   print(taglist, LineLength = LineLength, offset.start = nchar(startS),
-         withFinalLineBreak = FALSE, first.print = startS)
-   cat("}%\n")
-   return(invisible())
-}
+### begin of code to SweaveListingPreparations
 
-lstsetR <- function(Rset = NULL, LineLength = getOption("width"),
-                    add = getSweaveListingOption("addRset"), startS = "\\lstset{"){
-   if(add){
-       Rset0 <- getSweaveListingOption("Rset")
-       if(length(Rset)){
-          newnms <- names(Rset)
-          oldnms <- names(Rset0)
-          ooldnms <- oldnms[! (oldnms %in% newnms)]
-          Rset <- c(Rset, Rset0[ooldnms]) 
-       }else Rset <- Rset0   
-   }
-   if(!is(Rset, "taglist")) Rset <- taglist(list=Rset)
-   lstset(Rset, LineLength = LineLength, startS = startS)
-   return(invisible())
-}
+   sws <- .SweaveListingOptions
+   sws$inSweave <- TRUE
+   assignInNamespace(".SweaveListingOptions", sws, "SweaveListingUtils")
 
-lstsetRd <- function(Rdset = NULL, LineLength = getOption("width"),
-                    add = getSweaveListingOption("addRdset"), startS = "\\lstset{"){
-   if(add){
-       Rdset0 <- getSweaveListingOption("Rdset")
-       if(length(Rdset)){
-          newnms <- names(Rdset)
-          oldnms <- names(Rdset0)
-          ooldnms <- oldnms[! (oldnms %in% newnms)]
-          Rdset <- c(Rdset, Rdset0[ooldnms]) 
-       }else Rdset <- Rdset0   
-   }
-   if(!is(Rdset, "taglist")) Rdset <- taglist(list=Rdset)
-   lstset(Rdset, LineLength = LineLength, startS = startS)
-   return(invisible())
-}
+   withVerbatim <- rep(withVerbatim, length.out=3)
+   if(is.null(names(withVerbatim)))
+      names(withVerbatim) <- c("Sinput", "Soutput", "Scode")
 
-lstsetRin <- function(Rinset = NULL, LineLength = getOption("width"),
-                    add = getSweaveListingOption("addRinset"),
-                    startS = "\\lstdefinestyle{Rinstyle}{"){
-   if(add){
-       Rinset0 <- getSweaveListingOption("Rin")
-       if(length(Rinset)){
-          newnms <- names(Rinset)
-          oldnms <- names(Rinset0)
-          ooldnms <- oldnms[! (oldnms %in% newnms)]
-          Rinset <- c(Rinset, Rinset0[ooldnms])
-       }else Rinset <- Rinset0
-   }
-   if(!is(Rinset, "taglist")) Rinset <- taglist(list=Rinset)
-   lstset(Rinset, LineLength = LineLength, startS = startS)
-   return(invisible())
-}
-lstsetRout <- function(Routset = NULL, LineLength = getOption("width"),
-                    add = getSweaveListingOption("addRoutset"),
-                    startS = "\\lstdefinestyle{Routstyle}{"){
-   if(add){
-       Routset0 <- getSweaveListingOption("Rout")
-       if(length(Routset)){
-          newnms <- names(Routset)
-          oldnms <- names(Routset0)
-          ooldnms <- oldnms[! (oldnms %in% newnms)]
-          Routset <- c(Routset, Routset0[ooldnms])
-       }else Routset <- Routset0
-   }
-   if(!is(Routset, "taglist")) Routset <- taglist(list=Routset)
-   lstset(Routset, LineLength = LineLength, startS = startS)
-   return(invisible())
-}
-lstsetRcode <- function(Rcodeset = NULL, LineLength = getOption("width"),
-                    add = getSweaveListingOption("addRcodeset"),
-                    startS = "\\lstdefinestyle{Rcodestyle}{"){
-   if(add){
-       Rcodeset0 <- getSweaveListingOption("Rcode")
-       if(length(Rcodeset)){
-          newnms <- names(Rcodeset)
-          oldnms <- names(Rcodeset0)
-          ooldnms <- oldnms[! (oldnms %in% newnms)]
-          Rcodeset <- c(Rcodeset, Rcodeset0[ooldnms])
-       }else Rcodeset <- Rcodeset0
-   }
-   if(!is(Rcodeset, "taglist")) Rcodeset <- taglist(list=Rcodeset)
-   lstset(Rcodeset, LineLength = LineLength, startS = startS)
-   return(invisible())
-}
 
-SweaveListingPreparations <- function(
-   withOwnFileSection = FALSE,
-   withVerbatim = FALSE,
-   withSchunkDef = TRUE,
-   gin = TRUE,
-   ae = TRUE,
-   LineLength = getOption("width"),
-   Rset = getSweaveListingOption("Rset"), 
-   Rdset = getSweaveListingOption("Rdset"), 
-   Rin = getSweaveListingOption("Rin"),
-   Rout = getSweaveListingOption("Rout"),
-   Rcode = getSweaveListingOption("Rcode"),
-   Rcolor = getSweaveListingOption("Rcolor"),
-   RRecomdcolor = getSweaveListingOption("RRecomdcolor"),
-   Rbcolor = getSweaveListingOption("Rbcolor"),
-   Routcolor = getSweaveListingOption("Routcolor"),
-   Rcommentcolor = getSweaveListingOption("Rcommentcolor"),
-   pkg = getSweaveListingOption("pkg"), 
-   pkv = getSweaveListingOption("pkv"), 
-   fileCommand = getSweaveListingOption("fileCommand"),
-   pkgCommand = getSweaveListingOption("pkgCommand"),
-   lib.loc = NULL){
+   line <- paste("%",paste(rep("-",LineLength-2),collapse=""),"%\n", sep="")
 
-sws <- .SweaveListingOptions
-sws$inSweave <- TRUE
-assignInNamespace(".SweaveListingOptions", sws, "SweaveListingUtils")
 
-withVerbatim <- rep(withVerbatim, length.out=3)
-if(is.null(names(withVerbatim)))
-   names(withVerbatim) <- c("Sinput", "Soutput", "Scode")
 
+   cat(line,"%Preparations for Sweave and Listings\n",line,"%\n", sep = "")
 
-line <- paste("%",paste(rep("-",LineLength-2),collapse=""),"%\n", sep="")
+   cat("\\RequirePackage{color}\n")
+   cat("\\definecolor{Rcolor}{rgb}{",
+       paste(Rcolor,collapse=", "),"}\n", sep = "")
+   cat("\\definecolor{RRecomdcolor}{rgb}{",
+       paste(RRecomdcolor,collapse=", "),"}\n", sep = "")
+   cat("\\definecolor{Rbcolor}{rgb}{",
+       paste(Rbcolor,collapse=", "),"}\n", sep = "")
+   cat("\\definecolor{Routcolor}{rgb}{",
+       paste(Routcolor,collapse=", "),"}\n", sep = "")
+   cat("\\definecolor{Rcommentcolor}{rgb}{",
+       paste(Rcommentcolor,collapse=", "),"}\n", sep = "")
+   cat(line)
+   writeLines(readLines(file.path(system.file(package = "SweaveListingUtils",
+                                         lib.loc = lib.loc),
+                             "TeX", "Rdlisting.sty")))
+   cat(line)
+   ### (first) definition of Rstyle
+   lstsetR(Rset = Rset, LineLength = LineLength,
+           startS ="\\lstdefinestyle{RstyleO1}{")
+   cat("\\lstdefinestyle{Rstyle}{style=RstyleO1}\n")
+   ###  definition of Rdstyle
+   lstsetRd(Rdset=Rdset, LineLength=LineLength,
+           startS ="\\lstdefinestyle{Rdstyle}{")
+   cat(line)
+   if(!withOwnFileSection)
+       SweaveListingoptions("addRset" = FALSE, "addRdset" = FALSE)
+   cat("\\global\\def\\Rlstset{\\lstset{style=Rstyle}}%\n")
+   cat("\\global\\def\\Rdlstset{\\lstset{style=Rdstyle}}%\n")
+   cat(line)
+   cat("\\global\\def\\Rinlstset{\\lstset{style=Rinstyle}}%\n")
+   cat("\\global\\def\\Routlstset{\\lstset{style=Routstyle}}%\n")
+   cat("\\global\\def\\Rcodelstset{\\lstset{style=Rcodestyle}}%\n")
+   cat(line)
+   if(!withOwnFileSection)
+      cat("\\Rlstset\n")
+   cat(line,"%copying relevant parts of Sweave.sty\n",line,"%\n", sep = "")
 
+   cat("\\RequirePackage{graphicx,fancyvrb}%\n")
+   cat("\\IfFileExists{upquote.sty}{\\RequirePackage{upquote}}{}%\n\n")
+   cat("\\RequirePackage{ifthen}%\n")
+   ### you might still want to have the boolean TeX
+   #   variables available in your code
+   if(gin){
+     cat("\\newboolean{Sweave at gin}%\n")
+     cat("\\setboolean{Sweave at gin}{true}%\n")
+     cat("\\setkeys{Gin}{width=0.8\\textwidth}%\n")
+   }
 
+   if(ae){
+      cat("\\newboolean{Sweave at ae}\n")
+      cat("\\setboolean{Sweave at ae}{true}%\n")
+      cat("\\RequirePackage[T1]{fontenc}\n",
+          "\\RequirePackage{ae}\n%\n", sep ="")
+   }
 
-cat(line,"%Preparations for Sweave and Listings\n",line,"%\n", sep = "")
+   if(withSchunkDef)
+      cat("\\newenvironment{Schunk}{}{}\n\n")
 
-cat("\\RequirePackage{color}\n")
-cat("\\definecolor{Rcolor}{rgb}{",paste(Rcolor,collapse=", "),"}\n", sep = "")
-cat("\\definecolor{RRecomdcolor}{rgb}{",paste(RRecomdcolor,collapse=", "),"}\n", sep = "")
-cat("\\definecolor{Rbcolor}{rgb}{",paste(Rbcolor,collapse=", "),"}\n", sep = "")
-cat("\\definecolor{Routcolor}{rgb}{",paste(Routcolor,collapse=", "),"}\n", sep = "")
-cat("\\definecolor{Rcommentcolor}{rgb}{",paste(Rcommentcolor,collapse=", "),"}\n", sep = "")
-cat(line)
-writeLines(readLines(file.path(system.file(package = "SweaveListingUtils", 
-                                      lib.loc = lib.loc),
-                          "TeX", "Rdlisting.sty")))
-cat(line)
-lstsetR(Rset=Rset, LineLength=LineLength, startS ="\\lstdefinestyle{RstyleO1}{")
-cat("\\lstdefinestyle{Rstyle}{style=RstyleO1}\n")
-lstsetRd(Rdset=Rdset, LineLength=LineLength, startS ="\\lstdefinestyle{Rdstyle}{")
-cat(line)
-if(!withOwnFileSection)
-    SweaveListingoptions("addRset" = FALSE, "addRdset" = FALSE)
-cat("\\global\\def\\Rlstset{\\lstset{style=Rstyle}}%\n")
-cat("\\global\\def\\Rdlstset{\\lstset{style=Rdstyle}}%\n")
-cat(line)
-cat("\\global\\def\\Rinlstset{\\lstset{style=Rinstyle}}%\n")
-cat("\\global\\def\\Routlstset{\\lstset{style=Routstyle}}%\n")
-cat("\\global\\def\\Rcodelstset{\\lstset{style=Rcodestyle}}%\n")
-cat(line)
-if(!withOwnFileSection)
-   cat("\\Rlstset\n")
-cat(line,"%copying relevant parts of Sweave.sty\n",line,"%\n", sep = "")
+   cat("\\newcommand{\\Sconcordance}[1]{% \n",
+     "\\ifx\\pdfoutput\\undefined% \n",
+     "\\csname newcount\\endcsname\\pdfoutput\\fi% \n",
+     "\\ifcase\\pdfoutput\\special{#1}% \n",
+     "\\else\\immediate\\pdfobj{#1}\\fi} \n\n", sep ="")
 
-cat("\\RequirePackage{graphicx,fancyvrb}%\n")
-cat("\\IfFileExists{upquote.sty}{\\RequirePackage{upquote}}{}%\n\n")
-cat("\\RequirePackage{ifthen}%\n")
-### you might still want to have the boolean TeX
-#   variables available in your code
-if(gin){
-  cat("\\newboolean{Sweave at gin}%\n")
-  cat("\\setboolean{Sweave at gin}{true}%\n")
-  cat("\\setkeys{Gin}{width=0.8\\textwidth}%\n")
-}
+   #% ---- end of parts of Sweave.sty
+   cat(line,"% ---- end of parts of Sweave.sty\n",line,"%\n", sep = "")
 
-if(ae){
-   cat("\\newboolean{Sweave at ae}\n")
-   cat("\\setboolean{Sweave at ae}{true}%\n")
-   cat("\\RequirePackage[T1]{fontenc}\n",
-       "\\RequirePackage{ae}\n%\n", sep ="")
-}
-
-if(withSchunkDef)
-cat("\\newenvironment{Schunk}{}{}\n\n")
-
-cat("\\newcommand{\\Sconcordance}[1]{% \n",
-  "\\ifx\\pdfoutput\\undefined% \n",
-  "\\csname newcount\\endcsname\\pdfoutput\\fi% \n",
-  "\\ifcase\\pdfoutput\\special{#1}% \n",
-  "\\else\\immediate\\pdfobj{#1}\\fi} \n\n", sep ="")
-cat(line,"% ---- end of parts of Sweave.sty\n",line,"%\n", sep = "")
-
-if(!withOwnFileSection){
-if(withVerbatim["Sinput"]){
-cat("\\DefineVerbatimEnvironment{Sinput}{Verbatim}")
-cat("%\n  {formatcom=\\color{Rcolor}\\lstset{fancyvrb=true,escapechar='}}\n")
-}else{
-#### Thanks to Andrew Ellis !!
-#cat("\\lstdefinestyle{Rinstyle}",
-#    "{style=Rstyle,fancyvrb=true,basicstyle=\\color{Rcolor}\\small}}%\n")
-lstset(taglist(list=Rin), LineLength=LineLength, startS = "\\lstdefinestyle{RinstyleO}{")
-lstsetRin(Rin=Rin, LineLength=LineLength)
-cat("\\lstnewenvironment{Sinput}{\\Rinlstset}{\\Rlstset}\n")
-}
-if(withVerbatim["Soutput"]){
-cat("\\DefineVerbatimEnvironment{Soutput}{Verbatim}")
-cat("%\n  {formatcom=\\color{Routcolor}\\small\\lstset{fancyvrb=false}}\n")
-}else{
-#### Thanks to Andrew Ellis !!
-lstset(taglist(list=Rout), LineLength=LineLength,
-       startS = "\\lstdefinestyle{RoutstyleO}{")
-lstsetRout(Rout=Rout, LineLength=LineLength)
-#cat("\\lstdefinestyle{Routstyle}",
-#    "{fancyvrb=false,basicstyle=\\color{Rout}\\small}}%\n")
-cat("\\lstnewenvironment{Soutput}{\\Routlstset}{\\Rlstset}\n")
-}
-if(withVerbatim["Scode"]){
-cat("\\DefineVerbatimEnvironment{Scode}{Verbatim}")
-cat("%\n  {fontshape=sl,formatcom=\\color{Rcolor}\\lstset{fancyvrb=true}}\n")
-}else{
-#### Thanks to Andrew Ellis !!
-lstset(taglist(list=Rcode), LineLength=LineLength,
-       startS = "\\lstdefinestyle{RcodestyleO}{")
-lstsetRcode(Rcode=Rcode, LineLength=LineLength)
-#cat("\\lstdefinestyle{Rcodestyle}",
-#    "{style=Rstyle,fancyvrb=true,fontshape=sl,basicstyle=\\color{Rcolor}}%\n")
-cat("\\lstnewenvironment{Scode}{\\Rcodelstset}{\\Rlstset}\n")
-}
-}
-cat(line)
-cat("\\let\\code\\lstinline\n")
-cat("\\def\\Code#1{{\\tt\\color{Rcolor} #1}}\n")
-cat(fileCommand,"\n")
-cat(pkgCommand,"\n")
-if(missing(pkv)){
-     if(nzchar(rpkv <- readPkgVersion(package = pkg, lib.loc=lib.loc)))
-        pkv <- rpkv
+   #% definition of Rstyle, Rdstyle, Rinstyle, Routstyle, Rcodestyle
+   if(!withOwnFileSection){
+      if(withVerbatim["Sinput"]){
+         cat("% ---- input \n")
+         cat("\\DefineVerbatimEnvironment{Sinput}{Verbatim}")
+         cat("%\n  {formatcom=\\color{Rcolor}",
+             "\\lstset{fancyvrb=true,escapechar='}}\n", sep = "")
+         cat("%\n")
+      }else{#### Thanks to Andrew Ellis !!
+         cat("% ---- input \n")
+         lstset(taglist(list=Rin), LineLength=LineLength,
+                startS = "\\lstdefinestyle{RinstyleO}{")
+         cat("\\lstdefinestyle{Rinstyle}{style=RinstyleO}\n")
+         cat("\\lstnewenvironment{Sinput}{\\Rinlstset}{\\Rlstset}\n")
+         cat("%\n")
+      }
+      if(withVerbatim["Soutput"]){
+         cat("% ---- output \n")
+         cat("\\DefineVerbatimEnvironment{Soutput}{Verbatim}")
+         cat("%\n  {formatcom=\\color{Routcolor}\\small",
+             "\\lstset{fancyvrb=false}}\n", sep = "")
+         cat("%\n")
+      }else{#### Thanks to Andrew Ellis !!
+         cat("% ---- output \n")
+         lstset(taglist(list=Rout), LineLength=LineLength,
+                startS = "\\lstdefinestyle{RoutstyleO}{")
+         cat("\\lstdefinestyle{Routstyle}{style=RoutstyleO}\n")
+         cat("\\lstnewenvironment{Soutput}{\\Routlstset}{\\Rlstset}\n")
+         cat("%\n")
+      }
+      if(withVerbatim["Scode"]){
+         cat("% ---- code \n")
+         cat("\\DefineVerbatimEnvironment{Scode}{Verbatim}")
+         cat("%\n  {fontshape=sl,formatcom=\\color{Rcolor}",
+             "\\lstset{fancyvrb=true}}\n", sep = "")
+         cat("%\n")
+      }else{#### Thanks to Andrew Ellis !!
+         cat("% ---- code \n")
+         lstset(taglist(list=Rcode), LineLength=LineLength,
+                startS = "\\lstdefinestyle{RcodestyleO}{")
+         cat("\\lstdefinestyle{Rcodestyle}{style=RcodestyleO}\n")
+         cat("\\lstnewenvironment{Scode}{\\Rcodelstset}{\\Rlstset}\n")
+         cat("%\n")
+      }
    }
-cat("\\newcommand{\\pkgversion}{{\\tt ",pkv,"}}\n", sep = "")
-cat(line)
-lstsetLanguage()
-cat(line,"%\n%\n",sep="")
-cat("\n")
-return(invisible())
+   cat(line)
+   cat("\\let\\code\\lstinline\n")
+   cat("\\def\\Code#1{{\\tt\\color{Rcolor} #1}}\n")
+   cat(fileCommand,"\n")
+   cat(pkgCommand,"\n")
+   if(missing(pkv)){
+        if(nzchar(rpkv <- readPkgVersion(package = pkg, lib.loc=lib.loc)))
+           pkv <- rpkv
+      }
+   cat("\\newcommand{\\pkgversion}{{\\tt ",pkv,"}}\n", sep = "")
+   cat(line)
+   lstsetLanguage()
+   cat(line,"%\n%\n",sep="")
+   cat("\n")
+   return(invisible())
 }
 
+#------------------------------------------------------------------------------
+# readSourceFromRForge
+#------------------------------------------------------------------------------
 readSourceFromRForge <- function(PKG, TYPE, FILENAME, PROJECT,
                                  fromRForge = getSweaveListingOption("fromRForge"),
                                  base.url = getSweaveListingOption("base.url")){
@@ -354,6 +231,9 @@
   .CacheFiles[[base.URL]]
 }
 
+#------------------------------------------------------------------------------
+# copySourceFromRForge
+#------------------------------------------------------------------------------
 copySourceFromRForge <- function(PKG, TYPE, FILENAME, PROJECT, from, to,
                                  offset.before = 0, offset.after = 0,
                                  fromRForge = getSweaveListingOption("fromRForge"),
@@ -378,6 +258,9 @@
    return(invisible())
 }
 
+#------------------------------------------------------------------------------
+# lstinputSourceFromRForge
+#------------------------------------------------------------------------------
 lstinputSourceFromRForge <- function(PKG, TYPE, FILENAME, PROJECT, from, to,
                                  offset.before = 0, offset.after = 0,
                                  LineLength = getOption("width"),
@@ -448,21 +331,24 @@
      if(!is.null(lR[[k]])){ if(lR[[k]]){
         todo <- NULL
         if(TYPE=="man"){
-          ex.from <- if(length(gr <- grep("\\\\examples\\{",RL[[k]]))) gr[1] else lR[[k]]
-          ex.to <- if(length(gr <- grep("\\}",RL[[k]][ex.from:lR[[k]]]))) ex.from+gr[1]-1 else 1
-          cat(line) #,"\\Rdlstset\n",sep="")
-          cat("\\begin{lstlisting}[style=Rdstyle]\n")
+          ex.from <- if(length(gr <- grep("\\\\examples\\{",RL[[k]])))
+                     gr[1] else lR[[k]]
+          ex.to <- if(length(gr <- grep("\\}",RL[[k]][ex.from:lR[[k]]])))
+                   ex.from+gr[1]-1 else 1
+          cat(line)
+          cat("\\begin{lstlisting}[style = Rdstyle]\n")
           if(ex.from<=ex.to){
              writeLines(RL[[k]][1:(ex.from)])
              cat("\\end{lstlisting}\\vspace{-2ex}\n")
-             cat(line) # ,"\\Rlstset\n",sep="")
-             cat("\\begin{lstlisting}[style=Rstyle,")
-             cat("basicstyle = \\scriptsize\\color{Rcolor}, xleftmargin = 2em]\n")
+             cat(line)
+             cat("\\begin{lstlisting}[style = Rstyle,")
+             cat("basicstyle = \\scriptsize\\color{Rcolor},",
+                 " xleftmargin = 2em]\n", sep = "")
              writeLines(RL[[k]][(ex.from+1):(ex.to-1)])
              if(ex.to <lR){
                 cat("\\end{lstlisting}\\vspace{-3ex}\n")
-                cat(line) #,"\\Rdlstset\n",sep="")
-                cat("\\begin{lstlisting}[style=Rdstyle]\n")
+                cat(line)
+                cat("\\begin{lstlisting}[style = Rdstyle]\n")
                 writeLines(RL[[k]][(ex.to):lR[[k]]])
                 }
           }else writeLines(RL[[k]])

Modified: branches/distr-2.2/pkg/SweaveListingUtils/R/keywordsStyle.R
===================================================================
--- branches/distr-2.2/pkg/SweaveListingUtils/R/keywordsStyle.R	2009-09-01 23:44:19 UTC (rev 561)
+++ branches/distr-2.2/pkg/SweaveListingUtils/R/keywordsStyle.R	2009-09-03 23:07:35 UTC (rev 562)
@@ -100,8 +100,8 @@
         keywordstyles <- rep(keywordstyles, length.out = lP)
 
      if(lP) {
-        if(is.null(.numberofRequires)) .numberofRequires <<- 1
-        else .numberofRequires <<- .numberofRequires + 1
+        if(is.null(.numberofRstyleDefs)) .numberofRstyleDefs <<- 1
+        else .numberofRstyleDefs <<- .numberofRstyleDefs + 1
         withcomma <- TRUE
         pos1 <- 0
         for(i in 1: lP){
@@ -112,15 +112,15 @@
 
            if(i==1){
               pos1 <- pos0 + length(.alreadyDefinedPkgs)
-              cat("\n\\lstdefinestyle{RstyleO",.numberofRequires+1,"}{style=RstyleO",
-                       .numberofRequires,",%\n",sep="")
+              cat("\n\\lstdefinestyle{RstyleO",.numberofRstyleDefs+1,"}{style=RstyleO",
+                       .numberofRstyleDefs,",%\n",sep="")
            }
 
            if(i==lP) withcomma <- FALSE
            genKWL(pkg = pkgs[i], kwd = kwl,
                   kws = keywordstyles[i], withcomma = withcomma)
            if(i==lP) cat("}%\n\\lstdefinestyle{Rstyle}{style=RstyleO",
-                          .numberofRequires+1,"}\n\n",
+                          .numberofRstyleDefs+1,"}\n\n",
                           sep="")
            }
      }
@@ -129,10 +129,10 @@
 
 changeKeywordstyles <- function(pkgs, keywordstyles){
      setkws <- function(num, kws){
-        cat("%\n\\lstdefinestyle{RstyleO",.numberofRequires+1,"}{style=RstyleO",
-                       .numberofRequires,",%\n", sep="")
+        cat("%\n\\lstdefinestyle{RstyleO",.numberofRstyleDefs+1,"}{style=RstyleO",
+                       .numberofRstyleDefs,",%\n", sep="")
         cat("{keywordstyle={[",num+1,"]",kws,"}\n}\n", sep = "")
-        cat("\\lstdefinestyle{Rstyle}{style=RstyleO", .numberofRequires+1,"}\n",
+        cat("\\lstdefinestyle{Rstyle}{style=RstyleO", .numberofRstyleDefs+1,"}\n",
             sep = "")
         }
 
@@ -158,8 +158,8 @@
      keywordstyles <- rep(keywordstyles, length.out = lP)
 
      if(lP){
-        if(is.null(.numberofRequires)) .numberofRequires <<- 1
-        else .numberofRequires <<- .numberofRequires + 1
+        if(is.null(.numberofRstyleDefs)) .numberofRstyleDefs <<- 1
+        else .numberofRstyleDefs <<- .numberofRstyleDefs + 1
         for(i in 1: lP)
             setkws(num = numIdx[i], kws = keywordstyles[i])
      }

Added: branches/distr-2.2/pkg/SweaveListingUtils/R/lstset.R
===================================================================
--- branches/distr-2.2/pkg/SweaveListingUtils/R/lstset.R	                        (rev 0)
+++ branches/distr-2.2/pkg/SweaveListingUtils/R/lstset.R	2009-09-03 23:07:35 UTC (rev 562)
@@ -0,0 +1,141 @@
+lstset <- function(taglist, LineLength = getOption("width"),
+                   startS = "\\lstset{"){
+   print(taglist, LineLength = LineLength, offset.start = nchar(startS),
+         withFinalLineBreak = FALSE, first.print = startS)
+   cat("}%\n")
+   return(invisible())
+}
+
+lstdefRstyle <- function(Rset = NULL, LineLength = getOption("width"),
+                    add = TRUE){
+
+   oN <- paste("RstyleO", .numberofRstyleDefs, sep = "")
+   nN <- paste("RstyleO", .numberofRstyleDefs + 1, sep = "")
+
+   if(add) Rset <- c("style"= oN, Rset)
+   if(!is(Rset, "taglist")) Rset <- taglist(list=Rset)
+
+   if(is.null(.numberofRstyleDefs)) .numberofRstyleDefs <<- 1
+      else .numberofRstyleDefs <<- .numberofRstyleDefs + 1
+
+
+   cat("\n")
+   lstset(Rset, LineLength = LineLength,
+          startS = paste("\\lstdefinestyle{", nN,"}{",sep=""))
+   cat("\\lstdefinestyle{Rstyle}{style=",nN,"}\n%\n",sep="")
+
+   return(invisible())
+}
+
+.preOrappend <- function(SetFromOptions, NewSet, append = TRUE,
+                         withRstyle = FALSE){
+#       cat("%\n%",SetFromOptions,"\n%\n")
+       set0 <- getSweaveListingOption(SetFromOptions)
+#       cat("%\n%",paste("%",set0,"\n"),"\n%\n")
+       if(length(NewSet)){
+          newnms <- names(NewSet)
+          oldnms <- names(set0)
+          ooldnms <- oldnms[! (oldnms %in% newnms)]
+          if(append)  ret <- c(set0[ooldnms], NewSet)
+          else        ret <- c(NewSet, set0[ooldnms])
+       }else {
+          ret <- set0
+       }
+       if(withRstyle) if(is.null(ret$style)) ret <- c(style="Rstyle",ret)
+       return(ret)
+}
+
+.lstsetTempl <- function(set = NULL, setName = "",
+                         LineLength = getOption("width"),
+                         add = TRUE, startS = "", append = TRUE,
+                         withRstyle = FALSE, withPre = TRUE,
+                         withPre2 = TRUE, withAft = TRUE){
+   if(add) set <- .preOrappend(setName, set, append = append,
+                               withRstyle = withRstyle)
+   if(!is(set, "taglist")) set <- taglist(list=set)
+   if(withPre) cat(ifelse(withPre2,"\n",""),
+                   "%----------------\n", sep = "")
+   lstset(set, LineLength = LineLength, startS = startS)
+   if(withAft) cat("%----------------\n")
+   return(invisible())
+}
+
+lstsetR <- function(Rset = NULL, LineLength = getOption("width"),
+                    add = getSweaveListingOption("addRset"),
+                    startS = "\\lstset{",
+                    append = TRUE, withRstyle = FALSE)
+   .lstsetTempl(set = Rset, setName = "Rset", LineLength = LineLength,
+                add = add, startS = startS, append = append,
+                withRstyle = withRstyle)
+
+lstsetRd <- function(Rdset = NULL, LineLength = getOption("width"),
+                    add = getSweaveListingOption("addRdset"),
+                    startS = "\\lstset{",append = TRUE)
+   .lstsetTempl(set = Rdset, setName = "Rdset", LineLength = LineLength,
+                add = add, startS = startS, append = append)
+
+
+lstsetRin <- function(Rinset = NULL, LineLength = getOption("width"),
+                    add = getSweaveListingOption("addRinset"),
+                    startS = "\\lstdefinestyle{Rinstyle}{",
+                    append = TRUE)
+   .lstsetTempl(set = Rinset, setName = "Rin", LineLength = LineLength,
+                add = add, startS = startS, append = append,
+                withRstyle = TRUE)
+
+lstsetRout <- function(Routset = NULL, LineLength = getOption("width"),
+                    add = getSweaveListingOption("addRoutset"),
+                    startS = "\\lstdefinestyle{Routstyle}{",
+                    append = TRUE)
+   .lstsetTempl(set = Routset, setName = "Rout", LineLength = LineLength,
+                add = add, startS = startS, append = append)
+
+lstsetRcode <- function(Rcodeset = NULL, LineLength = getOption("width"),
+                    add = getSweaveListingOption("addRcodeset"),
+                    startS = "\\lstdefinestyle{Rcodestyle}{",
+                    append = TRUE)
+   .lstsetTempl(set = Rcodeset, setName = "Rcode", LineLength = LineLength,
+                add = add, startS = startS, append = append,
+                withRstyle = TRUE)
+
+lstsetRall <- function(Rallset = NULL, LineLength = getOption("width"),
+                    add = c("in" = getSweaveListingOption("addRinset"),
+                            "out" = getSweaveListingOption("addRoutset"),
+                            "code" = getSweaveListingOption("addRcodeset")),
+                    startS = c("in" = "\\lstdefinestyle{Rinstyle}{",
+                               "out" = "\\lstdefinestyle{Routstyle}{",
+                               "code" = "\\lstdefinestyle{Rcodestyle}{"),
+                    append = c("in" = TRUE, "out" = TRUE, "code" = TRUE),
+                    withOptionsDefAppend = TRUE){
+
+   .prep <- function(u){
+      u <- rep(u, length.out = 3)
+      ioc <- c("in", "out", "code")
+      if(all(ioc %in% names(u)))
+         u <- u[ioc]
+      names(u) <- ioc
+      u}
+
+   add    <- .prep(add)
+   startS <- .prep(startS)
+   append <- .prep(append)
+
+   cat("%----------------\n")
+   lstdefRstyle(Rset = Rallset, LineLength = LineLength)
+   if(withOptionsDefAppend){
+     .lstsetTempl(set = Rallset, setName = "Rin", LineLength = LineLength,
+                add = add["in"], startS = startS["in"], append = append["in"],
+                withRstyle = TRUE, withPre = FALSE, withAft = FALSE)
+     .lstsetTempl(set = Rallset, setName = "Rout", LineLength = LineLength,
+                add = add["out"], startS = startS["out"], append = append["out"],
+                withRstyle = TRUE, withAft = FALSE, withPre = FALSE)
+     .lstsetTempl(set = Rallset, setName = "Rcode", LineLength = LineLength,
+                add = add["code"], startS = startS["code"], append = append["code"],
+                withRstyle = TRUE,  withPre = FALSE)
+   }else{
+     cat("\\lstdefinestyle{Rinstyle}{style=Rstyle}\n")
+     cat("\\lstdefinestyle{Routstyle}{style=Rstyle}\n")
+     cat("\\lstdefinestyle{Rcodestyle}{style=Rstyle}\n")
+   }
+   return(invisible())
+   }
\ No newline at end of file

Added: branches/distr-2.2/pkg/SweaveListingUtils/R/taglist.R
===================================================================
--- branches/distr-2.2/pkg/SweaveListingUtils/R/taglist.R	                        (rev 0)
+++ branches/distr-2.2/pkg/SweaveListingUtils/R/taglist.R	2009-09-03 23:07:35 UTC (rev 562)
@@ -0,0 +1,63 @@
+print.taglist <- function(x, LineLength = getOption("width"), offset.start = 0,
+                          withFinalLineBreak = TRUE, first.print = NULL,
+                          ErrorOrWarn = "warn", ...){
+   xc <- as.character(deparse(substitute(x)))
+   ll <- length(x)
+   LineL <- max(LineLength-2,0)
+   LineBreak <- NULL
+   mi50 <- min(LineLength,50)
+   maL <- max(3*LineLength,getOption("width"))
+   if(ll){
+      offS <- paste(rep(" ", offset.start), collapse = "")
+      for(i in 1:ll){
[TRUNCATED]

To get the complete diff run:
    svnlook diff /svnroot/distr -r 562


More information about the Distr-commits mailing list