Commit 2d42ba8d authored by Yuanle Song's avatar Yuanle Song
Browse files

v2.3.0 auto convert Chinese dot in more cases.

capital letter + dot + digit is now supported in auto convert.
parent e9779a33
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -35,10 +35,10 @@ M-x customize-group zero-input-pinyin
  user phrase db.
- To delete system phrase or user phrase, type C-<digit> when candidate is
  shown in zero-panel.
- Auto period for digits and English letter and digit mixed words. For
  example, to type "3.6" when zero-input-mode is on, type "3." will insert "3。
  ", just continue type 6, it will be converted to "3.6". Same thing for "H。
  265" -> "H.265".
- Auto convert Chinese period to dot for digits and English letter and digit
  mixed words. For example, to type "3.6" when zero-input-mode is on, type
  "3." will insert "3。", just continue type 6, it will be converted to
  "3.6". Same thing for "H。265" -> "H.265".

* File list
- zero-input.el
+9 −0
Original line number Diff line number Diff line
@@ -111,6 +111,12 @@ cd ~/lisp/elisp/zero/
* later                                                               :entry:
* current                                                             :entry:
** 
** 2020-02-15 zero-el:中文标点full模式下,无法输入 fan'gai 翻盖
因为'会自动变成左引号。
而'在zps里面还有分词字符的含义。

- 建议取消 preedit 状态下'的自动 commit 1st candidate 并插入引号的功能。

** 2020-02-16 declare zero-input-punctuation-level, zero-input-full-width-p using defcustom
use setq-default to set the value.

@@ -119,6 +125,9 @@ complete registered im symbols.
** 2019-10-23 checkdoc and package-lint can't ignore some non-issues.
I can't run them in git pre-commit hook.
* done                                                                :entry:
** 2020-02-14 zero-el: H。265 > H.265
除了数字+小数点+数字,大写英文+小数点+数字也可以自动转换。

** 2020-02-02 zero-el: 如果输入“。”之前和之后输入的是数字,则自动将"。"转换为小数点"."。
(setq zero-input-auto-fix-dot-between-numbers t)
enabled by default.
+17 −0
Original line number Diff line number Diff line
@@ -54,6 +54,23 @@
  (let ((zero-input-initial-fetch-size 12))
    (should (= 12 (zero-input-get-initial-fetch-size)))))

(ert-deftest zero-input-add-recent-insert-char ()
  (let ((test-ring (make-ring 3)))
    (ring-insert test-ring 'a)
    (ring-insert test-ring 'b)
    (ring-insert test-ring 'c)
    (should (eq 'c (ring-ref test-ring 0)))
    (should (eq 'b (ring-ref test-ring 1)))
    (should (eq 'a (ring-ref test-ring 2))))
  (let ((test-ring (make-ring 3)))
    (ring-insert test-ring 'a)
    (ring-insert test-ring 'b)
    (ring-insert test-ring 'c)
    (ring-insert test-ring 'd)
    (should (eq 'd (ring-ref test-ring 0)))
    (should (eq 'c (ring-ref test-ring 1)))
    (should (eq 'b (ring-ref test-ring 2)))))

(provide 'zero-input-framework-test)

;;; zero-input-framework-test.el ends here
+9 −5
Original line number Diff line number Diff line
@@ -133,7 +133,7 @@ If item is not in lst, return nil."

;; zero-input-el version
(defvar zero-input-version nil "Zero package version.")
(setq zero-input-version "2.2.2")
(setq zero-input-version "2.3.0")

;; FSM state
(defconst zero-input--state-im-off 'IM-OFF)
@@ -743,11 +743,15 @@ Argument CH the character that was inserted."
  (if (and zero-input-mode zero-input-auto-fix-dot-between-numbers)
      (let ((ch (or ch (elt (this-command-keys-vector) 0))))
	(zero-input-add-recent-insert-char ch)
	;; if user typed digit “。” digit, auto convert “。” to “.”
	(cl-flet ((my-digit-char-p (ch) (and (>= ch ?0) (<= ch ?9))))
	  (when (and (my-digit-char-p (ring-ref zero-input-recent-insert-chars 0))
	;; if user typed "[0-9A-Z]。[0-9]", auto convert “。” to “.”
	(cl-flet ((my-digit-char-p (ch) (and (>= ch ?0) (<= ch ?9)))
		  (my-capital-letter-p (ch) (and (>= ch ?A) (<= ch ?Z))))
	  ;; ring-ref index 2 is least recent inserted char.
	  (when (and (let ((ch (ring-ref zero-input-recent-insert-chars 2)))
		       (or (my-digit-char-p ch)
			   (my-capital-letter-p ch)))
		     (equal ? (ring-ref zero-input-recent-insert-chars 1))
		     (my-digit-char-p (ring-ref zero-input-recent-insert-chars 2)))
		     (my-digit-char-p (ring-ref zero-input-recent-insert-chars 0)))
	    (delete-char -2)
	    (insert "." (car (ring-elements zero-input-recent-insert-chars))))))))

+10 −6
Original line number Diff line number Diff line
@@ -12,7 +12,7 @@
;; See the License for the specific language governing permissions and
;; limitations under the License.

;; Version: 2.2.2
;; Version: 2.3.0
;; URL: https://gitlab.emacsos.com/sylecn/zero-el
;; Package-Requires: ((emacs "24.3") (s "1.2.0"))

@@ -246,7 +246,7 @@ If item is not in lst, return nil."

;; zero-input-el version
(defvar zero-input-version nil "Zero package version.")
(setq zero-input-version "2.2.2")
(setq zero-input-version "2.3.0")

;; FSM state
(defconst zero-input--state-im-off 'IM-OFF)
@@ -856,11 +856,15 @@ Argument CH the character that was inserted."
  (if (and zero-input-mode zero-input-auto-fix-dot-between-numbers)
      (let ((ch (or ch (elt (this-command-keys-vector) 0))))
	(zero-input-add-recent-insert-char ch)
	;; if user typed digit “。” digit, auto convert “。” to “.”
	(cl-flet ((my-digit-char-p (ch) (and (>= ch ?0) (<= ch ?9))))
	  (when (and (my-digit-char-p (ring-ref zero-input-recent-insert-chars 0))
	;; if user typed "[0-9A-Z]。[0-9]", auto convert “。” to “.”
	(cl-flet ((my-digit-char-p (ch) (and (>= ch ?0) (<= ch ?9)))
		  (my-capital-letter-p (ch) (and (>= ch ?A) (<= ch ?Z))))
	  ;; ring-ref index 2 is least recent inserted char.
	  (when (and (let ((ch (ring-ref zero-input-recent-insert-chars 2)))
		       (or (my-digit-char-p ch)
			   (my-capital-letter-p ch)))
		     (equal ? (ring-ref zero-input-recent-insert-chars 1))
		     (my-digit-char-p (ring-ref zero-input-recent-insert-chars 2)))
		     (my-digit-char-p (ring-ref zero-input-recent-insert-chars 0)))
	    (delete-char -2)
	    (insert "." (car (ring-elements zero-input-recent-insert-chars))))))))