Jump to Java Documentation from Emacs

Update January 2013: this package has been refined and formally renamed to javadoc-lookup. The user interface is essentially the same — under different function names — but with some extra goodies. It's available for install from MELPA.

I keep running to either a search engine or, when offline, manually browsing to Java API documentation when I need to look something up. When I'm using Emacs this is stupid, so I fixed it. I put together a java-docs package that let's me quickly jump to documentation from within Emacs.

Repository: git clone git://github.com/skeeto/javadoc-lookup.git

Unfortunately it launches it in a web browser right now because there doesn't seem to be a reasonable way to render the documentation inside Emacs itself. So you'll need to have browse-url set up properly in your configuration.

I strongly recommend you use this with Ido, which comes with Emacs. If you do, you'll want to load it after you enable ido-mode, which will enable the Ido minibuffer completion in java-docs.

So, after you require java-docs, you give it a list of places to look for documentation.

(require 'java-docs)
(java-docs "/usr/share/doc/openjdk-6-jdk/api" "~/src/project/doc")

It will scan these locations and build up an index of classes. If you're using a recent enough version of Emacs it will cache that index for faster loading in the future, since on certain systems it can needlessly take a bit of time.

After that you can jump to documentation with C-h j (java-docs-lookup). It will ask you what you want to look up and offer completion with your preferred completion function.

If you don't want to open it up in an external browser, you can set Emacs to run a text-based browser inside itself.

(setq browse-url-browser-function 'browse-url-text-emacs)

Have a comment on this article? Start a discussion in my public inbox by sending an email to ~skeeto/public-inbox@lists.sr.ht [mailing list etiquette] , or see existing discussions.

This post has archived comments.

null program

Chris Wellons

wellons@nullprogram.com (PGP)
~skeeto/public-inbox@lists.sr.ht (view)