Add facility to allow user functions to transform typed URLs.
commit9ac33a0f3eb299788a2b7bd8725a5e2c43a86af5
authorDavid Kettler <kettler@internode.on.net>
Sat, 29 Nov 2008 09:22:05 +0000 (29 19:52 +1030)
committerDavid Kettler <David.Kettler@dsto.defence.gov.au>
Mon, 1 Dec 2008 23:13:20 +0000 (2 09:43 +1030)
tree89f8853b5d9933b0731e0f018d8e692f62c9ba36
parent4d3ba19ede34b4a11513ca57db6ab1524a876d7a
Add facility to allow user functions to transform typed URLs.

If the typed input to read-url and friends is not (something like) a
valid URL or webjump then a list of user defined "handler" functions
can be called to try to transform the input into something valid.

A handler generator is provided to prepend a given webjump keyword to
the typed input.  This means that an input of an arbitrary set of
words will search on those words.  There has to be more than one word
though, otherwise it might be the name of a web site.  And the first
word can't be a webjump.

Example usage:

  read_url_handler_list = [read_url_make_default_webjump_handler("google")];

A handler generator is provided to transform a blank (empty) input
into a given url (or webjump).  Useful for the obsessive, but can also
be used to run some arbitrary javascript.

This facility doesn't really check if the typed URL is valid;
possibly_valid_url() is just a heuristic.  A real validity check would
probably need support from nsIWebNavigation; probably it would need to
attempt the load.  But then behaviour would depend on whether some
site is up.  The heuristic might be best.

A useful enhancement would be to define the functions with a variation
of interactive(), which would provide documentation and make them
clearly part of the browser configuration.  The hook mechanism is also
related.  That's a little harder when using higher order functions,
such as those provided.

With thanks to John Foerch for review and suggestions.
modules/content-buffer.js
modules/utils.js