Skip to content

Commit

Permalink
Remove the function of continuous translation, it is not easy to use.
Browse files Browse the repository at this point in the history
  • Loading branch information
manateelazycat committed Nov 12, 2018
1 parent a82c9d3 commit ebf7671
Showing 1 changed file with 8 additions and 27 deletions.
35 changes: 8 additions & 27 deletions insert-translated-name.el
Expand Up @@ -6,8 +6,8 @@
;; Maintainer: Andy Stewart <lazycat.manatee@gmail.com>
;; Copyright (C) 2018, Andy Stewart, all rights reserved.
;; Created: 2018-09-22 10:54:16
;; Version: 1.2
;; Last-Updated: 2018-09-26 13:44:50
;; Version: 1.3
;; Last-Updated: 2018-11-12 09:40:33
;; By: Andy Stewart
;; URL: http://www.emacswiki.org/emacs/download/insert-translated-name.el
;; Keywords:
Expand Down Expand Up @@ -66,6 +66,9 @@

;;; Change log:
;;
;; 2018/11/12
;; * Remove the function of continuous translation, it is not easy to use.
;;
;; 2018/09/26
;; * Add `insert-translated-name-use-original-translation'.
;; * Nothing happen if input word is empty.
Expand Down Expand Up @@ -211,7 +214,6 @@

;; Add monitor hook.
(add-hook 'after-change-functions 'insert-translated-name-monitor-after-change nil t)
(add-hook 'pre-command-hook #'insert-translated-name-monitor-pre-command)

;; Make sure build hash to contain placeholder.
(unless (boundp 'insert-translated-name-placeholder-hash)
Expand All @@ -231,9 +233,7 @@
(overlay-put insert-translated-name-active-overlay 'face 'insert-translated-name-font-lock-mark-word)

;; Print play hint.
(if (string-equal insert-translated-name-active-style "comment")
(message "Type Chinese and press SPACE to translate, type TAB to stop translate.")
(message "Type Chinese and press SPACE to translate.")))
(message "Type Chinese and press SPACE to translate."))

(defun insert-translated-name-inactive (&optional keep-style)
(interactive)
Expand All @@ -256,20 +256,6 @@
(unless keep-style
(set (make-local-variable 'insert-translated-name-active-style) nil)))

(defun insert-translated-name-monitor-pre-command ()
(when (and (boundp 'insert-translated-name-active-point))
(let* ((event last-command-event)
(key (make-vector 1 event))
(key-desc (key-description key)))
(cond
;; End translate if press TAB with comment style.
((and (string-equal insert-translated-name-active-style "comment")
(equal key-desc "TAB"))
;; Inactive
(insert-translated-name-inactive nil)

(message "End translate comment."))))))

(defun insert-translated-name-monitor-after-change (start end len)
(when (and (boundp 'insert-translated-name-active-point))
(if insert-translated-name-active-point
Expand All @@ -284,17 +270,12 @@
(insert-translated-name-query-translation word insert-translated-name-active-style)

;; Inactive.
(insert-translated-name-inactive t)
(insert-translated-name-inactive nil)
))
;; Update active overlay bound if user press any other non-SPACE character.
(t
(move-overlay insert-translated-name-active-overlay insert-translated-name-active-point (point))))
;; Continue translate if styel is comment and press SPACE.
(when (string-equal insert-translated-name-active-style "comment")
(let ((insert-char (buffer-substring-no-properties start end)))
(when (string-equal insert-char " ")
(insert-translated-name-active "comment")
))))))
)))

(defun insert-translated-name-current-parse-state ()
"Return parse state of point from beginning of defun."
Expand Down

0 comments on commit ebf7671

Please sign in to comment.