[ESS] RSiteSearch functionality in Emacs

Sebastian Luque spluque at gmail.com
Tue May 2 19:08:02 CEST 2006


Martin Maechler <maechler at stat.math.ethz.ch> wrote:

[...]

> Seth> Seems to work for me (version info below).  One
> Seth> improvement I would like: use all defaults without
> Seth> asking unless called with C-u prefix.

> Good idea.

Yes it is, so here's a new version that does that (works in my system):

---<---------------cut here---------------start-------------->---

(defun r-utils-rsitesearch (string)
  "Search the R archives for STRING, using default criteria.  If called with a prefix,
options are available for 1) matches per page, 2) sections of the
archives to search (separated by value of
`crm-default-separator'), 3) for displaying results in long or
short formats, and 4) 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)))
    (if current-prefix-arg
	(let ((mpp (concat
		    "&max="
		    (completing-read
		     "Matches per page: "
		     '(("20" 1) ("30" 2) ("40" 3) ("50" 4) ("100" 5)))))
	      (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)))
      (browse-url (concat site okstring "&max=20&result=normal&sort=score"
			  "&idxname=Rhelp02a&idxname=functions&idxname=docs")))))

---<---------------cut here---------------end---------------->---

I'll leave it up to more experienced elispers to get more readable options
lists, as that requires post handling of the strings to create the url,
and wouldn't know how to do that.


-- 
Seb




More information about the ESS-help mailing list