Emacs: Command to Lookup Doc on Web 📜
Command to Search Web, or Lookup Function Doc, Word Definition
put this in your Emacs Init File:
(defun xah-lookup-web () "Lookup current word or text selection in web search. URL `http://xahlee.info/emacs/emacs/emacs_lookup_ref.html' Created: 2017-02-09 Version: 2026-01-07" (interactive) (let ((xword (if (region-active-p) (buffer-substring-no-properties (region-beginning) (region-end)) (current-word t)))) (browse-url (format "https://search.brave.com/search?q=%s" xword))))
This is useful when you are writing a major mode for a programing language. You want to provide a command that lookup function (the word under cursor)'s documentation.
To make this command search different search engine, you just need to change the URL.
Change browse-url to eww if you want to use emacs browser
〔see Emacs: Eww Web Browser〕
Emacs, Web Browser
Elisp, writing a major mode. Essentials
- Elisp: Write a Major Mode for Syntax Coloring
- Elisp: Font Lock Mode
- Elisp: Syntax Color Comments
- Elisp: Write Comment/Uncomment Command
- Elisp: Keyword Completion
- Elisp: Create Keymap (keybinding)
- Elisp: Create Function Templates
- Emacs: Command to Lookup Doc on Web 📜
- Elisp: Create a Hook
- Elisp: Major Mode Names
- Elisp: provide, require, features
- Elisp: load, load-file, autoload
- Elisp: Syntax Table