If anyone's interested, I've updated the searchengines patch to succeed with the latest hg pull.
The diff: diff -r dbb565b8d61c config.def.h --- a/config.def.h Fri Jun 25 09:42:58 2010 +0200 +++ b/config.def.h Fri Aug 13 16:28:31 2010 -0400 @@ -7,6 +7,10 @@ static char *cookiefile = ".surf/cookies.txt"; static time_t sessiontime = 3600; #define NOBACKGROUND 0 +static SearchEngine searchengines[] = { + { "g", "http://www.google.com/search?q=%s" }, + { "leo", "http://dict.leo.org/ende?search=%s" }, +}; #define SETPROP(p, q) { .v = (char *[]){ "/bin/sh", "-c", \ "prop=\"`xprop -id $2 $0 | cut -d '\"' -f 2 | dmenu`\" &&" \ diff -r dbb565b8d61c surf.c --- a/surf.c Fri Jun 25 09:42:58 2010 +0200 +++ b/surf.c Fri Aug 13 16:28:31 2010 -0400 @@ -55,6 +55,11 @@ const Arg arg; } Key; +typedef struct { + char *token; + char *uri; +} SearchEngine; + static Display *dpy; static Atom atoms[AtomLast]; static Client *clients = NULL; @@ -90,6 +95,7 @@ static Client *newclient(void); static void newwindow(Client *c, const Arg *arg); static void newrequest(SoupSession *s, SoupMessage *msg, gpointer v); +static gchar *parseuri(const gchar *uri); static void pasteuri(GtkClipboard *clipboard, const char *text, gpointer d); static void print(Client *c, const Arg *arg); static GdkFilterReturn processx(GdkXEvent *xevent, GdkEvent *event, gpointer d); @@ -388,8 +394,7 @@ if(strcmp(uri, "") == 0) return; - u = g_strrstr(uri, "://") ? g_strdup(uri) - : g_strdup_printf("http://%s", uri); + u = parseuri(uri); /* prevents endless loop */ if(c->uri && strcmp(u, c->uri) == 0) { reload(c, &a); @@ -562,6 +567,19 @@ spawn(NULL, &a); } + +gchar * +parseuri(const gchar *uri) { + guint i; + for (i = 0; i < LENGTH(searchengines); i++) { + if (searchengines[i].token == NULL || searchengines[i].uri == NULL || *(uri + strlen(searchengines[i].token)) != ' ') + continue; + if (g_str_has_prefix(uri, searchengines[i].token)) + return g_strdup_printf(searchengines[i].uri, uri + strlen(searchengines[i].token) + 1); + } + return g_strrstr(uri, "://") ? g_strdup(uri) : g_strdup_printf("http://%s", uri); +} + void pasteuri(GtkClipboard *clipboard, const char *text, gpointer d) { Arg arg = {.v = text };