我已经安装了 Lubuntu 存储库中的 dictem,但我不知道如何运行它。我想知道它的基本用法、如何添加/删除词典、如何查找 Wiki、Wiktionary、forvo 等网络资源进行发音等。
我目前正在使用 GoldenDict,但如果 emacs 中也有类似的功能就更好了,这样查找结果就可以轻松地在其他文档中使用。
答案1
我一直使用 emacs 中的 dict 插件dictem
。事实上,dictem README 中有非常好的信息。无论如何,这是我的设置。在使用此代码之前,请安装下面列出的依赖项。顺便说一句,此设置仅联系本地主机服务器,而不联系 Web 资源。
;; 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)