[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: stardict and emacs
From: |
B.Qnyd |
Subject: |
Re: stardict and emacs |
Date: |
Sun, 12 Dec 2010 02:23:19 -0800 (PST) |
User-agent: |
G2/1.0 |
On Dec 12, 4:57 pm, François Patte
<francois.pa...@mi.parisdescartes.fr> wrote:
> Bonjour,
>
> I would like to use stardict in an emacs window, but I fail... I found a
> stardict.el and a sdcv.el, and loaded them, but I don't know what to do
> (I have added some lines in my .emacs, but I don't know how to make a
> correct adaptation to my system).
>
> I run linux with emacs 23
>
> stardict is installed in /usr/bin/
>
> dictionaries are in /usr/share/stardict/dic/
>
> What I would like is to be able to choose a dictionary, and ask for a
> word through emacs (in minibuff) and have the answer displayed in a new
> buffer/window.
>
> Is this possible and how?
>
> Thank you
> --
> Fran ois Patte
> Universit Paris Descartes
i am used it...
it's good!
-----------------------------------------
you used it, need install Stardict of Character Version..
my install it's sdcv-0.4.2-1mdv2008.0.i586.rpm
in .emacs add:
(require 'sdcv)
;; 调用 stardict 的命令行程序 sdcv 来查辞典
;; 如果选中了 region 就查询 region 的内容,否则查询当前光标所在的单词
;; 查询结果在一个叫做 *sdcv* 的 buffer 里面显示出来,在这个 buffer 里面
;; 按 q 可以把这个 buffer 放到 buffer 列表末尾,按 d 可以查询单词
(global-set-key (kbd "C-c d") 'kid-sdcv-to-buffer)
(defun kid-sdcv-to-buffer ()
(interactive)
(let ((word (if mark-active
(buffer-substring-no-properties (region-beginning)
(region-end))
(current-word nil t))))
(setq word (read-string (format "Search the dictionary for
(default %s): " word)
nil nil word))
(set-buffer (get-buffer-create "*sdcv*"))
(buffer-disable-undo)
(erase-buffer)
(let ((process (start-process-shell-command "sdcv" "*sdcv*" "sdcv"
"-n" word)))
(set-process-sentinel
process
(lambda (process signal)
(when (memq (process-status process) '(exit signal))
(unless (string= (buffer-name) "*sdcv*")
(setq kid-sdcv-window-configuration (current-window-
configuration))
(switch-to-buffer-other-window "*sdcv*")
(local-set-key (kbd "d") 'kid-sdcv-to-buffer)
(local-set-key (kbd "q") (lambda ()
(interactive)
(bury-buffer)
(unless (null (cdr (window-
list))) ; only one window
(delete-window)))))
(goto-char (point-min))))))))
select word used C-c d ..now used it;