Thursday, May 7, 2009

emacs: Searching programming API's with webjump


Image by MarkyBon

In a previous post I outlined how to use webjump, a built in feature of emacs to quickly launch web pages in a browser, after querying the user for search phrases and so on.

This describes how to simply setup webjump to search the API documentation for whatever framework you are using. The example will be Java's Platform documentation. 



  1. Find the base url you want to search. We will use google to only find things that begin with this. In the case of Javas documentation I'm going to search at http://java.sun.com/javase/6/docs/api/
  2. Set up the web jump code as below. The three arguments in square brackets are [ base url, normal search url prefix, search url post fix ]. You just need to replace the JAVA API part of my URL with the URL you are interested in.
  3. M-x webjump
  4. Type your query and hit enter
  5. Browser opens with search results






(require 'webjump)
(global-set-key [f2] 'webjump)
(setq webjump-sites
(append '(
("Java API" .
[simple-query "www.google.com" "http://www.google.ca/search?hl=en&as_sitesearch=http://java.sun.com/javase/6/docs/api/&q=" ""])
)
webjump-sample-sites))



1 comment:

SETH said...

This rocks. Thanks for pointing it out.