Skip to content
Switch branches/tags

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time
DictEm is a Dictionary protocol client for GNU Emacs.

It uses a console dict client ( and
implements all functions of the client part of DICT protocol
(RFC-2229,, i.e. looking up words and definitions,
obtaining information about available strategies, provided databases,
information about DICT server etc.

Unlike dictionary.el
( DictEm widely
uses autocompletion that is used for selecting dictionary and search
strategy.  Moreover, DictEm provides several hooks which may be used
for buffer postprocessing. For example, inbuilt hyperlinking and
highlighting mechanisms are based on this possibility.  Another example
is that information obtained from DICT server that is in HTML, ROFF or
INFO format can be easily viewed by Emacs+DictEm if the user supplies
appropriate conversion functions.  Of course DictEm can be differently
configured for different Emacs modes (major, minor or buffer
oriented), that allows modularized access to all data serviced by DICT
servers. This makes it ideal tool for translating articles between a
series of foreign languages, browsing manuals and other tasks
depending on Emacs mode user currently works with.

Additionally DictEm supports accessing so called virtual dictionaries (a set
of dictionaries provided by DICT server that user prefers to treat as
a single one).

Yet another feature DictEm provides is a set of useful functions with
a help of which user can extend DictEm functionality such as to define
new search strategies or even provide new functionality such as to use
another sources of data other than DICT servers.

See below for a set of example configuration and extensions.

Also DictEm uses customization mechanism provided by Emacs that helps
Emacs users to easily configure DictEm.


See the file COPYING


Latest sources can be downloaded from


* In order to uncompress dictem tarball run the following.

  tar xfv dictem-x.y.z.tar.gz

  If you read this file, you probably have already done this.

* Change your current directory to dictem.

  cd dictem-x.y.z

* Copy *.el file to the directory you want.

  cp *.el /path/to/emacs/el/files

* Make sure that DICT client named dict
  (available at
  is installed on your system.
  Console dict client is used by DictEm for accessing the DICT server.
  dict-1.9.14 or later is strongly recommended.
  If you'll set dictem-option-mime variable to t (read below),
  dict-1.10.3 or later MUST be used.


    Please send all bug reports and suggestions directly to
    Aleksey Cheusov <>.
    Reporting bugs at is also good.

    Also note that there exists mailing list (low
    traffic) where you can ask questions about DICT protocol and


Customization group

Take note, that DictEm defines customization group "dictem".
So, it may be easier for you to customize DictEm by running
M-x customize-group <RET> dictem <RET>

Manual Configuration


The easiest configuration of dictem may look like this

; Add to load-path variable a new directory with files of dictem
(add-to-list 'load-path "/path/you/installed/dictem/to")

; Loading dictem functions
(require 'dictem)

; Setting the dictionary server hostname.
; This part is optional, if dictem-server is nil (the default value)
; "dict" command line utility will use its ows config file
; ~/.dictrc or PREFIX/etc/dict.conf.
; Keeping dictem-server variable unset is recomended because
; this allows to try _list of_ servers until connection is made,
; see dict(1) for details.
;(setq dictem-server "localhost")
;(setq dictem-server "")

; Setting the dictionary server port.
; Setting dictem-port is usually not necessary because
; most DICT servers use the default port 2628.
;(setq dictem-port   "2628")

; Code necessary to obtain database and strategy list from DICT
; server. As of version 0.90, dictem runs this function from
; dictem-select-database and dictem-select-strategy if an
; initialization was not completed or failed previously, that is
; running dictem-initialize is optional

; Assigning hot keys for accessing DICT server

; Ask for word, database and search strategy
; and show definitions found
(global-set-key "\C-cs" 'dictem-run-search)

; Ask for word, database and search strategy
; and show matches found
(global-set-key "\C-cm" 'dictem-run-match)

; Ask for word and database name
; and show definitions found
(global-set-key "\C-cd" 'dictem-run-define)

; Show information about DICT server
(global-set-key "\C-c\M-r" 'dictem-run-show-server)

; Show information about the database
(global-set-key "\C-c\M-i" 'dictem-run-show-info)

; Show a list of databases provided by DICT server
(global-set-key "\C-c\M-b" 'dictem-run-show-databases)


There are a few functions that can make dictem look
a bit nicer and be more functional. They should
be added to special hooks like the following.

; For creating hyperlinks on database names
; and found matches.
; Click on them with mouse-2
(add-hook 'dictem-postprocess-match-hook

; For highlighting the separator between the definitions found.
; This also creates hyperlink on database names.
(add-hook 'dictem-postprocess-definition-hook 

; For creating hyperlinks in dictem buffer
; that contains definitions.
(add-hook 'dictem-postprocess-definition-hook 

; For creating hyperlinks in dictem buffer
; that contains information about a database.
(add-hook 'dictem-postprocess-show-info-hook


If you want to combine some databases in you own "virtual" dictionary,
create them like this

(setq dictem-user-databases-alist
   '(("_en-ru"  . ("mueller7" "korolew_en-ru"))
     ("_en-en"  . ("foldoc" "gcide" "wn"))
     ("_ru-ru"  . ("beslov" "ushakov" "ozhegov" "brok_and_efr"))
     ("_unidoc" . ("susv3" "man" "info" "howto" "rfc"))

As a result four new special database collections will be created
and new names will appear when
dictem-run function will ask you about database name.


You can even create virtual dictionaries which consist of
databases from different DICT server.
The dict url form dict:///religion means 'dict' command line tool
will be called without -h option, i.e. a list of dictionary servers
from .dictrc (or dict.conf) will be used.

(setq dictem-user-databases-alist
   '(("_en-ru" . ("dict://"
     ("_ru-ru" . ("beslov" "dict:///religion"))

another example:

(setq dictem-user-databases-alist
      `(("en-en" . ("dict://"))
        ("en-ru" . ("dict:///en-ru"


If your DICT server provides too many databases and most of which
are of no interest for you, you can disable them
and use only those specified in dictem-user-databases-alist variable. 

(setq dictem-use-user-databases-only t)


Of course, you can assign your own key bindings in dictem buffer

(define-key dictem-mode-map [tab] 'dictem-next-link)
(define-key dictem-mode-map [(backtab)] 'dictem-previous-link)


You are not limited to the default DICT server only.
The following code will allow you to access any server you want.
You'll be asked for host and port.

 '(lambda ()
     (let* ((dictem-server (read-string "server: "
					dictem-server nil ""))
	    (dictem-port (read-string "port: "
				      (dictem-get-port) nil "2628")))
       (call-interactively 'dictem-run-define)))))

 '(lambda ()
     (let* ((dictem-server (read-string "server: "
					dictem-server nil ""))
	    (dictem-port (read-string "port: "
				      (dictem-get-port) nil "2628")))
       (call-interactively 'dictem-run-match)))))

 '(lambda ()
     (let* ((dictem-server (read-string "server: "
					dictem-server nil ""))
	    (dictem-port (read-string "port: "
				      (dictem-get-port) nil "2628")))
       (call-interactively 'dictem-run-search)))))

 '(lambda ()
     (let* ((dictem-server (read-string "server: "
					dictem-server nil ""))
	    (dictem-port (read-string "port: "
				      (dictem-get-port) nil "2628")))
       (call-interactively 'dictem-run-show-info)))))

 '(lambda ()
     (let* ((dictem-server (read-string "server: "
					dictem-server nil ""))
	    (dictem-port (read-string "port: "
				      (dictem-get-port) nil "2628")))
       (call-interactively 'dictem-run-show-server)))))


Some databases may have specially formatted definitions,
for example, HTML, MIME, DICF or ROFF formats.
It is easy to postprocess them.

; All functions from dictem-postprocess-each-definition-hook
; will be run for each definition which in turn will be narrowed.
; Current database name is kept in dictem-current-dbname variable.
; The following code demonstrates how to highlight SUSV3 and ROFF
; definitions.
(add-hook 'dictem-postprocess-definition-hook

; Function for highlighting definition from the database "susv3".
(defun dictem-highlight-susv3-definition ()
  (cond ((string= "susv3" dictem-current-dbname)
	 (goto-char (point-min))
	 (while (search-forward-regexp
	    (match-beginning 0) (match-end 0) 'face 'bold)

; Function to show roff-formatted text from the database "man".
(require 'woman)
(defun dictem-highlight-man-definition ()
  (cond ((string= "man" dictem-current-dbname)
	 (goto-char (point-min))
	 (while (search-forward-regexp "^  " nil t)
	   (replace-match ""))
	 (goto-char (point-min))
	 (forward-line 2)
	 (woman-decode-region (point) (point-max))

(add-hook 'dictem-postprocess-each-definition-hook 
(add-hook 'dictem-postprocess-each-definition-hook 


; The dictem's top level function is 'dictem-run'.
; By using it more advanced ELISP programmers
; can create their own search scenaria. Look at this code.

  "gcide" "apple" "lev")

  "dict://" "apple" "exact")

  '("dict://" "dict://")
   "apple" "exact")

(dictem-run 'dictem-base-show-info "dict://")

(let ((dictem-server "localhost"))
   '(lambda (a b c)
      (dictem-base-show-strategies nil nil nil)
      (dictem-base-show-databases nil nil nil)
      (dictem-base-show-server nil nil nil)

  '(lambda (a b c)
      '("man" "susv3")
      (dictem-read-query (thing-at-point 'word))
      nil ))
  nil nil)

(let ((query (dictem-read-query (thing-at-point 'word))))
   `((lambda (a b c)
	'("gcide" "wn")
	,query "exact"))
     (lambda (a b c)
	'("mueller7" "korolew_en-ru")
	,query "word")))))


By default dictem remembers the database name and strategy that
was used last time.
The  dictem-select-database and dictem-select-strategy functions
will use these values as a default in the minibuffer.
If you dislike this behaviour, set variables
dictem-default-database and/or dictem-default-strategy.

(add-hook 'c-mode-common-hook
	  '(lambda ()
	     (make-local-variable 'dictem-default-database)
	     (setq dictem-default-database "man")

The example above sets default database to "man"
in C buffers.


As of dictem-0.0.4 dictem-empty-initial-input customizable variable
tells dictem-read-query whether to leave initial input empty or not.
It is `nil' by default.
For emulating behaviour of older releases, set it to `t'.

(setq dictem-empty-initial-input t)

Ex. 12

By default dictem-postprocess-definition-hyperlinks function
assumes that hyperlinks have the following form: {foo} or {foo|bar}.
Sometimes "{" and "}" characters are general characters
in definitions. The following code changes "{" and "}" for
"{link-beg " and " link-end" respectively
inside definitions obtained from the databases "^infopage-..."

; new function is used for creating hyperlinks
; which works differently depending on database name
(defun my-dictem-postprocess-definition-hyperlinks ()
  "Creating hyperlinks according to database name"
  (cond (
	((string-match "^infopage-" dictem-current-dbname)
	 (let ((dictem-hyperlink-beginning "{link-beg ")
	       (dictem-hyperlink-end       " link-end}")
	(t (dictem-postprocess-definition-hyperlinks)))))

; definitions from each database are processed separately
(add-hook 'dictem-postprocess-definition-hook
(add-hook 'dictem-postprocess-each-definition-hook

Ex. 13

You may want to remove "XXX definition[s] found" header
from the DEFINE buffers.
It may be done with a help of
dictem-postprocess-definition-remove-header function.

(add-hook 'dictem-postprocess-definition-hook

Ex. 14

As of version 0.7 dictem can handle dictionaries defined by user.
This allows to use dictem not only for accessing DICT servers,
but also for accesing users' databases.

; DEFINE function for the database "mysuperdb"
(defun dictem-mysuperdb-DEFINE (query)
   ((string= query "apple")  '("Apples grow on the trees"
			       "Apple may be green, yellow or red"))
   ((string= query "potato") '("Potato is a vegetable"
			       "Potato is a traditional Belarusian food"))
   (t (dictem-make-error
       20 (format "No definitions for %s" query)))

; MATCH function for the database "mysuperdb"
(defun dictem-mysuperdb-MATCH (query strategy)
  ; the name of strategy is ignored
  (let ((apple  (string-match query "apple"))
	(potato (string-match query "potato")))
     ((and (string= strategy "exact") (string= query "apple"))
     ((and (string= strategy "exact") (string= query "potato"))
     ((and apple potato)
      '("apple" "potato"))
     (t (dictem-make-error
	 20 (format "No matches for %s/%s" query strategy)))

; Initializing a list of user-defined databases
(setq dictem-user-databases-alist
      `(("_en-en"  . ("foldoc" "gcide" "wn"))
	("_ru-ru"  . ("beslov" "ushakov" "ozhegov" "brok_and_efr"))
          ; the name of the database
          ; short description
          "My super database"
          ; MATCH function
	  (symbol-function 'dictem-mysuperdb-MATCH)
          ; DEFINE function
	  (symbol-function 'dictem-mysuperdb-DEFINE))

Ex. 15

Last years many dictionary servers provide too many bilingual dictionaries,
most of which may be not very interesting for you.
DictEm allows to exclude such dictionaries from an autocompletion menu
by setting a list of regular expressions in dictem-exclude-databases
If, for example, you don't speak french and german and use
dict:// server, your config may look like this

(setq dictem-server "")
(setq dictem-exclude-databases '("ger-" "-ger" "fra-" "-fra"))

Note that, (dictem-initialize) is placed after initializing
dictem-exclude-databases variable.

If you have read to this point and all the examples above seem easy,
you are probably a ELISP Guru.
So, I have nothing more to tell you ;-)
Feel free to inspect the code, and I hope you'll find DictEm useful.

Dict'em All! ;-)


Dictionary protocol client (RFC 2229) for Emacs







No packages published