[xmonad] darcs patch: intelligent searches in XMonad.Action.Search

Gwern Branwen gwern0 at gmail.com
Mon Jan 26 10:56:42 EST 2009

Hash: SHA512

On Mon, Jan 26, 2009 at 9:18 AM, Michał Trybus  wrote:
> Hi,
> Here's a patch for something I've been missing in the Search action.
> It makes it possible to create your own search engine which uses
> a function to transform a search query into a URL instead of joining
> two strings.
> You can also easily connect many search engines into one that takes
> a query with a prefix to identify which of the engine to use. There's also
> a modifier which will take a search engine and wrap it so that if the search
> term is a URL it will go directly to the address (useful with selectSearch)
> Sorry for my code. I'm new to haskell.

A quick review: all '[Char]' should be replaced by 'String'.
Is it possible to improve:

+> searchFunc ('w':'i':'k':'i':':':x) =
"http://en.wikipedia.org/wiki/" ++ (escape x)
+> searchFunc s@('h':'t':'t':'p':':':'/':'/':x) = s

with a guard instead? pattern-matching on Strings is, as you can see,
rather unpleasant and a little confusing because of the ':'

+   @searchFunc :: [Char] -> [Char]@ here searches for a word in
wikipedia if it has a prefix

I would usually include the type sig in the code itself, as it makes
the code more 'durable' if you will when copied, and makes the prose
more readable.

In general, this patch looks worthwhile (although I doubt I'll use the
more advanced functionality).

- --
Version: GnuPG v1.4.9 (GNU/Linux)


More information about the xmonad mailing list