Search module:XMonad.Actions
A customized prompt indicating we are searching, and the name of the
site.
Given a browser, a search engine's transformation function, and a
search term, perform the requested search in the browser.
A generator for rearrangers that append a single element based on the
search string, if doing so would not be redundant (empty string or
value already present).
Given a base URL, create the
SearchEngine that escapes the
query and appends it to the base. You can easily define a new engine
locally using exported functions without needing to modify
XMonad.Actions.Search:
myNewEngine = searchEngine "site" "https://site.com/search="
The important thing is that the site has a interface which accepts the
escaped query string as part of the URL. Alas, the exact URL to feed
searchEngine varies from site to site, often considerably, so there's
no general way to cover this.
Generally, examining the resultant URL of a search will allow you to
reverse-engineer it if you can't find the necessary URL already
described in other projects such as Surfraw.
If your search engine is more complex than this (you may want to
identify the kind of input and make the search URL dependent on the
input or put the query inside of a URL instead of in the end) you can
use the alternative
searchEngineF function.
searchFunc :: String -> String
searchFunc s | "wiki:" `isPrefixOf` s = "https://en.wikipedia.org/wiki/" ++ (escape $ drop 1 $ snd $ break (==':') s)
| "https://" `isPrefixOf` s = s
| otherwise = (use google) s
myNewEngine = searchEngineF "mymulti" searchFunc
searchFunc here searches for a word in wikipedia if it has a
prefix of "wiki:" (you can use the
escape function to escape
any forbidden characters), opens an address directly if it starts with
"https://" and otherwise uses the provided google search engine. You
can use other engines inside of your own through the
use
function as shown above to make complex searches.
The user input will be automatically escaped in search engines created
with
searchEngine,
searchEngineF, however, completely
depends on the transformation function passed to it.
This navigation style combines navigation and search into one mode at
the cost of losing vi style navigation. With this style, there is no
substring search submode, but every typed character is added to the
substring search.
Navigation submode used for substring search. It returns to the first
argument navigation style when the user hits Return.
Apply a transformation function the current search string
Like
search, but in this case, the string is not specified but
grabbed from the user's response to a prompt. Example:
, ((modm, xK_g), promptSearch greenXPConfig google)
This specializes "promptSearchBrowser" by supplying the browser
argument as supplied by
getBrowser from
XMonad.Prompt.Shell.
Like
search, but for use with the output from a Prompt; it
grabs the Prompt's result, passes it to a given searchEngine and opens
it in a given browser.
Like
search, but for use with the X selection; it grabs the
selection, passes it to a given searchEngine and opens it in the
default browser . Example:
, ((modm .|. shiftMask, xK_g), selectSearch google)
This specializes "selectSearchBrowser" by supplying the browser
argument as supplied by
getBrowser from
XMonad.Prompt.Shell.
Like
search, but for use with the X selection; it grabs the
selection, passes it to a given searchEngine and opens it in a given
browser.