all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Xah <xahlee@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: Additional dict server for dictionary.el
Date: Mon, 3 Nov 2008 14:43:28 -0800 (PST)	[thread overview]
Message-ID: <c003e685-eadd-4bf6-bebc-82ae59b2e5cd@u29g2000pro.googlegroups.com> (raw)
In-Reply-To: b412ff00-ff3b-45f7-a7be-8585920219e8@o4g2000pra.googlegroups.com


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
Thesaurus.
If there is a text selection (a phrase), lookup that phrase.
This command needs “dictionary.el” installed."
 (interactive)
 (let (myword myurl meat navigText pos)
   (setq myword
         (if (and transient-mark-mode mark-active)
             (buffer-substring-no-properties (region-beginning)
(region-end))
           (thing-at-point 'symbol)))
   (require 'dictionary)
   ;; (dictionary-do-search "fancy" "web1913" 'dictionary-display-
search-result)
   (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-
max))))

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

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

   (setq navigText (buffer-substring 1 pos))

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

   ;; remove message about how many def found. e.g. “1 definition
found”.
   (goto-char 1)
   (while
       (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
http://xahlee.org/emacs/emacs_lookup_ref.html

• Problems of Open Source Dictionaries
http://xahlee.org/Periodic_dosage_dir/bangu/dict_open_source_probs.html

  Xah
∑ http://xahlee.org/

  reply	other threads:[~2008-11-03 22:43 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.2428.1225315094.25473.help-gnu-emacs@gnu.org>
2008-10-30 22:27 ` Additional dict server for dictionary.el Xah
2008-10-30 23:45   ` Xah
2008-11-01 10:36     ` Xah
2008-11-03 22:43       ` Xah [this message]
2008-10-29 21:17 Sven Bretfeld

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c003e685-eadd-4bf6-bebc-82ae59b2e5cd@u29g2000pro.googlegroups.com \
    --to=xahlee@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.