help-gnu-emacs
[Top][All Lists]
Advanced

[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: Sat, 1 Nov 2008 03:36:51 -0700 (PDT)
User-agent: G2/1.0

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 via email to

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