Emacs: xah-lookup.el, Lookup the Web

By Xah Lee. Date: . Last updated: .

Emacs package “xah-lookup.el” gives you the following commands.

If there's a text selection (a phrase you want to lookup), these commands will lookup the selected text.


github: https://github.com/xahlee/lookup-word-on-internet

Also on MELPA http://melpa.org/#/xah-lookup

[see Emacs: How to Install Packages Using ELPA, MELPA]

Manual Install

To install manually, place this file xah-lookup.el in the directory ~/.emacs.d/lisp/

Then, place the following code in your emacs init file

(add-to-list 'load-path "~/.emacs.d/lisp/")
(require 'xah-lookup)


Using Emacs Builtin Browser

If you prefer to use emacs builtin eww browser, put the following in your emacs init.

(require 'eww)
(setq xah-lookup-browser-function 'eww) ; must come before loading xah-lookup
(require 'xah-lookup)

For operating system's default browser, use 'browse-url instead of 'eww

[see Emacs: Eww Web Browser]

Change Keybinding

To change/add keys, put the following in your emacs init. For example:

(define-key help-map (kbd "7") 'xah-lookup-google) ; C-h 7
(global-set-key (kbd "<f2>") 'xah-lookup-wikipedia) ; F2

[see Emacs: How to Define Keys]

Change URL or Browser for Each Command

Each command can use a different reference site URL or different browser. For example:

(require 'xah-lookup)
(require 'eww)
(put 'xah-lookup-word-definition 'xah-lookup-url "http://www.thefreedictionary.com/word02051")
(put 'xah-lookup-word-definition 'xah-lookup-browser-function 'eww)

The word02051 is the lookup word query string place-holder.

Lookup Programing Language Docs

You can create your own lookup command to lookup ruby, php, clojure, etc. For example:

(defun my-lookup-php (&optional @word)
  "lookup php doc of word under cursor"
  (require 'xah-lookup)
   (get 'my-lookup-php 'xah-lookup-url )
   (get 'my-lookup-php 'xah-lookup-browser-function )))

(put 'my-lookup-php 'xah-lookup-url "http://us.php.net/word02051")
(put 'my-lookup-php 'xah-lookup-browser-function 'browse-url)

Online Reference URLs

Here's the URL syntax for some popular language or reference sites. The “WORD” should be your search string.

For a list of English online dictionary URLs, see

Online Dictionaries

Patreon me $5 patreon

Or Buy Xah Emacs Tutorial

Or buy a nice keyboard: Best Keyboard for Emacs

If you have a question, put $5 at patreon and message me.