Pārlūkot izejas kodu

add prefs for google-translate

pull/1/head
10sr pirms 10 gadiem
vecāks
revīzija
0db2111a25
1 mainītis faili ar 93 papildinājumiem un 72 dzēšanām
  1. +93
    -72
      emacs.el

+ 93
- 72
emacs.el Parādīt failu

@@ -1285,6 +1285,7 @@ found, otherwise returns nil."
(let ((iswitchb-default-method 'display))
(call-interactively 'iswitchb-buffer)))


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; sdic

@@ -1314,6 +1315,98 @@ found, otherwise returns nil."
(setq sdic-disable-select-window t)
(setq sdic-window-height 7))


;;;;;;;;;;;;;;;;;;;;;;;;
;; ilookup

(when (fetch-library
"https://raw.github.com/10sr/emacs-lisp/master/ilookup.el"
t)
(lazy-load-eval 'ilookup
'(ilookup-open)
(setq ilookup-dict-alist
'(
("en" . (lambda (word)
(shell-command-to-string
(format "sdcv -n -u dictd_www.dict.org_gcide '%s'"
word))))
("ja" . (lambda (word)
(shell-command-to-string
(format "sdcv -n -u EJ-GENE95 -u jmdict-en-ja '%s'"
word))))
("jaj" . (lambda (word)
(shell-command-to-string
(format "sdcv -n -u jmdict-en-ja '%s'"
word))))
("jag" .
(lambda (word)
(with-temp-buffer
(insert (shell-command-to-string
(format "sdcv -n -u 'Genius English-Japanese' '%s'"
word)))
(html2text)
(buffer-substring (point-min)
(point-max)))))
("alc" . (lambda (word)
(shell-command-to-string
(format "alc '%s' | head -n 20"
word))))
("app" . (lambda (word)
(shell-command-to-string
(format "dict_app '%s'"
word))))
;; letters broken
("ms" .
(lambda (word)
(let ((url (concat
"http://api.microsofttranslator.com/V2/Ajax.svc/"
"Translate?appId=%s&text=%s&to=%s"))
(apikey "3C9778666C5BA4B406FFCBEE64EF478963039C51")
(target "ja")
(eword (url-hexify-string word)))
(with-current-buffer (url-retrieve-synchronously
(format url
apikey
eword
target))
(message "")
(goto-char (point-min))
(search-forward-regexp "^$"
nil
t)
(url-unhex-string (buffer-substring-no-properties
(point)
(point-max)))))))
))
;; (funcall (cdr (assoc "ms"
;; ilookup-alist))
;; "dictionary")

;; (switch-to-buffer (url-retrieve-synchronously "http://api.microsofttranslator.com/V2/Ajax.svc/Translate?appId=3C9778666C5BA4B406FFCBEE64EF478963039C51&text=dictionary&to=ja"))

;; (switch-to-buffer (url-retrieve-synchronously "http://google.com"))

(setq ilookup-default "ja")
(when (locate-library "google-translate")
(add-to-list 'ilookup-dict-alist
'("gt" .
(lambda (word)
(save-excursion
(google-translate-translate "auto"
"ja"
word))
(with-current-buffer "*Google Translate*"
(buffer-substring-no-properties (point-min)
(point-max)))))))
))


(when (lazy-load-eval 'google-translate '(google-translate-translate
google-translate-at-point))
(setq google-translate-default-source-language "auto")
(setq google-translate-default-target-language "ja"))


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; vc
;; (require 'vc)
@@ -2371,77 +2464,5 @@ this is test, does not rename files."

;; (my-real-function-subr-p 'my-real-function-subr-p)

;;;;;;;;;;;;;;;;;;;;;;;;
;; ilookup

(when (fetch-library
"https://raw.github.com/10sr/emacs-lisp/master/ilookup.el"
t)
(lazy-load-eval 'ilookup
'(ilookup-open)
(setq ilookup-dict-alist
'(
("en" . (lambda (word)
(shell-command-to-string
(format "sdcv -n -u dictd_www.dict.org_gcide '%s'"
word))))
("ja" . (lambda (word)
(shell-command-to-string
(format "sdcv -n -u EJ-GENE95 -u jmdict-en-ja '%s'"
word))))
("jaj" . (lambda (word)
(shell-command-to-string
(format "sdcv -n -u jmdict-en-ja '%s'"
word))))
("jag" .
(lambda (word)
(with-temp-buffer
(insert (shell-command-to-string
(format "sdcv -n -u 'Genius English-Japanese' '%s'"
word)))
(html2text)
(buffer-substring (point-min)
(point-max)))))
("alc" . (lambda (word)
(shell-command-to-string
(format "alc '%s' | head -n 20"
word))))
("app" . (lambda (word)
(shell-command-to-string
(format "dict_app '%s'"
word))))
;; letters broken
("ms" .
(lambda (word)
(let ((url (concat
"http://api.microsofttranslator.com/V2/Ajax.svc/"
"Translate?appId=%s&text=%s&to=%s"))
(apikey "3C9778666C5BA4B406FFCBEE64EF478963039C51")
(target "ja")
(eword (url-hexify-string word)))
(with-current-buffer (url-retrieve-synchronously
(format url
apikey
eword
target))
(message "")
(goto-char (point-min))
(search-forward-regexp "^$"
nil
t)
(url-unhex-string (buffer-substring-no-properties
(point)
(point-max)))))))
))
;; (funcall (cdr (assoc "ms"
;; ilookup-alist))
;; "dictionary")

;; (switch-to-buffer (url-retrieve-synchronously "http://api.microsofttranslator.com/V2/Ajax.svc/Translate?appId=3C9778666C5BA4B406FFCBEE64EF478963039C51&text=dictionary&to=ja"))

;; (switch-to-buffer (url-retrieve-synchronously "http://google.com"))

(setq ilookup-default "ja")))


;;; emacs.el ends here

Notiek ielāde…
Atcelt
Saglabāt