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]