From 24dc09aa48e7b2a569aa8c0201c485cfec04ef55 Mon Sep 17 00:00:00 2001 From: "v.dijk.bas" Date: Thu, 31 Jan 2008 13:26:20 +0100 Subject: Added a handy tip to the documentation of XMonad.Actions.Search The tip explains how to use the submap action to create a handy submap of keybindings for searching. darcs-hash:20080131122620-4237f-af8af65fe7f3189e5d6d9c6b162afdf214765756.gz --- XMonad/Actions/Search.hs | 48 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) (limited to 'XMonad/Actions/Search.hs') diff --git a/XMonad/Actions/Search.hs b/XMonad/Actions/Search.hs index 3e1b325..caae13c 100644 --- a/XMonad/Actions/Search.hs +++ b/XMonad/Actions/Search.hs @@ -28,6 +28,9 @@ module XMonad.Actions.Search ( -- * Usage scholar, wayback, wikipedia + -- * Tip + -- $tip + ) where import Data.Char (chr, ord, isAlpha, isMark, isDigit) @@ -79,7 +82,50 @@ import XMonad.Util.XSelection (getSelection) * 'wikipedia' -- basic Wikipedia search. Feel free to add more! +-} + +{- $tip + +In combination with "XMonad.Actions.Submap" you can create a powerfull +and easy way to search without adding a whole bunch of bindings: + +First import the necessary modules: + +@ +import qualified XMonad.Prompt as P +import qualified XMonad.Actions.Submap as SM +import qualified XMonad.Actions.Search as S +@ + +Then add the following to your key bindings: + +@ + -- Search commands + , ((modm, xK_s), SM.submap $ searchEngineMap $ S.promptSearch P.defaultXPConfig) + , ((modm .|. shiftMask, xK_s), SM.submap $ searchEngineMap $ S.selectSearch) +@ + +where: + +@ + searchEngineMap method = M.fromList $ + [ ((0, xK_g), method \"firefox\" S.google) + , ((0, xK_h), method \"firefox\" S.hoogle) + , ((0, xK_w), method \"firefox\" S.wikipedia) + ] +@ + +Make sure to set firefox to open new pages in a new window instead of in a new tab: +Firefox -> Edit -> Preferences -> Tabs -> New pages should be opened in... + +Now /modm-s g/ \/ /h/ \/ /w/ prompts you for a search string, then opens a new +firefox window that performs the search on Google, Hoogle or +Wikipedia respectively. + +If you select something in whatever application and hit /modm-shift-s g/ \/ /h/ \/ /w/ +it will search the selected string with the specified engine. +Happy searching! -} -- A customized prompt. @@ -164,4 +210,4 @@ promptSearch config browser site = mkXPrompt Search config (getShellCompl []) $ -} selectSearch :: MonadIO m => Browser -> SearchEngine -> m () -selectSearch browser searchEngine = search browser searchEngine =<< getSelection \ No newline at end of file +selectSearch browser searchEngine = search browser searchEngine =<< getSelection -- cgit v1.2.3