Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have dictem from Lubuntu repositories installed, but I do not know how to run it. I would like to know the basic usage, how to add/remove dictionaries, how to look up web resources like Wiki, Wiktionary, forvo for pronunciation, etc.

I am using GoldenDict at the moment, but it would be nice to have similar features from within emacs so that the results of a lookup may be easily used in other documents.

share|improve this question

migrated from stackoverflow.com Nov 8 '11 at 8:10

This question came from our site for professional and enthusiast programmers.

1 Answer 1

up vote 1 down vote accepted

I use dict in emacs all the time with dictem plugin. Infact dictem README has very good information. Anyway this is my setup. Install dependencies listed below before using this code. BTW this setup only contacts the localhost server but not the web resources.

;; ubuntu packages needed
;; dict - client installed by default
;; dictd - server
;; dict-wn - Wordnet dictinory
;; any other dicts you want

(when (executable-find "dictd")            ; check dictd is available
   (require 'dictem))


(setq dictem-server "localhost")
(setq dictem-user-databases-alist
      `(("_en-en"  . ("foldoc" "gcide" "wn"))))

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

(setq dictem-port   "2628")
(dictem-initialize)

(setq dictem-default-strategy "word")
(setq dictem-use-user-databases-only t)

;; For creating hyperlinks on database names
;; and found matches.
(add-hook 'dictem-postprocess-match-hook
          'dictem-postprocess-match)

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

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

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

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

(setq dictem-user-databases-alist
      '(("_en-en"  . ("foldoc" "gcide" "wn"))))

;;; http://paste.lisp.org/display/89086
(defun dictem-run-define-at-point-with-query ()
  "Query the default dict server with the word read in within this function."
  (interactive)
  (let* ((default-word (thing-at-point 'symbol))
         (default-prompt (concat "Lookup Word "
                                 (if default-word
                                     (concat "(" default-word ")") nil)
                                 ": "))
         (dictem-query
          (funcall #'(lambda (str)
                       "Remove Whitespace from beginning and end of a string."
                       (replace-regexp-in-string "^[ \n\t]*\\(.*?\\)[ \n\t]*$"
                                                 "\\1"
                                                 str))
                   (read-string default-prompt nil nil default-word))))
    (if (= (length dictem-query) 0) nil
      (dictem-run 'dictem-base-search "*" dictem-query "."))))

(defun dictem-run-define-at-point ()
  "dictem look up for thing at point"
  (interactive)
  (let* ((default-word (thing-at-point 'symbol))
         (dictem-query
          (funcall #'(lambda (str)
                       "Remove Whitespace from beginning and end of a string."
                       (replace-regexp-in-string "^[ \n\t]*\\(.*?\\)[ \n\t]*$"
                                                 "\\1"
                                                 str))
                   default-word)))
    (if (= (length dictem-query) 0) nil
      (dictem-run 'dictem-base-search "*" dictem-query "."))))

(global-set-key "\C-cd" 'dictem-run-define-at-point)
(global-set-key "\C-cD" 'dictem-run-define-at-point-with-query)

(global-set-key "\C-zs" 'dictem-run-search)
(global-set-key "\C-zm" 'dictem-run-match)
;; (global-set-key "\C-cd" 'dictem-run-define)
share|improve this answer
    
This works, thanks a lot. –  usp2011 Oct 31 '11 at 23:25
    
One more question: I have a BGL file. I converted it to .index (using the program dictconv), and copied the .index file to /usr/share/dictd, and added the filename (without the extension to the list dictem-user-database-alist) but it does not seem to work. Could you please suggest what I have to do to be able to use a BGL file? Thank you. –  usp2011 Oct 31 '11 at 23:34

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.