EWW, Wordnick, and Emacs Satisfaction

I wrote before about EWW, the text-only browser built into Emacs. Last night I’ve implemented a quick lisp function to have it search certain words in Wordnik.

I got some help on the Emacs channel on IRC (My lisp gets rusty, I forgot that “let” in lisp lives only in the instant of the function, it doesn’t implement a permanent change). There, I also learned of Abo-abo’s define-word, which seems promising. However, this function only shows partial definitions in the minibuffe and any key press exists that buffer, making it hard to copy-paste definitions.

There are more options for this function (abo-abo is an amazing Emacs packages contributor) but I couldn’t find more thorough documentation on GitHub or the web. I also wanted something quick and vanilla-Emacs as possible, so I decided to go with my original solution.

To have EWW search a certain word in Wordnik:

(defun wordnik-search ()
  (interactive)
   (let ((eww-search-prefix "https://www.wordnik.com/words/")) (eww-search-words)))

This function uses the built in EWW function eww-search-words, which searches a highlighted word in EWW (M-x M-s). In itself, this is also very useful1.

To understand why you’d want a full page of a definition, you need to use Worknik for a while and get familiar with it. The website is not a mere dictionary like many others, it’s an index of several dictionaries, some of which are rarer to find. My favorite is the century dictionary, though I like to have the “quick and easy” word definition from American Heritage or similar as well.

Each definition in Wordnik also follows with tables of synonyms, rhymes and more. In EWW, there’s also the helpful eww-readable (simply “R”) which:

“View the main “readable” parts of the current web page. This command uses heuristics to find the parts of the web page that contains the main textual portion, leaving out navigation menus and the like.”

This makes reading the word definitions in Wordnik clean and distraction-free. Oh, and while I’m mentioning known-but-forgotten tricks: to highlight a word under the mark, use M-@, which will highlight from where the mark is located. Stand on a word you want to define, hit M-@, and then C-arrow to move to the start of the word (I never got used to M-b or M-f, which are placed awkwardly under the left palm).

Here’s how it looks like on my Emacs:

Wordnik definition for the word "definition" in Emacs

To have these word definitions at your fingertips while you write a post such as this one without ever switching a program or a Window… this is why Emacs is a magical writing machine to me.

Footnotes


  1. EWW uses Duck Duck Go by default, so your searches will come up there. Duck Duck Go is an excellent and privacy-oriented search engine, but it doesn’t stop there. It comes with Bangs, which means you can search certain terms in websites like wikipedia and yes, also wordnick, directly from EWW. ↩︎


Comments