Created
August 20, 2011 10:50
-
-
Save hitode909/1158955 to your computer and use it in GitHub Desktop.
非同期に辞書を引く
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; 非同期に辞書を引く | |
;; | |
;; (+ "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