Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
非同期に辞書を引く
#!/usr/bin/python2.5
import sys
from DictionaryServices import *
def main():
word = sys.argv[1].decode('utf-8')
result = DCSCopyTextDefinition(None, word, (0, len(word)))
if result:
print result.encode('utf-8')
else:
print "nil"
if __name__ == '__main__':
main()
;; 非同期に辞書を引く
;;
;; (+ "http://d.hatena.ne.jp/a666666/20100529/1275138722"
;; "http://sakito.jp/mac/dictionary.html"
;; "http://d.hatena.ne.jp/tomoya/20091218/1261138091"
;; "http://d.hatena.ne.jp/tomoya/20100103/1262482873")
(require 'cl)
(require 'deferred)
(defvar dict-bin "~/bin/dict.py"
"dict 実行ファイルのパス")
(defun my-dictionary ()
(interactive)
(lexical-let ((current-word (thing-at-point 'word)))
(when current-word
(deferred:$
(deferred:process dict-bin current-word)
(deferred:nextc it
(lambda (res) (popup-tip (concat current-word "\n" res))))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.