Skip to content

Instantly share code, notes, and snippets.

@hitode909
Created August 20, 2011 10:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save hitode909/1158955 to your computer and use it in GitHub Desktop.
Save hitode909/1158955 to your computer and use it in GitHub Desktop.
非同期に辞書を引く
#!/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