[ESS] Is html help configurable now?

Seb spluque at gmail.com
Thu Oct 29 20:32:25 CET 2009


On Mon, 05 Oct 2009 09:51:47 +0100,
Stephen Eglen <S.J.Eglen at damtp.cam.ac.uk> wrote:

[...]

> (I've recently started using w3m under Emacs, and it is great for
> limited browsing, so I could investigate getting ESS and w3m to
> co-operate.)

I've also been an asiduous user of w3m (via its Debian w3m-el Emacs
interface in Debian).  Since the new help system, however, the function
I was using to display the html broke.  I was able to get back the
functionality with this:

o A function in ~/.Rprofile:

---<--------------------cut here---------------start------------------->---
.rutils.help.start <- function (update=FALSE, gui="irrelevant",
                                browser=getOption("browser"), remote=NULL) {
    if (!is.function(browser) && (length(browser) != 1 || !is.character(browser) ||
        !nzchar(browser)))
        stop("invalid browser name, check options(\"browser\").")
    home <- if (is.null(remote)) {
        if (tools:::httpdPort == 0L)
            tools::startDynamicHelp()
        if (tools:::httpdPort > 0L) {
            if (update)
                make.packages.html()
            paste("http://127.0.0.1:", tools:::httpdPort, sep="")
        }
        else stop("help.start() requires the HTTP server to be running",
            call.=FALSE)
    }
    else remote
    paste(home, "/doc/html/index.html", sep="")
}
---<--------------------cut here---------------end--------------------->---

  that's just a hacked help.start() to return only the URL that R's http
  server produced.

o A simple Emacs Lisp function to parse and display in w3m:

---<--------------------cut here---------------start------------------->---
(defun r-utils-htmldocs ()
  "Use w3m to navigate R html documentation.
Documentation is produced by a hacked help.start()."
  (interactive)
  (let ((rhtml ".rutils.help.start()\n")
	(tmpbuf (get-buffer-create "**r-utils-mode**")))
    (ess-command rhtml tmpbuf)
    (set-buffer tmpbuf)
    (let* ((begurl (search-backward "http://"))
    	   (endurl (search-forward "index.html"))
    	   (url (buffer-substring-no-properties begurl endurl)))
      (w3m-goto-url-new-session url))
    (kill-buffer tmpbuf)))
---<--------------------cut here---------------end--------------------->---

The `r-utils-mode' comes from r-utils.el, but could be set to anything
else.

There might be better/more efficient ways to do it, but this works well
for me in GNU Emacs 23.1.50.1 (x86_64-pc-linux-gnu, GTK+ Version 2.18.3)
of 2009-10-23 on elegiac, modified by Debian and ESS 5.5.

BTW, can I give you an updated r-utils.el (I see that the one on the
website is rather old)?

-- 
Seb



More information about the ESS-help mailing list