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: Sat, 1 Nov 2008 03:36:51 -0700 (PDT)	[thread overview]
Message-ID: <b412ff00-ff3b-45f7-a7be-8585920219e8@o4g2000pra.googlegroups.com> (raw)
In-Reply-To: bffcf04c-f7cc-4b25-8771-5e0a7929121d@d10g2000pra.googlegroups.com

Some more info ...

i took a look at the alternative emacs dict client
http://sourceforge.net/projects/dictem
it turns out that this is merely a wrapper to a real command line
client, and is actually orginially based on “dictionary.el”.

this is kinda disappointing. I guess it tries to improve
“dictionary.el” but throws real meat, the actual real dict client,
out.

--------------

i wrote to the author of dictionary.el Torsten Hilbrich. Here's what
he says:

«
There is currently no way to use more than one dictionary server.

You could however locally modify dictionary-server in a self-written
lisp function like:

(defun search-in-1913 (word)
  (interactive (list (read-string "Search word: " (current-word))))
  (let ((dictionary-server "dict.org"))
    (dictionary-search word "web1913")))

Replace dict.org with the server you use for this dictionary.
»

«Regarding the window change you mentioned in the thread. Here is a
function you could use in replacement of dictionary-search to get the
behaviour you prefer:

(defun dictionary-search-other-window (word &optional dictionary)
  (interactive
   (list (read-string "Search word: " (current-word))
	 (if current-prefix-arg
	     (read-string "Dictionary: " dictionary-default-dictionary)
	   dictionary-default-dictionary)))
  (let ((dictionary-use-single-buffer t))
      (dictionary-search word dictionary)
      (other-window 1)))

It switches back to the original window and also let dictionary use a
single window to avoid recreating a new dictionary buffer for each
request.
»

----------------------------

i did some digging of the source code. So, effectively you can just do
this:

(dictionary-new-search (cons "fancy" "wn")) ; look up word in WordNet
(dictionary-new-search (cons "fancy" "web1913"))  ; look up word in
webster 1913

or

(dictionary-do-search "fancy" "web1913" 'dictionary-display-search-
result)

the dictionary-display-search-result function will take the result and
format it and display in buffer. But i haven't spent enough time to
figure out what's the format passed to dictionary-display-search-
result.

in anycase, here's a code that does lookup on current word. It
different than dictionary-lookup-definition in that if you have a text
selection, it'll use that phrase to lookup. This is convenient because
quite often emacs's (current-word) does not really pickup the word you
want. Including phrases or idioms that has a dict entry but has a
space in them. The other change is that the cursor remains where it
is.

(defun lookup-word-def ()
"Look up the word's definition in Webster 1913
If a region is active (a phrase), lookup that phrase."
 (interactive)
 (let (myword myurl)
   (setq myword
         (if (and transient-mark-mode mark-active)
             (buffer-substring-no-properties (region-beginning)
(region-end))
           (thing-at-point 'symbol)))
   (require 'dictionary)
   (dictionary-new-search (cons myword "web1913"))
; (dictionary-new-search (cons "fancy" "moby-thes"))
; (dictionary-new-search (cons "fancy" "wn"))
; (dictionary-do-search "fancy" "web1913" 'dictionary-display-search-
result)
   (other-window 1)
   ))

you could define several of these and assign them each to a shortcut.
e.g. the 0 on keypad, shift-0, ctrl+0, for looking up diff dicts...

ideally, i would like one press of a key and have the 3 dicts i want
(webster 1913, wordnet, moby thes) all combined in one output. This
means i'll have to figure out the format used in dictionary-display-
search-result... but currently not priority.

PS it odd that the dict protocol does not seem to allow client to
specify a _list_ of dicts to use, but it has a “*” to mean what i
presume ALL dict that's available on the server.

  Xah
∑ http://xahlee.org/

  reply	other threads:[~2008-11-01 10:36 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 [this message]
2008-11-03 22:43       ` Xah
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=b412ff00-ff3b-45f7-a7be-8585920219e8@o4g2000pra.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.