- 论坛徽章:
- 0
|
(require 'selection)
(require 'rep.io.timers)
(defvar timer nil)
(defvar sdcv-out nil)
(defun search ()
(interactive)
(let* ((word (x-get-selection 'PRIMARY)) ;must use let* to evaluate parameters immediatly
(output (make-string-output-stream))
(proc (make-process output)))
(setq word (string-replace ",$" "" word))
(setq word (string-replace "\\.$" "" word))
(setq word (string-replace "^`" "" word))
(setq word (string-replace "^'" "" word))
(setq word (string-replace "'$" "" word))
(setq word (string-replace "\\?$" "" word))
(call-process proc nil "sdcv" "-n" "--data-dir" "~/.stardict/dic/stardict-langdao-ec-gb-2.4.2/" word)
(setq output (get-output-stream-string output))
(setq word nil)
(setq sdcv-out (string-split (quote-regexp "-->朗道英汉字典5.0\012")
output))
(setq timer (make-timer do-print))
(do-print)))
(defun do-print ()
(setq sdcv-out (cdr sdcv-out))
(if (car sdcv-out)
(progn
(setq temp sdcv-out)
(setq tmp (car temp))
(while (car temp)
(setq temp (cdr temp))
(setq tmp (concat tmp (car temp))))
(display-message tmp '((position . (0 . 0)) (background . "LightGoldenrod1") (foreground . "black")))
(set-timer timer 10 0))
(progn
(delete-timer timer)
(display-message nil))))
本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u2/83046/showart_1332743.html |
|