README.md

engine-mode

engine-mode is a global minor mode for Emacs. It enables you to easily define
search engines, bind them to keybindings, and query them from the comfort of
your editor.

For example, suppose we want to be able to easily search GitHub:

(defengine github
"https://github.com/search?ref=simplesearch&q=%s")

This defines an interactive function engine/search-github. When executed it
will take the selected region (or prompt for input, if no region is selected)
and search GitHub for it, displaying the results in your default browser.

The defengine macro can also take an optional key combination, prefixed with
engine/keymap-prefix (which defaults to "C-x /"):

(defengine duckduckgo
"https://duckduckgo.com/?q=%s":keybinding"d")

C-x / d is now bound to the new function engine/search-duckduckgo! Nifty.

Installation

You can also install it like any other elisp file by adding it to your load path
and globally enabling it:

(require'engine-mode)
(engine-mode t)

Changing your default browser

engine-mode uses the engine/browser-function variable to determine which
browser it should use to open the URL it constructs. To change the default
browser, redefine engine/browser-function. For example, to always use Emacs'
built-in eww browser:

(setq engine/browser-function 'eww-browse-url)

engine/browser-function defaults to browse-url-browser-function, which Emacs
uses globally to open links.

The implementation of the browse-url-browser-function variable contains a
comprehensive list of possible browser functions. You can get to that by hitting
C-h v browser-url-browser-function <RETURN> and following the link to
browse-url.el.

Changing your browser on a per-engine basis

To only change the browser for a single engine, use the :browser keyword
argument when you define the engine. For example, to use eww only for your
GitHub search results, try:

Modifying the search term before sending it

An engine might want to transform a search term in some way before it
interpolates the term into the URL. Maybe the term should have a different
encoding, or be capitalized differently, or, uh, be passed through ROT13.
Whatever the reason, you can apply a custom transformation to a search term by
passing a function to defengine through the :term-transformation-hook
keyword argument.