Tuesday, November 03, 2009

Making Vimperator 2.2+ work with Delicious keywords

This blog post echos the same information as issue 138, which describes a tiny plugin delicious_addon_kw_hack.js that can be used to restore compatibility with the Delicious add-on.
As discussed in issue 120, as of changeset da9c0a1a532d of Vimperator v2.2b1, Vimperator's ":open" will stop recognizing keywords imported from Delicious bookmarks via the the Delicious Firefox add-on.

A simple way to fix the problem is to drop the following code:
bookmarks.getSearchURL = function(text, useDefsearch) {
let url = null;
let postData = {};
let searchString =
(useDefsearch ? options["defsearch"] + " " : "")
+ text;

this.getSearchEngines();

url = window.getShortcutOrURI(searchString, postData);

if (url == searchString)
return null;

if (postData && postData.value)
return [url, postData.value];

return [url, null]; // can be null
}
into a file like delicious_addon_kw_hack.js into your ~/.vimperator/plugin/ directory (or the equivalent directory under Windows; see :help plugins for more details).

6 comments:

Anonymous said...

thanks a lot!

codekiln said...

wait a second - this overrides the custom defsearch i had in my .vimperatorrc. how do i make it use the regular search if there's no keyword?

codekiln said...

also, this doesn't allow search parameters, does it?

Ted said...

It is possible that the code snippet does break defsearch. I can verify that my own defsearch is set to "google", but the functionality definitely isn't working. I never noticed this before because I don't use defsearch. However, I cannot verify that search parameters are broken. I know that "google stuff" and "maps stuff" and "doi stuff" all do the right thing. HOWEVER, I know those keywords exist within my del.icio.us bookmarks. It may be the case that quick searches that are not in del.icio.us don't work with parameters; I just don't know.

The code was actually lifted from a previous revision of vimperator's own code, and so once upon a time this code supported all vimperator features. However, new vimperator code may have migrated away from this code. The code was changed in vimperator for technical reasons. In particular, keywords functionality was needed within the entire liberator library, and so the code was moved into the liberator framework and made to not depend on things that only live within Firefox. At that instant, Delicious integration became impossible.

Mike Chen said...

Thanks! The defsearch thing was annoying me so I modified your hack slightly. The changes are:

5: (useDefSearch ? options["defsearch"] + " " : "")

13: return null;

Pretty simple, just a variable typo and the calling function expecting null, not an array of nulls before it retries with useDefsearch=true.

Ted said...

Good fixes, Mike. I actually don't think those were originally typos. That code was ripped out of an old version of Vimperator. I just think that the internals it referenced changed, which is what broke the defsearch. Your fixes put this code back in sync with the rest. Thanks!