Wordnet and Emacs

Something else I did to pass the time. This is going into my posts.el file, with the keybinding C-c w.

(defun get-current-word () 
  "Returns the current, or the last entered word."
    (setq start (point))
    (setq end (point))
    (buffer-substring-no-properties start end)))

(defvar wordnet-bin-path 
  "This should point to the full path of the wordnet command")

(defun wordnet-current-word ()
  "Shows the Wordnet overview for the current word." 
    (let ((buf (get-buffer-create "*wordnet*"))
          (word (get-current-word)))
        (set-buffer buf)
        (clear-buffer buf)
        (insert (concat "Wordnet overview for " word ": "))
        (call-process wordnet-bin-path nil "*wordnet*" t word "-over")
        (switch-to-buffer "*wordnet*")
        (read-string "Press Enter to continue… ")))))

(defun clear-buffer (buf)
  "Clear a buffer"
    (set-buffer buf)
    (kill-region (point-min) (point-max))))

For those that don’t speak code, that thing will show me the Wordnet overview of any word I’m currently typing. Boring, but a tiny-bit useful. To me.

Update: added the clear-buffer function definition. I forgot it’s not a built-in.