Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Can I build a dictionary in my Emacs?

0 views
Skip to first unread message

Water Lin

unread,
Nov 25, 2009, 10:12:48 PM11/25/09
to

I want to build a dictionary in my Emacs. So I can put my specific
words, expressions and their meanings into it.

By doing this, when I need them, I don't need to google them out again.

I don't know if it is suitable to call it dictionary, but it likes
dictionary.

Any good suggestions?

Thanks

Water Lin

--
Water Lin's notes and pencils: http://en.waterlin.org
Email: Wate...@ymail.com

Pascal J. Bourguignon

unread,
Nov 26, 2009, 6:00:30 AM11/26/09
to
Water Lin <Wate...@ymail.invalid> writes:

> I want to build a dictionary in my Emacs. So I can put my specific
> words, expressions and their meanings into it.
>
> By doing this, when I need them, I don't need to google them out again.
>
> I don't know if it is suitable to call it dictionary, but it likes
> dictionary.
>
> Any good suggestions?

Perhaps you could use EBD, the Emacs Data Base?


But if you have a persistent internet connection, why don't you just
use M-x dictionary RET?


Also, using google shouldn't be a big deal from emacs:


(require 'cl)
(require 'w3m)

(setf browse-url-browser-function
(lambda (url &rest args)
(other-frame 1) ; or (make-frame)
(w3m-goto-url url)))


(defun google-search (search-string)
"Search a string with Google."
(interactive "sGoogle Search: ")
(setf search-string
(shell-command-to-string
(format "echo %s|iconv -f ISO8859-1 -t UTF-8"
(shell-quote-argument search-string))))
(browse-url
(format "http://www.google.com/search?as_q=%s&num=50&hl=en&ie=ISO8869-1&btnG=Google+Search&as_epq=&as_oq=&as_eq=&lr=&as_ft=i&as_filetype=&as_qdr=all&as_nlo=&as_nhi=&as_occt=any&as_dt=i&as_sitesearch=&safe=images"
(apply (function concatenate) 'string
(mapcar (lambda (ch)
(if (or (and (<= ?0 ch) (<= ch ?9))
(and (<= ?A ch) (<= ch ?Z))
(and (<= ?a ch) (<= ch ?z)))
(format "%c" ch)
(format "%%%02x" ch)))
(string-to-sequence search-string 'list))))))


(defun google-search-region (start end)
"Search the text in the region with Google."
(interactive "r")
(google-search (buffer-substring-no-properties start end)))


--
__Pascal Bourguignon__

Lennart Borgman

unread,
Nov 26, 2009, 6:54:12 AM11/26/09
to help-gn...@gnu.org
>> I want to build a dictionary in my Emacs. So I can put my specific
>> words, expressions and their meanings into it.

Isn't there a good dictionary framework in predictive mode?


Tim X

unread,
Nov 26, 2009, 5:14:44 PM11/26/09
to
Water Lin <Wate...@ymail.invalid> writes:

> I want to build a dictionary in my Emacs. So I can put my specific
> words, expressions and their meanings into it.
>
> By doing this, when I need them, I don't need to google them out again.
>
> I don't know if it is suitable to call it dictionary, but it likes
> dictionary.
>
> Any good suggestions?
>
> Thanks
>

Emacs lisp has support ofr hashes and essentially, that would provide
the basic abstraction you want, but there is considerable work to
provide a useful interface etc. This is work that is pretty much already
done by other packages, so I feel you would be re-inventing a new
wheel.

for example, emacs integrates well with spelling checkers, such as
ispell and most of these have support for including a personal
dictionary and adding words to the dictionary. As this is integrated
into things like spell checking and packages like flyspell, you get the
benefit of standard funcitons, such as spell checking using your
personal dictionary as well as the ones that come built-in.

Rather than build/write your own, look into emacs support for spell
checking and see if you can add your word definitions to that existing
mechanism. Less work and easier to maintain in the long-term.

Tim


--
tcross (at) rapttech dot com dot au

Water Lin

unread,
Nov 27, 2009, 3:32:53 AM11/27/09
to
Tim X <ti...@nospam.dev.null> writes:

Ok, Thanks, I will read something about ispell later.

Colin S. Miller

unread,
Nov 27, 2009, 6:37:38 AM11/27/09
to
Tim X wrote:
>
> Rather than build/write your own, look into emacs support for spell
> checking and see if you can add your word definitions to that existing
> mechanism. Less work and easier to maintain in the long-term.

I think the OP wanted a dictionary that provides the definition of a word,
not just a word-correctly-spelled-p test.

Colin S. Miller


--
Replace the obvious in my email address with the first three letters of the hostname to reply.

Tim X

unread,
Nov 27, 2009, 5:50:46 PM11/27/09
to
"Colin S. Miller" <no-spam-...@csmiller.demon.co.uk> writes:

> Tim X wrote:
>>
>> Rather than build/write your own, look into emacs support for spell
>> checking and see if you can add your word definitions to that existing
>> mechanism. Less work and easier to maintain in the long-term.
>
> I think the OP wanted a dictionary that provides the definition of a word,
> not just a word-correctly-spelled-p test.
>

Thats a good point. In that case, I'd look at adding a dictionary to one
of the dict servers (don't know if the OP is on windows or Linux, but
fairly straight-forward for Linux) and then using one of the emacs
interfaces to dictionary servers. This would mean all that needs to be
done is generate the definitions file. All the interfaces are then done,
including interfaces from other things in addition to emacs.

If that is still too far off the mark for what the OP wants, I'd
consider looking at edb or even just a simple sexp bassed structure that
can easily be read/written to a file and maybe creating an emacs forms
front-end to make querying and adding new words easy. A simple sexp
based structure will be reasonably efficient for quite a large number of
words and definitions.

Stefan Monnier

unread,
Nov 27, 2009, 10:07:25 PM11/27/09
to
> I want to build a dictionary in my Emacs. So I can put my specific
> words, expressions and their meanings into it.

Why not just use a plain text file, with one definition per line.
Set it up with (setq word-wrap t) and (setq wrap-prefix " ").
Then just search with C-s and add definitions in the obvious way.


Stefan

Drew Adams

unread,
Dec 3, 2009, 1:22:01 PM12/3/09
to help-gn...@gnu.org

1. I second that. If this is for your own personal use and you don't expect to
have a large number of definitions, then this is a great way to go. It has the
advantages of simplicity, easy update, and variety of access/navigation methods.


2. If you will have lots of definitions or you want to create a dictionary for
others to use, then you might also want to look at the Emacs tags feature. A tag
is essentially just a definition. A tag file is an index to definitions.

Tags do not have to be definitions, but they typically are. The definitions are
typically code definitions (of function, variables, etc.), but they don't have
to be.

The advantages of using Emacs tags for definitions are (a) distribution: the
definitions can be scattered over any number of files and directories, and (b)
performance. The disadvantage is that you will need to create (and
maintain/update) the TAGS file, either by hand or by writing some code to do
that.
http://www.emacswiki.org/emacs/EmacsTags
http://www.gnu.org/software/emacs/manual/html_node/emacs/Tags.html#Tags


3. You might also consider using Imenu. In a way, this is halfway between #1 and
#2. Imenu parses a buffer, collecting the positions of any definitions contained
in it, and then it presents those definitions to users in a menu (or via
completion etc.). Again, the definitions are typically code definitions (of
functions, variables, etc.), but they do not have to be.

To use Imenu, you will need to come up with a regexp that recognizes a
definition, which means that you need to decide on a definition format. E.g.
`DEFINITION foo = ...' with a regexp that looks for "DEFINITION" followed by the
defined term followed by " = ". Or some such. The regexp variable to set is
`imenu-generic-expression'.
http://www.emacswiki.org/emacs/ImenuMode
http://www.gnu.org/software/emacs/manual/html_node/emacs/Imenu.html#Imenu


4. I don't think this is what you want, but I mention it anyway: Library
`synonyms.el' provides a navigable thesaurus. It uses a (large) file that
defines classes of English synonyms. You can use it to navigate among synonyms
in various ways. Dunno if a similar approach would be feasible for a dictionary.
http://www.emacswiki.org/emacs/Synonyms

0 new messages