branch: externals/pyim commit 6241955a7e4facad787319822eda36c843a0022d Author: Feng Shu <tuma...@163.com> Commit: Feng Shu <tuma...@163.com>
* pyim-cstring.el (pyim-cstring-to-codes): better handle when no entered. --- pyim-cstring.el | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/pyim-cstring.el b/pyim-cstring.el index a5acb30..31a7f8d 100644 --- a/pyim-cstring.el +++ b/pyim-cstring.el @@ -356,16 +356,18 @@ code-prefix)。当RETURN-LIST 设置为 t 时,返回一个 code list。" (cond ((eq class 'xingma) (pyim-cstring-to-xingma string scheme-name t)) ;;拼音使用了多音字校正 - (t (let* ((entered (or entered "")) - (codes (pyim-cstring-to-pinyin string nil "-" t nil t)) - (codes-sorted - (sort codes - (lambda (a b) - (< (string-distance a entered) - (string-distance b entered)))))) - ;; 将 code 与用户输入 entered 比对,选取一个与用户输入最类似的 - ;; code. 这种处理方式适合拼音输入法。 - (list (car codes-sorted))))))) + (t (let ((codes (pyim-cstring-to-pinyin string nil "-" t nil t)) + codes-sorted) + (if (< (length entered) 1) + codes + ;; 将 code 与用户输入 entered 比对,选取一个与用户输入最类似的 + ;; code. 这种处理方式适合拼音输入法。 + (setq codes-sorted + (sort codes + (lambda (a b) + (< (string-distance a entered) + (string-distance b entered))))) + (list (car codes-sorted)))))))) ;; ** 获取光标处中文字符串或者中文词条的功能 (defun pyim-cstring-at-point (&optional number)