[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/pyim eafaef3 22/36: update pyim-cstring.el
From: |
ELPA Syncer |
Subject: |
[elpa] externals/pyim eafaef3 22/36: update pyim-cstring.el |
Date: |
Thu, 22 Apr 2021 22:57:19 -0400 (EDT) |
branch: externals/pyim
commit eafaef3fd22aa5ce1114503d71f1080ea2750418
Author: Feng Shu <tumashu@163.com>
Commit: Feng Shu <tumashu@163.com>
update pyim-cstring.el
---
pyim-cstring.el | 37 +++++++++++++++++++++++++++++++++++++
pyim.el | 36 ------------------------------------
2 files changed, 37 insertions(+), 36 deletions(-)
diff --git a/pyim-cstring.el b/pyim-cstring.el
index da89b06..e92e1fb 100644
--- a/pyim-cstring.el
+++ b/pyim-cstring.el
@@ -301,6 +301,43 @@ BUG: 当 STRING 中包含其它标点符号,并且设置 SEPERATER 时,结
"简化版的 `pyim-cstring-to-pinyin', 不处理多音字。"
(pyim-cstring-to-pinyin string shou-zi-mu separator return-list t))
+(defalias 'pyim-hanzi2xingma 'pyim-cstring-to-xingma)
+(defun pyim-cstring-to-xingma (string scheme-name &optional return-list)
+ "返回汉字 STRING 对应形码方案 SCHEME-NAME 的 code (不包括
+code-prefix)。当RETURN-LIST 设置为 t 时,返回一个 code list。"
+ (let* ((fun (intern (concat "pyim-cstring-to-xingma:" (symbol-name
scheme-name))))
+ (code (and fun (funcall fun string))))
+ (when code
+ (if return-list
+ (list code)
+ code))))
+
+(defun pyim-cstring-to-xingma:wubi (string)
+ "返回汉字 STRING 的五笔编码(不包括 code-prefix)。当RETURN-LIST
+设置为 t 时,返回一个编码列表。"
+ (when (string-match-p "^\\cc+\\'" string)
+ (let ((code (pyim-code-search string 'wubi))
+ (len (length string)))
+ (when (string-empty-p code)
+ (when (= len 1)
+ (error "No code found for %s" string))
+ (setq string (split-string string "" t)
+ code
+ (cl-case len
+ ;; 双字词,分别取两个字的前两个编码
+ (2 (concat (substring (pyim-cstring-to-xingma:wubi (nth 0
string)) 0 2)
+ (substring (pyim-cstring-to-xingma:wubi (nth 1
string)) 0 2)))
+ ;; 三字词,取前二字的首编码,及第三个字的前两个编码
+ (3 (concat (substring (pyim-cstring-to-xingma:wubi (nth 0
string)) 0 1)
+ (substring (pyim-cstring-to-xingma:wubi (nth 1
string)) 0 1)
+ (substring (pyim-cstring-to-xingma:wubi (nth 2
string)) 0 2)))
+ ;; 四字词及以上,分别前三个字及最后一个字的首编码
+ (t (concat (substring (pyim-cstring-to-xingma:wubi (nth 0
string)) 0 1)
+ (substring (pyim-cstring-to-xingma:wubi (nth 1
string)) 0 1)
+ (substring (pyim-cstring-to-xingma:wubi (nth 2
string)) 0 1)
+ (substring (pyim-cstring-to-xingma:wubi (nth (1-
len) string)) 0 1))))))
+ code)))
+
(defalias 'pyim-cwords-at-point 'pyim-cstring-words-at-point)
(defun pyim-cstring-words-at-point (&optional end-of-point)
"获取光标当前的词条列表,当 END-OF-POINT 设置为 t 时,获取光标后的词条列表。
diff --git a/pyim.el b/pyim.el
index 8673f40..1541411 100644
--- a/pyim.el
+++ b/pyim.el
@@ -1029,42 +1029,6 @@ BUG:拼音无法有效地处理多音字。"
;; TODO, 排序个人词库?
)))
-(defun pyim-hanzi2xingma (string scheme-name &optional return-list)
- "返回汉字 STRING 对应形码方案 SCHEME-NAME 的 code (不包括
-code-prefix)。当RETURN-LIST 设置为 t 时,返回一个 code list。"
- (let* ((fun (intern (concat "pyim-hanzi2xingma:" (symbol-name scheme-name))))
- (code (and fun (funcall fun string))))
- (when code
- (if return-list
- (list code)
- code))))
-
-(defun pyim-hanzi2xingma:wubi (string)
- "返回汉字 STRING 的五笔编码(不包括 code-prefix)。当RETURN-LIST
-设置为 t 时,返回一个编码列表。"
- (when (string-match-p "^\\cc+\\'" string)
- (let ((code (pyim-code-search string 'wubi))
- (len (length string)))
- (when (string-empty-p code)
- (when (= len 1)
- (error "No code found for %s" string))
- (setq string (split-string string "" t)
- code
- (cl-case len
- ;; 双字词,分别取两个字的前两个编码
- (2 (concat (substring (pyim-hanzi2xingma:wubi (nth 0 string))
0 2)
- (substring (pyim-hanzi2xingma:wubi (nth 1 string))
0 2)))
- ;; 三字词,取前二字的首编码,及第三个字的前两个编码
- (3 (concat (substring (pyim-hanzi2xingma:wubi (nth 0 string))
0 1)
- (substring (pyim-hanzi2xingma:wubi (nth 1 string))
0 1)
- (substring (pyim-hanzi2xingma:wubi (nth 2 string))
0 2)))
- ;; 四字词及以上,分别前三个字及最后一个字的首编码
- (t (concat (substring (pyim-hanzi2xingma:wubi (nth 0 string))
0 1)
- (substring (pyim-hanzi2xingma:wubi (nth 1 string))
0 1)
- (substring (pyim-hanzi2xingma:wubi (nth 2 string))
0 1)
- (substring (pyim-hanzi2xingma:wubi (nth (1- len)
string)) 0 1))))))
- code)))
-
(defun pyim-create-word-at-point (&optional number silent)
"将光标前字符数为 NUMBER 的中文字符串添加到个人词库中
当 SILENT 设置为 t 是,不显示提醒信息。"
- [elpa] externals/pyim 900071a 02/36: Add pyim-pinyin.el, (continued)
- [elpa] externals/pyim 900071a 02/36: Add pyim-pinyin.el, ELPA Syncer, 2021/04/22
- [elpa] externals/pyim c13c2a6 06/36: Move code to pyim-common.el, ELPA Syncer, 2021/04/22
- [elpa] externals/pyim 09fd273 07/36: Sort pyim-common.el, ELPA Syncer, 2021/04/22
- [elpa] externals/pyim 6dfe546 08/36: New pyim-punctuation.el file., ELPA Syncer, 2021/04/22
- [elpa] externals/pyim 6cc63e8 09/36: New file: pyim-dict.el, ELPA Syncer, 2021/04/22
- [elpa] externals/pyim 8ae9ad9 10/36: New file pyim-cstring.el, ELPA Syncer, 2021/04/22
- [elpa] externals/pyim 678240a 16/36: Add pyim-candidates.el, ELPA Syncer, 2021/04/22
- [elpa] externals/pyim fa9a82a 17/36: pyim-posframe-* -> pyim-page-posframe-*, ELPA Syncer, 2021/04/22
- [elpa] externals/pyim 8023823 15/36: New file: pyim-page.el, ELPA Syncer, 2021/04/22
- [elpa] externals/pyim cfd96c6 20/36: update pyim-candidates.el, ELPA Syncer, 2021/04/22
- [elpa] externals/pyim eafaef3 22/36: update pyim-cstring.el,
ELPA Syncer <=
- [elpa] externals/pyim c9cd6bf 27/36: Add pyim-autoselector.el, ELPA Syncer, 2021/04/22
- [elpa] externals/pyim f56d0a6 30/36: Add README.org, ELPA Syncer, 2021/04/22
- [elpa] externals/pyim f26fecc 03/36: New file: pyim-cregexp.el, ELPA Syncer, 2021/04/22
- [elpa] externals/pyim 819f9c6 04/36: Move pyim-permutate-list* to pyim-common.el, ELPA Syncer, 2021/04/22
- [elpa] externals/pyim bf3626c 05/36: * pyim-common.el (pyim-flatten-list): Move from pyim.el, ELPA Syncer, 2021/04/22
- [elpa] externals/pyim 97fd721 11/36: New file pyim-scheme.el, ELPA Syncer, 2021/04/22
- [elpa] externals/pyim 4e7fe1b 12/36: Add new file: pyim-dcache.el, ELPA Syncer, 2021/04/22
- [elpa] externals/pyim af1bec4 14/36: update pyim-cstring.el, ELPA Syncer, 2021/04/22
- [elpa] externals/pyim 08be340 24/36: pyim-fuzzy-pinyin-alist -> pyim-pinyin-fuzzy-alist, ELPA Syncer, 2021/04/22
- [elpa] externals/pyim de98d10 28/36: pyim-page-select* -> pyim-select*, ELPA Syncer, 2021/04/22