From eb373574c9dfca0a554dae68dbb2012cc77d84f1 Mon Sep 17 00:00:00 2001 From: Andriy Tykhonov Date: Wed, 26 Sep 2018 21:42:15 +0300 Subject: [PATCH 1/3] Fix tkk error. --- google-translate-tk.el | 39 ++++++++++++++------------------------- 1 file changed, 14 insertions(+), 25 deletions(-) diff --git a/google-translate-tk.el b/google-translate-tk.el index 6a44d29..de9c919 100644 --- a/google-translate-tk.el +++ b/google-translate-tk.el @@ -46,13 +46,6 @@ (defvar google-translate--tkk-url "http://translate.google.com/") -(defvar google-translate--tkk-regex - "TKK=eval('((function(){var\\s-+a\\\\x3d\\(-?[0-9]+\\);var\\s-+b\\\\x3d\\(-?[0-9]+\\);return\\s-+\\([0-9]+\\)" - "Regexp for `google-translate--search-tkk'.") - -(defvar google-translate--tkk-debug - nil - "For debugging of tk related issues.") (defun google-translate--bit-v-2comp (v) "Return the two's complement of V." @@ -128,28 +121,23 @@ D is an integer." (defun google-translate--search-tkk () "Search TKK." - (if (re-search-forward google-translate--tkk-regex nil t) - (mapcar #'string-to-number - (list (match-string 1) (match-string 2) (match-string 3))) - (error "Failed to search TKK"))) + (let ((start nil) + (tkk nil) + (nums '())) + (setq start (search-forward ";TKK='")) + (search-forward "';") + (backward-char 2) + (setq tkk (buffer-substring start (point))) + (setq nums (split-string tkk "\\.")) + (list (string-to-number (car nums)) + (string-to-number (car (cdr nums)))))) (defun google-translate--get-b-d1 () "Return a list of b and d1 for `google-translate--gen-tk'." (let* ((url-request-extra-headers '(("Connection" . "close"))) - (buf (url-retrieve-synchronously google-translate--tkk-url)) - (debug-buffer-name "*Google Translate Debug*") - tkk-contents - tkk-ls) + (buf (url-retrieve-synchronously google-translate--tkk-url))) (with-current-buffer buf - (setq tkk-ls (google-translate--search-tkk)) - (setq tkk-contents (buffer-string))) - (when google-translate--tkk-debug - (with-output-to-temp-buffer debug-buffer-name - (prin1 tkk-contents)) - (select-window (display-buffer debug-buffer-name))) - (when (buffer-live-p buf) (kill-buffer buf)) - (list (cl-third tkk-ls) - (google-translate--lsh (+ (cl-first tkk-ls) (cl-second tkk-ls)) 0)))) + (google-translate--search-tkk)))) (defun google-translate--gen-rl (a b) (cl-loop for c from 0 below (- (length b) 2) by 3 @@ -178,7 +166,8 @@ D is an integer." (setq a (ffloor (mod a 1e6))) (format "%s.%s" (car (split-string (number-to-string a) "\\.")) - (car (split-string (number-to-string (google-translate--logxor a b)) "\\."))))) + (car (split-string (number-to-string + (google-translate--logxor a b)) "\\."))))) (provide 'google-translate-tk) From d3d244f3d81f8b67d1d90555c98b04b9df7ab99c Mon Sep 17 00:00:00 2001 From: Andriy Tykhonov Date: Wed, 26 Sep 2018 21:45:27 +0300 Subject: [PATCH 2/3] Bump version: 0.11.14 -> 0.11.15. --- .bump-version.el | 2 +- Makefile | 2 +- google-translate-core-ui.el | 2 +- google-translate-core.el | 4 ++-- google-translate-default-ui.el | 2 +- google-translate-pkg.el | 2 +- google-translate-smooth-ui.el | 2 +- google-translate-tk.el | 2 +- google-translate.el | 2 +- 9 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.bump-version.el b/.bump-version.el index 3f8ac1a..f4faf2a 100644 --- a/.bump-version.el +++ b/.bump-version.el @@ -7,4 +7,4 @@ "google-translate-pkg.el" "google-translate-smooth-ui.el" "Makefile")) - (:current-version "0.11.14")) + (:current-version "0.11.15")) diff --git a/Makefile b/Makefile index 2bfd863..f76c632 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ ELC = $(SRC:.el=.elc) CASK ?= cask PKG_DIR := $(shell $(CASK) package-directory) FEATURES = $(wildcard features/*.feature) -VERSION = 0.11.14 +VERSION = 0.11.15 TARGET_DIR = google-translate-$(VERSION) all: test marmalade tag diff --git a/google-translate-core-ui.el b/google-translate-core-ui.el index a420457..df1a56f 100644 --- a/google-translate-core-ui.el +++ b/google-translate-core-ui.el @@ -5,7 +5,7 @@ ;; Author: Oleksandr Manzyuk ;; Maintainer: Andrey Tykhonov ;; URL: https://github.com/atykhonov/google-translate -;; Version: 0.11.14 +;; Version: 0.11.15 ;; Keywords: convenience ;; Contributors: diff --git a/google-translate-core.el b/google-translate-core.el index 11709e0..0c7e67b 100644 --- a/google-translate-core.el +++ b/google-translate-core.el @@ -5,7 +5,7 @@ ;; Author: Oleksandr Manzyuk ;; Maintainer: Andrey Tykhonov ;; URL: https://github.com/atykhonov/google-translate -;; Version: 0.11.14 +;; Version: 0.11.15 ;; Keywords: convenience ;; Contributors: @@ -261,7 +261,7 @@ translation it is possible to get suggestion." (defun google-translate-version () (interactive) - (message "Google Translate (version): %s" "0.11.14")) + (message "Google Translate (version): %s" "0.11.15")) (provide 'google-translate-core) diff --git a/google-translate-default-ui.el b/google-translate-default-ui.el index 6ede698..7956086 100644 --- a/google-translate-default-ui.el +++ b/google-translate-default-ui.el @@ -6,7 +6,7 @@ ;; Author: Oleksandr Manzyuk ;; Maintainer: Andrey Tykhonov ;; URL: https://github.com/atykhonov/google-translate -;; Version: 0.11.14 +;; Version: 0.11.15 ;; Keywords: convenience ;; Contributors: diff --git a/google-translate-pkg.el b/google-translate-pkg.el index 26400a3..490e507 100644 --- a/google-translate-pkg.el +++ b/google-translate-pkg.el @@ -1,2 +1,2 @@ -(define-package "google-translate" "0.11.14" +(define-package "google-translate" "0.11.15" "Emacs interface to Google Translate.") diff --git a/google-translate-smooth-ui.el b/google-translate-smooth-ui.el index c3efbe5..9b6a01a 100644 --- a/google-translate-smooth-ui.el +++ b/google-translate-smooth-ui.el @@ -6,7 +6,7 @@ ;; Author: Oleksandr Manzyuk ;; Maintainer: Andrey Tykhonov ;; URL: https://github.com/atykhonov/google-translate -;; Version: 0.11.14 +;; Version: 0.11.15 ;; Keywords: convenience ;; Contributors: diff --git a/google-translate-tk.el b/google-translate-tk.el index de9c919..4af9b87 100644 --- a/google-translate-tk.el +++ b/google-translate-tk.el @@ -6,7 +6,7 @@ ;; Author: Oleksandr Manzyuk ;; Maintainer: Andrey Tykhonov ;; URL: https://github.com/atykhonov/google-translate -;; Version: 0.11.14 +;; Version: 0.11.15 ;; Keywords: convenience ;; Contributors: diff --git a/google-translate.el b/google-translate.el index 6f6cc6d..2ae503a 100644 --- a/google-translate.el +++ b/google-translate.el @@ -5,7 +5,7 @@ ;; Author: Oleksandr Manzyuk ;; Maintainer: Andrey Tykhonov ;; URL: https://github.com/atykhonov/google-translate -;; Version: 0.11.14 +;; Version: 0.11.15 ;; Keywords: convenience ;; Contributors: From a344f6bd9e3d3afbcdef377cda714c2ab104f3bc Mon Sep 17 00:00:00 2001 From: Andriy Tykhonov Date: Wed, 26 Sep 2018 22:20:19 +0300 Subject: [PATCH 3/3] Fix broken integration tests. --- features/google-translate-default-ui.feature | 4 ++-- features/google-translate-smooth-ui.feature | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/features/google-translate-default-ui.feature b/features/google-translate-default-ui.feature index 38a79a9..bafb4a8 100644 --- a/features/google-translate-default-ui.feature +++ b/features/google-translate-default-ui.feature @@ -110,13 +110,13 @@ Feature: Default UI for Google Translate Scenario: Suggestion when word is misspelled Given I set google-translate-default-source-language to "en" Given I set google-translate-default-target-language to "ru" - When I translate "sudgest" + When I translate "sugest" Then I should see suggestion "suggest" Scenario: Linked suggestion: click on suggestion Given I set google-translate-default-source-language to "en" Given I set google-translate-default-target-language to "ru" - When I translate "sudgest" + When I translate "sugest" Then I should see suggestion "suggest" And I press "TAB" And I press "TAB" diff --git a/features/google-translate-smooth-ui.feature b/features/google-translate-smooth-ui.feature index a0e9916..f941217 100644 --- a/features/google-translate-smooth-ui.feature +++ b/features/google-translate-smooth-ui.feature @@ -55,12 +55,12 @@ Feature: Smooth UI for Google Translate Scenario: Suggestion when word is misspelled Given I set google-translate-translation-directions-alist to (("en" . "ru")) - When I translate "sudgest" + When I translate "sugest" Then I should see suggestion "suggest" Scenario: Linked suggestion: click on suggestion Given I set google-translate-translation-directions-alist to (("en" . "ru")) - When I translate "sudgest" + When I translate "sugest" Then I should see suggestion "suggest" And I press "TAB" And I press "TAB"