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 URL or 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)

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.

Reference sites URL
SourceURL Format
Perl refhttp://perldoc.perl.org/search.html?q=WORD
PHP refhttp://us.php.net/WORD
AutoHotkey refhttp://www.autohotkey.com/docs/commands/WORD.htm
Wolfram Alphahttp://www.wolframalpha.com/input/?i=WORD
Spanish Dictionary 1http://dle.rae.es/?w=WORD
Spanish Dictionary 2http://www.linguee.es/espanol-ingles/search?source=auto&query=WORD

For a list of English online dictionary URLs, see

Online Dictionaries

Like my tutorial? Put $5 at patreon

Or Buy Xah Emacs Tutorial

Or buy a nice keyboard: Best Keyboard for Emacs

Ask me question on patreon