Emacs: Command to Lookup Google, Wikipedia, Dictionary, Programing Reference

Buy Xah Emacs Tutorial. Master emacs benefits for life.
, , …,

This page shows you commands/package to lookup the web of the word under cursor.

Download xah-lookup.el

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

Also on MELPA. 〔➤ Emacs: How to Install Packages Using ELPA, MELPA, Marmalade

You can change the default key, or specify Emacs Eww Web Browser as default. See the file header for how.

Command to Lookup Wikipedia

The following shows you how to write your own, to:

Place the following in your emacs init file.

(require 'browse-url) ; in emacs

(defun my-lookup-wikipedia ()
  "Look up the word under cursor in Wikipedia.
If there is a text selection (a phrase), use that.

This command switches you to your browser."
  (let (myWord myUrl)
    (setq myWord
          (if (use-region-p)
              (buffer-substring-no-properties (region-beginning) (region-end))
            (thing-at-point 'word)))

    (setq myWord (replace-regexp-in-string " " "_" myWord))
    (setq myUrl (concat "http://en.wikipedia.org/wiki/" myWord))
    (browse-url myUrl)
    ;; (eww myUrl) ; emacs's own browser

You can setup a key such as F8 for easy access. See: Emacs: How to Define Keys.

You can change the URL in the above definition to other reference sites. Here's the URL syntax for some popular language or reference sites. The “�” should be your search string.

SourceURL Format

Here's a list of online dictionary URLs: Online English Dictionary Tools.

Using a Specific Browser


Like it?
Buy Xah Emacs Tutorial
or share
blog comments powered by Disqus