[Distr-commits] r514 - branches/distr-2.2/pkg/SweaveListingUtils/R branches/distr-2.2/pkg/SweaveListingUtils/chm branches/distr-2.2/pkg/SweaveListingUtils/inst/doc branches/distr-2.2/pkg/SweaveListingUtils/man pkg/SweaveListingUtils pkg/SweaveListingUtils/R pkg/SweaveListingUtils/chm pkg/SweaveListingUtils/inst pkg/SweaveListingUtils/inst/doc pkg/SweaveListingUtils/man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue Jul 28 22:59:47 CEST 2009
Author: ruckdeschel
Date: 2009-07-28 22:59:46 +0200 (Tue, 28 Jul 2009)
New Revision: 514
Modified:
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/SweaveListingUtils.chm
branches/distr-2.2/pkg/SweaveListingUtils/chm/taglist.html
branches/distr-2.2/pkg/SweaveListingUtils/inst/doc/ExampleSweaveListingUtils.Rnw
branches/distr-2.2/pkg/SweaveListingUtils/inst/doc/preambleExp.tex
branches/distr-2.2/pkg/SweaveListingUtils/man/taglist.Rd
pkg/SweaveListingUtils/DESCRIPTION
pkg/SweaveListingUtils/R/SweaveListingOptions.R
pkg/SweaveListingUtils/R/SweaveListingUtils.R
pkg/SweaveListingUtils/R/keywordsStyle.R
pkg/SweaveListingUtils/chm/00Index.html
pkg/SweaveListingUtils/chm/SweaveListingUtils.chm
pkg/SweaveListingUtils/chm/taglist.html
pkg/SweaveListingUtils/inst/NEWS
pkg/SweaveListingUtils/inst/doc/ExampleSweaveListingUtils.Rnw
pkg/SweaveListingUtils/inst/doc/preambleExp.tex
pkg/SweaveListingUtils/man/taglist.Rd
Log:
SweaveListingUtils: fixed an issue with multiple definitions of morekeywords for listings style Rstyle
Modified: branches/distr-2.2/pkg/SweaveListingUtils/R/SweaveListingOptions.R
===================================================================
--- branches/distr-2.2/pkg/SweaveListingUtils/R/SweaveListingOptions.R 2009-07-23 15:45:46 UTC (rev 513)
+++ branches/distr-2.2/pkg/SweaveListingUtils/R/SweaveListingOptions.R 2009-07-28 20:59:46 UTC (rev 514)
@@ -3,6 +3,7 @@
.CacheFiles <- NULL
.alreadyDefinedPkgs <- NULL
.tobeDefinedPkgs <- NULL
+.numberofRequires <- 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-07-23 15:45:46 UTC (rev 513)
+++ branches/distr-2.2/pkg/SweaveListingUtils/R/SweaveListingUtils.R 2009-07-28 20:59:46 UTC (rev 514)
@@ -13,6 +13,7 @@
unlockBinding(".keywordsR", asNamespace("SweaveListingUtils"))
unlockBinding(".alreadyDefinedPkgs", asNamespace("SweaveListingUtils"))
+ unlockBinding(".numberofRequires", asNamespace("SweaveListingUtils"))
unlockBinding(".tobeDefinedPkgs", asNamespace("SweaveListingUtils"))
unlockBinding(".CacheFiles", asNamespace("SweaveListingUtils"))
unlockBinding(".CacheLength", asNamespace("SweaveListingUtils"))
@@ -41,7 +42,8 @@
print.taglist <- function(x, LineLength = getOption("width"), offset.start = 0,
- withFinalLineBreak = TRUE, first.print = NULL, ...){
+ withFinalLineBreak = TRUE, first.print = NULL,
+ ErrorOrWarn = "warn", ...){
xc <- as.character(deparse(substitute(x)))
ll <- length(x)
LineL <- max(LineLength-2,0)
@@ -65,7 +67,10 @@
if (ntry < LineL){
actstr <- trystr
}else{
- if(ntry > maL) stop(gettextf(
+ 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))
@@ -235,6 +240,7 @@
"TeX", "Rdlisting.sty")))
cat(line)
lstsetR(Rset=Rset, LineLength=LineLength, startS ="\\lstdefinestyle{Rstyle}{")
+lstsetR(Rset=Rset, LineLength=LineLength, startS ="\\lstdefinestyle{RstyleO1}{")
lstsetRd(Rdset=Rdset, LineLength=LineLength, startS ="\\lstdefinestyle{Rdstyle}{")
cat(line)
if(!withOwnFileSection)
Modified: branches/distr-2.2/pkg/SweaveListingUtils/R/keywordsStyle.R
===================================================================
--- branches/distr-2.2/pkg/SweaveListingUtils/R/keywordsStyle.R 2009-07-23 15:45:46 UTC (rev 513)
+++ branches/distr-2.2/pkg/SweaveListingUtils/R/keywordsStyle.R 2009-07-28 20:59:46 UTC (rev 514)
@@ -40,7 +40,9 @@
}
lstsetLanguage <- function(pkgs, posIdx, keywordstyles, overwrite = FALSE){
- genKWL <- function(pkg, kwd, kws){
+ if(is.null(.numberofRequires)) .numberofRequires <<- 1
+ else .numberofRequires <<- .numberofRequires + 1
+ genKWL <- function(pkg, kwd, kws, withcomma = TRUE){
if (!overwrite)
kwd <- kwd[!kwd%in%.keywordsR]
num <- length(.alreadyDefinedPkgs)
@@ -51,7 +53,7 @@
cat("% --------------------------\n% Registration of package ",pkg,
BaseOrRec,
"\n% --------------------------\n",
- "\\lstdefinestyle{Rstyle}{morekeywords={[",num+2,"]", sep = "")
+ "morekeywords={[",num+2,"]", sep = "")
ml <- length(kwd); m1 <- ml%/%5; m2 <- ml%%5
kwd[ml] <- paste(kwd[ml],"%",sep="")
if(length(kwd)){
@@ -63,8 +65,10 @@
}
cat(kwd,sep = seps, fill = FALSE); #cat("%\n")
if(ml<=5) cat("\n")
- cat("},%\nkeywordstyle={[",num+2,"]",kws,"}%\n}\n", sep = "")
- cat(paste("%\n%\n\n"))
+ cat("},%\nkeywordstyle={[",num+2,"]",kws,"}",sep="")
+ if(withcomma) cat(",")
+ cat("%\n%\n", sep = "")
+# cat(paste("%\n%\n\n"))
.alreadyDefinedPkgs <<- c(.alreadyDefinedPkgs,pkg)
}
return(invisible())
@@ -96,19 +100,38 @@
}else
keywordstyles <- rep(keywordstyles, length.out = lP)
- if(lP) {for(i in 1: lP){
- kwl <- ls(pos = which(pkgs[i] == gsub("package:","",search())))
- kwl <- sort(kwl[grep("^[[:alpha:]]+\\w*",kwl,perl=TRUE)],
- decreasing = TRUE)
- genKWL(pkg = pkgs[i], kwd = kwl,
- kws = keywordstyles[i])}
+ if(lP) {
+ withcomma <- TRUE
+ pos1 <- 0
+ for(i in 1: lP){
+ pos0 <- which(pkgs[i] == gsub("package:","",search()))
+ kwl <- ls(pos = pos0)
+ kwl <- sort(kwl[grep("^[[:alpha:]]+\\w*",kwl,perl=TRUE)],
+ decreasing = TRUE)
+
+ if(i==1){
+ pos1 <- pos0 + length(.alreadyDefinedPkgs)
+ cat("\n\\lstdefinestyle{Rstyle",pos1,"}{style=RstyleO",
+ .numberofRequires,",%\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=Rstyle",
+ pos1,"}\n",
+ "\\lstdefinestyle{RstyleO",.numberofRequires+1,
+ "}{style=Rstyle", pos1,"}\n\n",
+
+ sep="")
+ }
}
return(invisible())
}
changeKeywordstyles <- function(pkgs, keywordstyles){
setkws <- function(num, kws){
- cat("%\n\\lstset%\n")
+ cat("%\n\\lstdefinestyle{Rstyle}%\n")
cat("{keywordstyle={[",num+1,"]",kws,"}\n}\n", sep = "")
}
@@ -238,7 +261,7 @@
kwsI <- kws[idxRec]
grI <- grep("\\\\color\\{.+\\}", kwsI, invert = TRUE)
- kwsI <- gsub("\\\\color\\{.+\\}","\\\\color\\{RRecomdcolor\\}",
+ kwsI <- gsub("\\\\color\\{.[^\\}]+\\}","\\\\color\\{RRecomdcolor\\}",
kwsI)
kwsI[grI] <- gsub("\\}$","\\\\color\\{RRecomdcolor\\}\\}",kwsI[grI])
kws[idxRec] <- kwsI
Modified: branches/distr-2.2/pkg/SweaveListingUtils/chm/SweaveListingUtils.chm
===================================================================
(Binary files differ)
Modified: branches/distr-2.2/pkg/SweaveListingUtils/chm/taglist.html
===================================================================
--- branches/distr-2.2/pkg/SweaveListingUtils/chm/taglist.html 2009-07-23 15:45:46 UTC (rev 513)
+++ branches/distr-2.2/pkg/SweaveListingUtils/chm/taglist.html 2009-07-28 20:59:46 UTC (rev 514)
@@ -27,7 +27,8 @@
taglist(..., list = NULL, defname = "V")
## S3 method for class 'taglist':
print(x, LineLength = getOption("width"), offset.start = 0,
- withFinalLineBreak = TRUE, first.print = NULL, ...)
+ withFinalLineBreak = TRUE, first.print = NULL,
+ ErrorOrWarn = "warn", ...)
</pre>
@@ -68,6 +69,10 @@
<td>
character; something to be printed immediately before
the first list item; defaulting to <code>NULL</code>.</td></tr>
+<tr valign="top"><td><code>ErrorOrWarn</code></td>
+<td>
+shall we issue a warning (if partially matched to <code>"warn"</code>
+or else an error</td></tr>
</table>
<h3>Details</h3>
Modified: branches/distr-2.2/pkg/SweaveListingUtils/inst/doc/ExampleSweaveListingUtils.Rnw
===================================================================
--- branches/distr-2.2/pkg/SweaveListingUtils/inst/doc/ExampleSweaveListingUtils.Rnw 2009-07-23 15:45:46 UTC (rev 513)
+++ branches/distr-2.2/pkg/SweaveListingUtils/inst/doc/ExampleSweaveListingUtils.Rnw 2009-07-28 20:59:46 UTC (rev 514)
@@ -463,11 +463,6 @@
lstinputSourceFromRForge("distr","man","BinomParameter-class.Rd","distr")
@
-Note that corresponding examples are still typeset in {\sf R} style;
-however, up to now this will only be done in the (static) {\tt listings} style
-{\tt Rstyle}, as defined in the preamble; keywords from attached packages
-will not be used. Reason for this: I do not yet know how to save a current
-``state of style'' in a corresponding {\tt listings} style.
%
Modified: branches/distr-2.2/pkg/SweaveListingUtils/inst/doc/preambleExp.tex
===================================================================
--- branches/distr-2.2/pkg/SweaveListingUtils/inst/doc/preambleExp.tex 2009-07-23 15:45:46 UTC (rev 513)
+++ branches/distr-2.2/pkg/SweaveListingUtils/inst/doc/preambleExp.tex 2009-07-28 20:59:46 UTC (rev 514)
@@ -2,6 +2,7 @@
\RequirePackage{listings}
%\usepackage{Sweave}
% -------------------------------------------------------------------------------
+% -------------------------------------------------------------------------------
%------------------------------------------------------------------------------%
%Preparations for Sweave and Listings
%------------------------------------------------------------------------------%
@@ -30,20 +31,24 @@
morecomment=[l]\%% 2008/9 Peter Ruckdeschel
}[keywords,comments]%%
%------------------------------------------------------------------------------%
-\lstdefinestyle{Rstyle}{fancyvrb=true,escapechar=§,language=R,%
- % note:
- % '§' replaces accent grave (otherwise difficulties in TeXing this verbatim)
+\lstdefinestyle{Rstyle}{fancyvrb=true,escapechar=§,language=R,% § just for convenience
basicstyle={\color{Rcolor}\small},%
keywordstyle={\bf\color{Rcolor}},%
commentstyle={\color{Rcommentcolor}\ttfamily\itshape},%
- literate={<-}{{$\leftarrow$}}2{<<-}{{$\twoheadleftarrow$}}2%
- {~}{{$\sim$}}1{<=}{{$\leq$}}2%
- {>=}{{$\geq$}}2%
- {^}{{$\scriptstyle\wedge$}}1,%
+ literate={<-}{{$\leftarrow$}}2{<<-}{{$\twoheadleftarrow$}}2{~}{{$\sim$}}1{<=}{{$\leq$}}2{>=}{{$\geq$}}2{^}{{$\scriptstyle\wedge$}}1,%
alsoother={$},%
alsoletter={.<-},%
otherkeywords={!,!=,~,$,*,\&,\%/\%,\%*\%,\%\%,<-,<<-,/},%
escapeinside={(*}{*)}}%
+\lstdefinestyle{RstyleO1}{fancyvrb=true,escapechar=§,language=R,% § just for convenience
+ basicstyle={\color{Rcolor}\small},%
+ keywordstyle={\bf\color{Rcolor}},%
+ commentstyle={\color{Rcommentcolor}\ttfamily\itshape},%
+ literate={<-}{{$\leftarrow$}}2{<<-}{{$\twoheadleftarrow$}}2{~}{{$\sim$}}1{<=}{{$\leq$}}2{>=}{{$\geq$}}2{^}{{$\scriptstyle\wedge$}}1,%
+ alsoother={$},%
+ alsoletter={.<-},%
+ otherkeywords={!,!=,~,$,*,\&,\%/\%,\%*\%,\%\%,<-,<<-,/},%
+ escapeinside={(*}{*)}}%
\lstdefinestyle{Rdstyle}{fancyvrb=true,language=Rd,keywordstyle={\bf},%
basicstyle={\color{black}\footnotesize},%
commentstyle={\ttfamily\itshape},%
@@ -61,16 +66,18 @@
%copying relevant parts of Sweave.sty
%------------------------------------------------------------------------------%
%
+\RequirePackage{graphicx,fancyvrb}%
+\IfFileExists{upquote.sty}{\RequirePackage{upquote}}{}%
+
\RequirePackage{ifthen}%
\newboolean{Sweave at gin}%
\setboolean{Sweave at gin}{true}%
+\setkeys{Gin}{width=0.8\textwidth}%
\newboolean{Sweave at ae}
\setboolean{Sweave at ae}{true}%
-\RequirePackage{graphicx,fancyvrb}%
-\IfFileExists{upquote.sty}{\RequirePackage{upquote}}{}%
-\setkeys{Gin}{width=0.8\textwidth}
\RequirePackage[T1]{fontenc}
\RequirePackage{ae}
+%
\newenvironment{Schunk}{}{}
\newcommand{\Sconcordance}[1]{%
@@ -103,40 +110,41 @@
\def\pkg#1{{\tt "#1"}}
\newcommand{\pkgversion}{{\tt 2.2}}
%------------------------------------------------------------------------------%
+\lstdefinestyle{Rstyle2}{style=RstyleO1,%
% --------------------------
% Registration of package SweaveListingUtils
% --------------------------
-\lstset{morekeywords={[2]taglist,SweaveListingPreparations,SweaveListingOptions,%
-SweaveListingoptions,SweaveListingMASK,setToBeDefinedPkgs,readSourceFromRForge,%
-readPkgVersion,lstsetRd,lstsetR,lstsetLanguage,lstset,lstinputSourceFromRForge,%
-getSweaveListingOption,copySourceFromRForge,changeKeywordstyles%
+morekeywords={[2]taglist,SweaveListingPreparations,SweaveListingOptions,SweaveListingoptions,SweaveListingMASK,%
+setToBeDefinedPkgs,setBaseOrRecommended,readSourceFromRForge,readPkgVersion,lstsetRout,%
+lstsetRin,lstsetRd,lstsetRcode,lstsetR,lstsetLanguage,%
+lstset,lstinputSourceFromRForge,isBaseOrRecommended,getSweaveListingOption,copySourceFromRForge,%
+changeKeywordstyles%
},%
-keywordstyle={[2]{\bf}}%
-}
+keywordstyle={[2]{\bf}},%
%
-%
-
% --------------------------
% Registration of package startupmsg
% --------------------------
-\lstset{morekeywords={[3]suppressStartupMessages,startupType,startupPackage,%
-StartupMessage,startupMessage,startupEndline,readVersionInformation,%
-readURLInformation,pointertoNEWS,onlytypeStartupMessages,%
+morekeywords={[3]suppressStartupMessages,startupType,startupPackage,StartupMessage,startupMessage,%
+startupEndline,readVersionInformation,readURLInformation,pointertoNEWS,onlytypeStartupMessages,%
NEWS,mystartupMessage,mySMHandler,infoShow,buildStartupMessage%
},%
-keywordstyle={[3]{\bf}}%
-}
+keywordstyle={[3]{\bf}},%
%
%
...
-snipped expanded `\TeX` (see how the original `\verb|`\TeX`|` gets escaped!)
+snipped expanded (`\TeX`) (see how the original `(\verb|(`\TeX`)|)` gets escaped!)
code for registration of packages
tools, stats, graphics, grDevices, utils, datasets, methods, base
...
%
+},%
+keywordstyle={[11]{\bf\color{RRecomdcolor}}}%
+%
+}%
+\lstdefinestyle{Rstyle}{style=Rstyle2}
+\lstdefinestyle{RstyleO2}{style=Rstyle2}
+
%------------------------------------------------------------------------------%
-\lstset%
-{keywordstyle={[2]\bf\color{blue}}
-}%
Modified: branches/distr-2.2/pkg/SweaveListingUtils/man/taglist.Rd
===================================================================
--- branches/distr-2.2/pkg/SweaveListingUtils/man/taglist.Rd 2009-07-23 15:45:46 UTC (rev 513)
+++ branches/distr-2.2/pkg/SweaveListingUtils/man/taglist.Rd 2009-07-28 20:59:46 UTC (rev 514)
@@ -8,7 +8,8 @@
\usage{
taglist(..., list = NULL, defname = "V")
\method{print}{taglist}(x, LineLength = getOption("width"), offset.start = 0,
- withFinalLineBreak = TRUE, first.print = NULL, ...)
+ withFinalLineBreak = TRUE, first.print = NULL,
+ ErrorOrWarn = "warn", ...)
}
\arguments{
\item{\dots}{arbitrary number of arguments in \code{taglist}, respectively,
@@ -30,6 +31,8 @@
defaults to \code{TRUE}.}
\item{first.print}{character; something to be printed immediately before
the first list item; defaulting to \code{NULL}.}
+ \item{ErrorOrWarn}{shall we issue a warning (if partially matched to \code{"warn"}
+ or else an error}
}
\details{
Modified: pkg/SweaveListingUtils/DESCRIPTION
===================================================================
--- pkg/SweaveListingUtils/DESCRIPTION 2009-07-23 15:45:46 UTC (rev 513)
+++ pkg/SweaveListingUtils/DESCRIPTION 2009-07-28 20:59:46 UTC (rev 514)
@@ -1,6 +1,6 @@
Package: SweaveListingUtils
Title: Utilities for Sweave together with TeX listings package
-Version: 0.3.2
+Version: 0.3.3
Depends: R(>= 2.0.0), startupmsg
Suggests: distr
Imports: stats
@@ -13,6 +13,6 @@
vignette and documented source code
Maintainer: Peter Ruckdeschel <Peter.Ruckdeschel at itwm.fraunhofer.de>
License: LGPL-3
-Date: 2009-07-15
+Date: 2009-07-29
LastChangedDate: {$LastChangedDate$}
LastChangedRevision: {$LastChangedRevision$}
Modified: pkg/SweaveListingUtils/R/SweaveListingOptions.R
===================================================================
--- pkg/SweaveListingUtils/R/SweaveListingOptions.R 2009-07-23 15:45:46 UTC (rev 513)
+++ pkg/SweaveListingUtils/R/SweaveListingOptions.R 2009-07-28 20:59:46 UTC (rev 514)
@@ -3,6 +3,7 @@
.CacheFiles <- NULL
.alreadyDefinedPkgs <- NULL
.tobeDefinedPkgs <- NULL
+.numberofRequires <- NULL
.SweaveListingOptions <- list(
Rset = list("fancyvrb" = "true", "escapechar" = "`",
Modified: pkg/SweaveListingUtils/R/SweaveListingUtils.R
===================================================================
--- pkg/SweaveListingUtils/R/SweaveListingUtils.R 2009-07-23 15:45:46 UTC (rev 513)
+++ pkg/SweaveListingUtils/R/SweaveListingUtils.R 2009-07-28 20:59:46 UTC (rev 514)
@@ -13,6 +13,7 @@
unlockBinding(".keywordsR", asNamespace("SweaveListingUtils"))
unlockBinding(".alreadyDefinedPkgs", asNamespace("SweaveListingUtils"))
+ unlockBinding(".numberofRequires", asNamespace("SweaveListingUtils"))
unlockBinding(".tobeDefinedPkgs", asNamespace("SweaveListingUtils"))
unlockBinding(".CacheFiles", asNamespace("SweaveListingUtils"))
unlockBinding(".CacheLength", asNamespace("SweaveListingUtils"))
@@ -41,7 +42,8 @@
print.taglist <- function(x, LineLength = getOption("width"), offset.start = 0,
- withFinalLineBreak = TRUE, first.print = NULL, ...){
+ withFinalLineBreak = TRUE, first.print = NULL,
+ ErrorOrWarn = "warn", ...){
xc <- as.character(deparse(substitute(x)))
ll <- length(x)
LineL <- max(LineLength-2,0)
@@ -65,7 +67,10 @@
if (ntry < LineL){
actstr <- trystr
}else{
- if(ntry > maL) stop(gettextf(
+ 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))
@@ -235,6 +240,7 @@
"TeX", "Rdlisting.sty")))
cat(line)
lstsetR(Rset=Rset, LineLength=LineLength, startS ="\\lstdefinestyle{Rstyle}{")
+lstsetR(Rset=Rset, LineLength=LineLength, startS ="\\lstdefinestyle{RstyleO1}{")
lstsetRd(Rdset=Rdset, LineLength=LineLength, startS ="\\lstdefinestyle{Rdstyle}{")
cat(line)
if(!withOwnFileSection)
Modified: pkg/SweaveListingUtils/R/keywordsStyle.R
===================================================================
--- pkg/SweaveListingUtils/R/keywordsStyle.R 2009-07-23 15:45:46 UTC (rev 513)
+++ pkg/SweaveListingUtils/R/keywordsStyle.R 2009-07-28 20:59:46 UTC (rev 514)
@@ -40,7 +40,9 @@
}
lstsetLanguage <- function(pkgs, posIdx, keywordstyles, overwrite = FALSE){
- genKWL <- function(pkg, kwd, kws){
+ if(is.null(.numberofRequires)) .numberofRequires <<- 1
+ else .numberofRequires <<- .numberofRequires + 1
+ genKWL <- function(pkg, kwd, kws, withcomma = TRUE){
if (!overwrite)
kwd <- kwd[!kwd%in%.keywordsR]
num <- length(.alreadyDefinedPkgs)
@@ -51,7 +53,7 @@
cat("% --------------------------\n% Registration of package ",pkg,
BaseOrRec,
"\n% --------------------------\n",
- "\\lstdefinestyle{Rstyle}{morekeywords={[",num+2,"]", sep = "")
+ "morekeywords={[",num+2,"]", sep = "")
ml <- length(kwd); m1 <- ml%/%5; m2 <- ml%%5
kwd[ml] <- paste(kwd[ml],"%",sep="")
if(length(kwd)){
@@ -63,8 +65,10 @@
}
cat(kwd,sep = seps, fill = FALSE); #cat("%\n")
if(ml<=5) cat("\n")
- cat("},%\nkeywordstyle={[",num+2,"]",kws,"}%\n}\n", sep = "")
- cat(paste("%\n%\n\n"))
+ cat("},%\nkeywordstyle={[",num+2,"]",kws,"}",sep="")
+ if(withcomma) cat(",")
+ cat("%\n%\n", sep = "")
+# cat(paste("%\n%\n\n"))
.alreadyDefinedPkgs <<- c(.alreadyDefinedPkgs,pkg)
}
return(invisible())
@@ -96,19 +100,38 @@
}else
keywordstyles <- rep(keywordstyles, length.out = lP)
- if(lP) {for(i in 1: lP){
- kwl <- ls(pos = which(pkgs[i] == gsub("package:","",search())))
- kwl <- sort(kwl[grep("^[[:alpha:]]+\\w*",kwl,perl=TRUE)],
- decreasing = TRUE)
- genKWL(pkg = pkgs[i], kwd = kwl,
- kws = keywordstyles[i])}
+ if(lP) {
+ withcomma <- TRUE
+ pos1 <- 0
+ for(i in 1: lP){
+ pos0 <- which(pkgs[i] == gsub("package:","",search()))
+ kwl <- ls(pos = pos0)
+ kwl <- sort(kwl[grep("^[[:alpha:]]+\\w*",kwl,perl=TRUE)],
+ decreasing = TRUE)
+
+ if(i==1){
+ pos1 <- pos0 + length(.alreadyDefinedPkgs)
+ cat("\n\\lstdefinestyle{Rstyle",pos1,"}{style=RstyleO",
+ .numberofRequires,",%\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=Rstyle",
+ pos1,"}\n",
+ "\\lstdefinestyle{RstyleO",.numberofRequires+1,
+ "}{style=Rstyle", pos1,"}\n\n",
+
+ sep="")
+ }
}
return(invisible())
}
changeKeywordstyles <- function(pkgs, keywordstyles){
setkws <- function(num, kws){
- cat("%\n\\lstset%\n")
+ cat("%\n\\lstdefinestyle{Rstyle}%\n")
cat("{keywordstyle={[",num+1,"]",kws,"}\n}\n", sep = "")
}
@@ -238,7 +261,7 @@
kwsI <- kws[idxRec]
grI <- grep("\\\\color\\{.+\\}", kwsI, invert = TRUE)
- kwsI <- gsub("\\\\color\\{.+\\}","\\\\color\\{RRecomdcolor\\}",
+ kwsI <- gsub("\\\\color\\{.[^\\}]+\\}","\\\\color\\{RRecomdcolor\\}",
kwsI)
kwsI[grI] <- gsub("\\}$","\\\\color\\{RRecomdcolor\\}\\}",kwsI[grI])
kws[idxRec] <- kwsI
Modified: pkg/SweaveListingUtils/chm/00Index.html
===================================================================
--- pkg/SweaveListingUtils/chm/00Index.html 2009-07-23 15:45:46 UTC (rev 513)
+++ pkg/SweaveListingUtils/chm/00Index.html 2009-07-28 20:59:46 UTC (rev 514)
@@ -10,7 +10,7 @@
<param name="keyword" value=".. contents">
</object>
-<h2>Help pages for package ‘SweaveListingUtils’ version 0.3.2</h2>
+<h2>Help pages for package ‘SweaveListingUtils’ version 0.3.3</h2>
<table width="100%">
<tr><td width="25%"><a href="0SweaveListingUtils-package.html">SweaveListingUtils-package</a></td>
Modified: pkg/SweaveListingUtils/chm/SweaveListingUtils.chm
===================================================================
(Binary files differ)
Modified: pkg/SweaveListingUtils/chm/taglist.html
===================================================================
--- pkg/SweaveListingUtils/chm/taglist.html 2009-07-23 15:45:46 UTC (rev 513)
+++ pkg/SweaveListingUtils/chm/taglist.html 2009-07-28 20:59:46 UTC (rev 514)
@@ -27,7 +27,8 @@
taglist(..., list = NULL, defname = "V")
## S3 method for class 'taglist':
print(x, LineLength = getOption("width"), offset.start = 0,
- withFinalLineBreak = TRUE, first.print = NULL, ...)
+ withFinalLineBreak = TRUE, first.print = NULL,
+ ErrorOrWarn = "warn", ...)
</pre>
@@ -68,6 +69,10 @@
<td>
character; something to be printed immediately before
the first list item; defaulting to <code>NULL</code>.</td></tr>
+<tr valign="top"><td><code>ErrorOrWarn</code></td>
+<td>
+shall we issue a warning (if partially matched to <code>"warn"</code>
+or else an error</td></tr>
</table>
<h3>Details</h3>
@@ -115,6 +120,6 @@
-<hr><div align="center">[Package <em>SweaveListingUtils</em> version 0.3.2 <a href="00Index.html">Index</a>]</div>
+<hr><div align="center">[Package <em>SweaveListingUtils</em> version 0.3.3 <a href="00Index.html">Index</a>]</div>
</body></html>
Modified: pkg/SweaveListingUtils/inst/NEWS
===================================================================
--- pkg/SweaveListingUtils/inst/NEWS 2009-07-23 15:45:46 UTC (rev 513)
+++ pkg/SweaveListingUtils/inst/NEWS 2009-07-28 20:59:46 UTC (rev 514)
@@ -3,6 +3,12 @@
######################################################################
##############
+v 0.3.3
+##############
+
+* fixed issue with overwriting several "morekeywords" keys
+
+##############
v 0.3.1
##############
* when SweaveListingPreparations is used with argument 'withOwnFileSection'=TRUE
Modified: pkg/SweaveListingUtils/inst/doc/ExampleSweaveListingUtils.Rnw
===================================================================
--- pkg/SweaveListingUtils/inst/doc/ExampleSweaveListingUtils.Rnw 2009-07-23 15:45:46 UTC (rev 513)
+++ pkg/SweaveListingUtils/inst/doc/ExampleSweaveListingUtils.Rnw 2009-07-28 20:59:46 UTC (rev 514)
@@ -463,11 +463,6 @@
lstinputSourceFromRForge("distr","man","BinomParameter-class.Rd","distr")
@
-Note that corresponding examples are still typeset in {\sf R} style;
-however, up to now this will only be done in the (static) {\tt listings} style
-{\tt Rstyle}, as defined in the preamble; keywords from attached packages
-will not be used. Reason for this: I do not yet know how to save a current
-``state of style'' in a corresponding {\tt listings} style.
%
Modified: pkg/SweaveListingUtils/inst/doc/preambleExp.tex
===================================================================
--- pkg/SweaveListingUtils/inst/doc/preambleExp.tex 2009-07-23 15:45:46 UTC (rev 513)
+++ pkg/SweaveListingUtils/inst/doc/preambleExp.tex 2009-07-28 20:59:46 UTC (rev 514)
@@ -2,6 +2,7 @@
\RequirePackage{listings}
%\usepackage{Sweave}
% -------------------------------------------------------------------------------
+% -------------------------------------------------------------------------------
%------------------------------------------------------------------------------%
%Preparations for Sweave and Listings
%------------------------------------------------------------------------------%
@@ -30,20 +31,24 @@
morecomment=[l]\%% 2008/9 Peter Ruckdeschel
}[keywords,comments]%%
%------------------------------------------------------------------------------%
-\lstdefinestyle{Rstyle}{fancyvrb=true,escapechar=§,language=R,%
- % note:
- % '§' replaces accent grave (otherwise difficulties in TeXing this verbatim)
+\lstdefinestyle{Rstyle}{fancyvrb=true,escapechar=§,language=R,% § just for convenience
basicstyle={\color{Rcolor}\small},%
keywordstyle={\bf\color{Rcolor}},%
commentstyle={\color{Rcommentcolor}\ttfamily\itshape},%
- literate={<-}{{$\leftarrow$}}2{<<-}{{$\twoheadleftarrow$}}2%
- {~}{{$\sim$}}1{<=}{{$\leq$}}2%
- {>=}{{$\geq$}}2%
- {^}{{$\scriptstyle\wedge$}}1,%
+ literate={<-}{{$\leftarrow$}}2{<<-}{{$\twoheadleftarrow$}}2{~}{{$\sim$}}1{<=}{{$\leq$}}2{>=}{{$\geq$}}2{^}{{$\scriptstyle\wedge$}}1,%
alsoother={$},%
alsoletter={.<-},%
otherkeywords={!,!=,~,$,*,\&,\%/\%,\%*\%,\%\%,<-,<<-,/},%
escapeinside={(*}{*)}}%
+\lstdefinestyle{RstyleO1}{fancyvrb=true,escapechar=§,language=R,% § just for convenience
+ basicstyle={\color{Rcolor}\small},%
+ keywordstyle={\bf\color{Rcolor}},%
+ commentstyle={\color{Rcommentcolor}\ttfamily\itshape},%
+ literate={<-}{{$\leftarrow$}}2{<<-}{{$\twoheadleftarrow$}}2{~}{{$\sim$}}1{<=}{{$\leq$}}2{>=}{{$\geq$}}2{^}{{$\scriptstyle\wedge$}}1,%
+ alsoother={$},%
+ alsoletter={.<-},%
+ otherkeywords={!,!=,~,$,*,\&,\%/\%,\%*\%,\%\%,<-,<<-,/},%
+ escapeinside={(*}{*)}}%
\lstdefinestyle{Rdstyle}{fancyvrb=true,language=Rd,keywordstyle={\bf},%
basicstyle={\color{black}\footnotesize},%
commentstyle={\ttfamily\itshape},%
@@ -61,16 +66,18 @@
%copying relevant parts of Sweave.sty
%------------------------------------------------------------------------------%
%
+\RequirePackage{graphicx,fancyvrb}%
+\IfFileExists{upquote.sty}{\RequirePackage{upquote}}{}%
+
\RequirePackage{ifthen}%
\newboolean{Sweave at gin}%
\setboolean{Sweave at gin}{true}%
+\setkeys{Gin}{width=0.8\textwidth}%
\newboolean{Sweave at ae}
\setboolean{Sweave at ae}{true}%
-\RequirePackage{graphicx,fancyvrb}%
-\IfFileExists{upquote.sty}{\RequirePackage{upquote}}{}%
-\setkeys{Gin}{width=0.8\textwidth}
\RequirePackage[T1]{fontenc}
\RequirePackage{ae}
+%
\newenvironment{Schunk}{}{}
\newcommand{\Sconcordance}[1]{%
@@ -103,40 +110,41 @@
\def\pkg#1{{\tt "#1"}}
\newcommand{\pkgversion}{{\tt 2.2}}
%------------------------------------------------------------------------------%
+\lstdefinestyle{Rstyle2}{style=RstyleO1,%
% --------------------------
% Registration of package SweaveListingUtils
% --------------------------
-\lstset{morekeywords={[2]taglist,SweaveListingPreparations,SweaveListingOptions,%
-SweaveListingoptions,SweaveListingMASK,setToBeDefinedPkgs,readSourceFromRForge,%
-readPkgVersion,lstsetRd,lstsetR,lstsetLanguage,lstset,lstinputSourceFromRForge,%
-getSweaveListingOption,copySourceFromRForge,changeKeywordstyles%
+morekeywords={[2]taglist,SweaveListingPreparations,SweaveListingOptions,SweaveListingoptions,SweaveListingMASK,%
+setToBeDefinedPkgs,setBaseOrRecommended,readSourceFromRForge,readPkgVersion,lstsetRout,%
+lstsetRin,lstsetRd,lstsetRcode,lstsetR,lstsetLanguage,%
+lstset,lstinputSourceFromRForge,isBaseOrRecommended,getSweaveListingOption,copySourceFromRForge,%
+changeKeywordstyles%
},%
-keywordstyle={[2]{\bf}}%
-}
+keywordstyle={[2]{\bf}},%
%
-%
-
% --------------------------
% Registration of package startupmsg
% --------------------------
-\lstset{morekeywords={[3]suppressStartupMessages,startupType,startupPackage,%
-StartupMessage,startupMessage,startupEndline,readVersionInformation,%
-readURLInformation,pointertoNEWS,onlytypeStartupMessages,%
+morekeywords={[3]suppressStartupMessages,startupType,startupPackage,StartupMessage,startupMessage,%
+startupEndline,readVersionInformation,readURLInformation,pointertoNEWS,onlytypeStartupMessages,%
NEWS,mystartupMessage,mySMHandler,infoShow,buildStartupMessage%
},%
-keywordstyle={[3]{\bf}}%
-}
+keywordstyle={[3]{\bf}},%
%
%
...
-snipped expanded `\TeX` (see how the original `\verb|`\TeX`|` gets escaped!)
+snipped expanded (`\TeX`) (see how the original `(\verb|(`\TeX`)|)` gets escaped!)
code for registration of packages
tools, stats, graphics, grDevices, utils, datasets, methods, base
...
%
+},%
+keywordstyle={[11]{\bf\color{RRecomdcolor}}}%
+%
+}%
+\lstdefinestyle{Rstyle}{style=Rstyle2}
+\lstdefinestyle{RstyleO2}{style=Rstyle2}
+
%------------------------------------------------------------------------------%
-\lstset%
-{keywordstyle={[2]\bf\color{blue}}
-}%
Modified: pkg/SweaveListingUtils/man/taglist.Rd
===================================================================
--- pkg/SweaveListingUtils/man/taglist.Rd 2009-07-23 15:45:46 UTC (rev 513)
+++ pkg/SweaveListingUtils/man/taglist.Rd 2009-07-28 20:59:46 UTC (rev 514)
@@ -8,7 +8,8 @@
\usage{
taglist(..., list = NULL, defname = "V")
\method{print}{taglist}(x, LineLength = getOption("width"), offset.start = 0,
- withFinalLineBreak = TRUE, first.print = NULL, ...)
+ withFinalLineBreak = TRUE, first.print = NULL,
+ ErrorOrWarn = "warn", ...)
}
\arguments{
\item{\dots}{arbitrary number of arguments in \code{taglist}, respectively,
@@ -30,6 +31,8 @@
defaults to \code{TRUE}.}
\item{first.print}{character; something to be printed immediately before
the first list item; defaulting to \code{NULL}.}
+ \item{ErrorOrWarn}{shall we issue a warning (if partially matched to \code{"warn"}
+ or else an error}
}
\details{
More information about the Distr-commits
mailing list