LoginSignup
4
2

More than 5 years have passed since last update.

カーソル位置の単語をOSXの辞書で調べて、Emacs上にポップアップ表示する

Last updated at Posted at 2014-01-17

SDIC使うのもありだけど、せっかくOSXに辞書があるので、その辞書を利用して、
Emacs上に結果をポップアップ表示する。

準備

dictionary-app を clone する。
$ hg clone http://hg.pqrs.org/commandline-dictionary-app

または、以下のページの左側にある gz からダウンロードする。
http://hg.pqrs.org/commandline-dictionary-app/

make を叩いて作成された dict を任意のディレクトリに置く。
(ここでは ~/.emacs.d/bin/dict とした)

dictionary-app.el を load-path の通ってる場所に置く。

設定

dictionary-app-setting.el
(defun ns-popup-dictionary ()
   "カーソル付近の単語を OSX の辞書でひく"
   (interactive)
   (let ((word (substring-no-properties (thing-at-point 'word)))
     (old-buf (current-buffer))
     (dict-buf (get-buffer-create "*dictionary.app*"))
     (view-mode-p)
     (dict))
     (set-buffer dict-buf)
     (erase-buffer)
     (call-process "~/.emacs.d/bin/dict"
           nil "*dictionary.app*" t word
           "Japanese-English" "Japanese" "Japanese Synonyms")
     (setq dict (buffer-string))
     (set-buffer old-buf)
     (when view-mode
       (view-mode)
       (setq view-mode-p t))
     (popup-tip dict)
     (when view-mode-p
       (view-mode))))

(define-key global-map (kbd "C-M-d") 'ns-popup-dictionary)

\C-\M-d で、カーソル位置の単語を辞書でひいた結果がポップアップされる。
1回目は結構時間かかるかも。

ポップアップされた内容からコピペしたくなるが、残念ながら出来ない...

4
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
2