[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Additional dict server for dictionary.el

From: Xah
Subject: Re: Additional dict server for dictionary.el
Date: Mon, 3 Nov 2008 14:43:28 -0800 (PST)
User-agent: G2/1.0

i took some time to solve problem about “dictionary.el”.

Now, with the following customized command, one can now effectively
select a set of dictionaries as the default dicts to lookup, with
their results in one pane. The cursor stays in the original pane. And
if the word under cursor is plural, e.g. chairs, or a phrase (e.g.
“Union Jack”), you can select parts of the word or phrase, and the
lookup will use that text selection.

Here's the code:

(defun lookup-word-def ()
  "Look up current word's definition in WordNet, Webster 1913, Moby
If there is a text selection (a phrase), lookup that phrase.
This command needs “dictionary.el” installed."
 (let (myword myurl meat navigText pos)
   (setq myword
         (if (and transient-mark-mode mark-active)
             (buffer-substring-no-properties (region-beginning)
           (thing-at-point 'symbol)))
   (require 'dictionary)
   ;; (dictionary-do-search "fancy" "web1913" 'dictionary-display-
   (dictionary-new-search (cons myword "wn"))
   (setq meat (buffer-substring (point-min) (point-max)))

   (dictionary-new-search (cons myword "web1913"))
   (setq meat (concat meat (buffer-substring (point-min) (point-

   (dictionary-new-search (cons myword "moby-thes"))
   (setq meat (concat meat (buffer-substring (point-min) (point-

   (switch-to-buffer "*my dict results*")
   (insert meat)
   (goto-char 1) (next-line 2)
   (setq pos (point))

   (setq navigText (buffer-substring 1 pos))

   (goto-char 1)
   ;; remove navigation text
        "[Back] [Search Definition]         [Matching words]
       [Select Dictionary]         [Select Match Strategy]
" nil t
"-----------------------------------------------------------------" t

   ;; remove message about how many def found. e.g. “1 definition
   (goto-char 1)
       (search-forward-regexp "[0-9]+ definitions* found\n\n" nil t)
     (replace-match "" t t))

   (goto-char (point-max))
   (insert navigText)
   (goto-char 1)
   (other-window 1)

The major content of this thread is now cleaned up and summarized as a
tutorial and a essay at:

• Dictionary and Reference Lookup with Emacs

• Problems of Open Source Dictionaries


reply via email to

[Prev in Thread] Current Thread [Next in Thread]