[Sciviews-commits] r298 - in pkg/svMisc: R man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Sep 7 13:07:37 CEST 2010


Author: phgrosjean
Date: 2010-09-07 13:07:37 +0200 (Tue, 07 Sep 2010)
New Revision: 298

Modified:
   pkg/svMisc/R/helpSearchWeb.R
   pkg/svMisc/man/guiCmd.Rd
   pkg/svMisc/man/helpSearchWeb.Rd
Log:
helpSearchWeb() reworked to call RSiteSearch() with type = "R"

Modified: pkg/svMisc/R/helpSearchWeb.R
===================================================================
--- pkg/svMisc/R/helpSearchWeb.R	2010-09-07 09:26:09 UTC (rev 297)
+++ pkg/svMisc/R/helpSearchWeb.R	2010-09-07 11:07:37 UTC (rev 298)
@@ -1,16 +1,24 @@
-helpSearchWeb <- function (apropos, type = c("google", "archive", "wiki"), browse = TRUE)
+helpSearchWeb <- function (what, type = c("R", "archive", "wiki", "google"),
+browse = TRUE, msg = browse, ...)
 {
-	apropos <- paste(apropos, collapse = " ", sep = "")
-	apropos <- gsub(" ", "+", apropos)
-	type <- type[1]
-	RSearchURL <- switch(type,
-		"google" = paste("http://www.google.com/search?sitesearch=r-project.org&q=",
-			apropos, sep = ''),
+	what <- paste(what, collapse = " ", sep = "")
+	what <- gsub(" ", "+", what)
+	type <- match.arg(type)
+	searchURL <- switch(type,
+		"R" = RSiteSearch(what, ...),
 		"archive" = paste("http://www.google.com/u/newcastlemaths?q=",
-			apropos, sep = ''),
+			what, sep = ''),
 		"wiki" = paste("http://rwiki.sciviews.org/doku.php?do=search&id=",
-			apropos, sep = ''),
-		stop("'type' could be only 'google', 'archive' or 'wiki', currently!"))
-	if (isTRUE(browse)) browseURL(RSearchURL)
-	return(invisible(RSearchURL))
+			what, sep = ''),
+		"google" = paste("http://www.google.com/search?sitesearch=r-project.org&q=",
+			what, sep = ''),
+		stop("'type' could be only 'R', 'archive', 'wiki' or 'google', currently!"))
+	if (type != "R") {
+		if (isTRUE(browse)) browseURL(searchURL)
+		if (isTRUE(msg)) {
+			cat(gettext("A search query has been submitted"), "\n")
+			cat(gettext("The results page should open in your browser shortly\n"))
+		}
+	}
+	return(invisible(searchURL))
 }

Modified: pkg/svMisc/man/guiCmd.Rd
===================================================================
--- pkg/svMisc/man/guiCmd.Rd	2010-09-07 09:26:09 UTC (rev 297)
+++ pkg/svMisc/man/guiCmd.Rd	2010-09-07 11:07:37 UTC (rev 298)
@@ -14,14 +14,14 @@
   debugging purposes). It executes a command string to a (compatible) GUI client.
 }
 \usage{
-guiCmd(command, ...)
-guiImport(...)
-guiExport(...)
-guiLoad(...)
-guiReport(...)
-guiSave(...)
-guiSetwd(...)
-guiSource(...)
+guiCmd(command, \dots)
+guiImport(\dots)
+guiExport(\dots)
+guiLoad(\dots)
+guiReport(\dots)
+guiSave(\dots)
+guiSetwd(\dots)
+guiSource(\dots)
 }
 
 \arguments{

Modified: pkg/svMisc/man/helpSearchWeb.Rd
===================================================================
--- pkg/svMisc/man/helpSearchWeb.Rd	2010-09-07 09:26:09 UTC (rev 297)
+++ pkg/svMisc/man/helpSearchWeb.Rd	2010-09-07 11:07:37 UTC (rev 298)
@@ -7,34 +7,44 @@
   \code{apropos} string.
 }
 \usage{
-helpSearchWeb(apropos, type = c("google", "archive", "wiki"), browse = TRUE)
+helpSearchWeb(what, type = c("R", "archive", "wiki", "google"), browse = TRUE,
+    msg = browse, \dots)
 }
 
 \arguments{
-  \item{apropos}{ the string to search. }
+  \item{what}{ the string(s) to search. In case of several strings, or several
+    words, any of these words are searched. }
   \item{type}{ the search engine, or location to use. }
-  \item{browse}{ do we actually show the page in the Web browser? }
+  \item{browse}{ do we actually show the page in the Web browser? If
+    \code{type = "R"}, this argument is ignored and the result is always
+    displayed in the Web browser. }
+  \item{msg}{ do we issue a message indicating that a page should be displayed
+    shortly in the Web browser? If \code{type = "R"}, this argument is ignored
+    and a message is always displayed. }
+  \item{\dots}{ further arguments to format the result page in case of
+    \code{type = "R"}. These are the same arguments as for
+    \code{RSiteSearch()}. }
 }
 
 \value{
-  Returns the URL used invisibly (invoked for its side effect of opening the web
+  Returns the URL used invisibly (invoked for its side effect of opening the Web
   browser with the search result, when \code{browse = TRUE}).
 }
 
 \author{ David Forrest <drf at vims.edu> & Philippe Grosjean <phgrosjean at sciviews.org>
-after Barry Rowland's original code }
+  after Barry Rowland's original code }
 
 \note{
-  The \code{RSiteSearch()} function in the 'utils' package is much more complete
-  but it does not search specific places, like the R Wiki. So, this function
-  is a complement.
+  The \code{RSiteSearch()} function in the 'utils' package is used when
+  \code{type = "R"}.
 }
 
 \seealso{ \code{\link[utils]{RSiteSearch}}, \code{\link[utils]{help.search}} }
 
 \examples{
 \dontrun{
-helpSearchWeb("volatility")                    # Google search, by default
+helpSearchWeb("volatility")                    # R site search, by default
+helpSearchWeb("volatility", type = "google")   # Google search
 helpSearchWeb("volatility", type = "archive")  # In the mailing list archive
 helpSearchWeb("median mean", type = "wiki")    # In the R Wiki
 }



More information about the Sciviews-commits mailing list