分享一个 emacs 中查单词的方法

  • 在 linux 中安装欧路词典
  • 欧路词典设置剪贴板查词
  • emacs 中 kill-ring-save 再用 dbus 激活欧路词典窗口
  • dbus 调用中的名称在每次欧路词典重启后都会变 需要用 d-feet 查询并修改
3 个赞
  • 安卓手机中同样是用欧路词典
  • termux 中的 emacs 用 termux-open-url 调用欧路词典的 urlscheme
(defun eudic ()
  (interactive)
  (shell-command
   (format "termux-open-url eudic://dict/%s"
	   (word-at-point))))
4 个赞

其实不必非得啥事儿都在 Emacs 里完成

1 个赞

Linux居然有欧路词典了?6个月前想用但是没有所以一直使用的手机查单词。。。

欧陆词典支持下载安装 英语词根词缀记忆词典 ,感觉按词根词缀记单词才是王道。

不需要走 dbus,直接运行欧陆词典即可,设置一下欧陆词典:

勾选 `自动查询剪贴板内单词`  `关闭窗口时最小化到状态栏`
不勾选 `软件启动时最小化` 

实现

(defun my/eudic (&optional read)
  "Translate with eudic.
eudic program must set auto translate words in clipboard."
  (interactive "P")
  (let* ((default-word (if (member major-mode '(doc-view-mode pdf-view-mode))
                           nil
                         (if mark-active
                             (buffer-substring-no-properties (region-beginning) (region-end))
                           (current-word))))
         (word (if read nil default-word))
         (old (car kill-ring)))
    (when (= 0 (length word))
      (setq word (read-string (concat "Translate Words: ") default-word)))
    ;; Put into kill-ring for eudic translate words in clipboard.
    (kill-new word)
    (start-process "eudic" nil "eudic")
    ;; Recover kill-ring later.
    (run-with-timer 1 nil (lambda (word old)
                            (if (equal word (car kill-ring))
                                (kill-new old)))
                    word old)))

DX能改一个调用goldendict的不谢谢

刚发现欧陆词典 LINUX 版很多词典要充会员才能用了,果断换回 Goldendict 了,Goldendict 很好集成:

(defun my/goldendict (&optional read)
  "Translate with goldendict."
  (interactive "P")
  (let* ((default-word (if (member major-mode '(doc-view-mode pdf-view-mode))
                           nil
                         (if mark-active
                             (buffer-substring-no-properties (region-beginning) (region-end))
                           (current-word))))
         (word (if read nil default-word)))
    (when (= 0 (length word))
      (setq word (read-string (concat "Translate Words: ") default-word)))
    (start-process "goldendict" nil "goldendict" word)))
5 个赞

谢谢DX 另请问用的是哪个版本的goldendict 官方据说早不更新了,所以停留在非常旧的版本上 为了用新的,下载的appimage的版本 但会找不到这个program

update: