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

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

This home page of the emacs package “xah-lookup.el”.

This page also shows you how to write emacs commands to lookup the web of the word under cursor.

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

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

Download

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

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

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."
  (interactive)
  (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
Perlhttp://perldoc.perl.org/search.html?q=�
PHPhttp://us.php.net/�
LSLhttp://wiki.secondlife.com/wiki/�
AutoHotkeyhttp://www.autohotkey.com/docs/commands/�.htm
Wikipediahttp://en.wikipedia.org/wiki/�
Googlehttp://www.google.com/search?q=�
binghttp://www.bing.com/search?q=�
Wolfram|Alphahttp://www.wolframalpha.com/input/?i=�

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

Using a Specific Browser

See:

back to Xah Emacs Packages

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