[ESS] RSiteSearch functionality in Emacs
Sebastian Luque
spluque at gmail.com
Tue May 2 02:17:49 CEST 2006
Hi,
Without knowing how to tell R to use w3m from within Emacs, and after
switching to Konqueror's window for the millionth time, I wrote the
following function:
---<---------------cut here---------------start-------------->---
(defun r-utils-rsitesearch (string)
"Search the R archives for STRING, with options for matches per
page, sections of the archives (space or comma separated strings)
to search, for displaying results in long or short formats, and
for sorting by any given field. Completion is available for
supplying options."
(interactive "sSearch string: ")
(let ((site "http://search.r-project.org/cgi-bin/namazu.cgi?query=")
(okstring (replace-regexp-in-string " +" "+" string))
(mpp (concat "&max="
(completing-read
"Matches per page: "
'(("20" 1) ("30" 2) ("40" 3) ("50" 4) ("100" 5))
nil nil "20" nil "20")))
(format (concat "&result="
(completing-read
"Format: " '("normal" "short")
nil t "normal" nil "normal")))
(sortby (concat "&sort="
(completing-read
"Sort by: "
'(("score" 1) ("date:late" 2) ("date:early" 3)
("field:subject:ascending" 4)
("field:subject:decending" 5)
("field:from:ascending" 6) ("field:from:decending" 7)
("field:size:ascending" 8) ("field:size:decending" 9))
nil t "score" nil "score")))
(restrict (concat
"&idxname="
(mapconcat 'identity
(completing-read-multiple
"Limit search to: "
'(("Rhelp02a" 1) ("functions" 2) ("docs" 3)
("Rhelp01" 4))
nil t "Rhelp02a,functions,docs" nil
"Rhelp02a,functions,docs") "&idxname="))))
(browse-url (concat site okstring mpp format sortby restrict))))
---<---------------cut here---------------end---------------->---
This emulates some of the functionality of RSiteSearch() and tests ok in
my system GNU Emacs 22.0.50.1 (i486-pc-linux-gnu, X toolkit, Xaw3d scroll
bars) of 2006-04-27 on pacem, modified by Debian. This has the benefit of
displaying results with whatever you've told browse-url to use; in my
case, w3m with the emacs-w3m package.
My elisp skills are rather poor, so comments and suggestions for
improvement are welcome.
--
Seb
More information about the ESS-help
mailing list