Skip to content

Instantly share code, notes, and snippets.

@hitode909
Created August 20, 2011 10:50

Revisions

  1. hitode909 revised this gist Aug 20, 2011. 2 changed files with 22 additions and 0 deletions.
    15 changes: 15 additions & 0 deletions dict.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    #!/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()
    7 changes: 7 additions & 0 deletions dictionary.el
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,10 @@
    ;; 非同期に辞書を引く
    ;;
    ;; (+ "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)

  2. hitode909 created this gist Aug 20, 2011.
    14 changes: 14 additions & 0 deletions dictionary.el
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    (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))))))))