[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/pyim 302f1bff4b 34/41: Refactor pyim-preview.el
From: |
ELPA Syncer |
Subject: |
[elpa] externals/pyim 302f1bff4b 34/41: Refactor pyim-preview.el |
Date: |
Sat, 4 Jun 2022 09:57:47 -0400 (EDT) |
branch: externals/pyim
commit 302f1bff4b8d21a08adf3e9dd4332e68b50f4aef
Author: Feng Shu <tumashu@163.com>
Commit: Feng Shu <tumashu@163.com>
Refactor pyim-preview.el
---
pyim-preview.el | 48 ++++++++++++++++++++++++++++++++----------------
1 file changed, 32 insertions(+), 16 deletions(-)
diff --git a/pyim-preview.el b/pyim-preview.el
index a2afaa9eea..68b2f82e73 100644
--- a/pyim-preview.el
+++ b/pyim-preview.el
@@ -67,7 +67,8 @@
这个函数会在 `pyim-input-method' 中调用,用于删除
`pyim-preview-overlay' 中保存的 overlay。"
- (if (and (overlayp pyim-preview-overlay) (overlay-start
pyim-preview-overlay))
+ (if (and (overlayp pyim-preview-overlay)
+ (overlay-start pyim-preview-overlay))
(delete-overlay pyim-preview-overlay)))
(defun pyim-preview-refresh (&rest _)
@@ -77,21 +78,7 @@ pyim 会使用 Emacs overlay 机制在 *待输入buffer* 光标处高亮显示
个预览字符串,让用户可以查看将要输入的字符串,这个函数用于更新这
个字符串的内容。"
(let* ((scheme (pyim-scheme-current))
- (candidates (pyim-process-get-candidates))
- (pos (1- (min (pyim-process-get-candidate-position)
- (length candidates))))
- (preview (concat (pyim-process-get-outcome)
- (nth pos candidates))))
- (when (pyim-scheme-quanpin-p scheme)
- (let ((rest (mapconcat
- (lambda (py)
- (concat (nth 0 py) (nth 1 py)))
- (nthcdr (length preview)
- (pyim-process-get-first-imobj))
- "'")))
- (when (string< "" rest)
- (setq preview (concat preview rest)))))
- (setq preview (pyim-process-subword-and-magic-convert preview))
+ (preview (pyim-preview-string scheme)))
;; Delete old preview string.
(pyim-preview-delete-string)
;; Insert new preview string.
@@ -102,6 +89,35 @@ pyim 会使用 Emacs overlay 机制在 *待输入buffer* 光标处高亮显示
(add-hook 'pyim-process-ui-refresh-hook #'pyim-preview-refresh)
+(cl-defgeneric pyim-preview-string (scheme)
+ "获得 preview 字符串。")
+
+(cl-defmethod pyim-preview-string (_scheme)
+ "获得 preview 字符串。"
+ (let* ((candidates (pyim-process-get-candidates))
+ (pos (1- (min (pyim-process-get-candidate-position)
+ (length candidates))))
+ (preview (concat (pyim-process-get-outcome)
+ (nth pos candidates))))
+ (pyim-process-subword-and-magic-convert preview)))
+
+(cl-defmethod pyim-preview-string ((_scheme pyim-scheme-quanpin))
+ "获得 preview 字符串,适用于全拼输入法。"
+ (let* ((candidates (pyim-process-get-candidates))
+ (pos (1- (min (pyim-process-get-candidate-position)
+ (length candidates))))
+ (preview (concat (pyim-process-get-outcome)
+ (nth pos candidates)))
+ (rest (mapconcat
+ (lambda (py)
+ (concat (nth 0 py) (nth 1 py)))
+ (nthcdr (length preview)
+ (pyim-process-get-first-imobj))
+ "'")))
+ (when (string< "" rest)
+ (setq preview (concat preview rest)))
+ (pyim-process-subword-and-magic-convert preview)))
+
(defun pyim-preview-delete-string ()
"删除已经插入 buffer 的 preview 预览字符串。"
(when (overlay-start pyim-preview-overlay)
- [elpa] externals/pyim 33a0f5a9b7 09/41: Add pyim-candidates-create-like-jianpin, (continued)
- [elpa] externals/pyim 33a0f5a9b7 09/41: Add pyim-candidates-create-like-jianpin, ELPA Syncer, 2022/06/04
- [elpa] externals/pyim b6b46a4e36 22/41: * pyim-candidates.el (pyim-candidates-create): Remove method of shuangpin., ELPA Syncer, 2022/06/04
- [elpa] externals/pyim b3868caa80 29/41: Add pyim-probe tests, ELPA Syncer, 2022/06/04
- [elpa] externals/pyim 951013539c 33/41: Add progress to commentary, ELPA Syncer, 2022/06/04
- [elpa] externals/pyim f4cc14ac64 32/41: Fix pyim-test.el, ELPA Syncer, 2022/06/04
- [elpa] externals/pyim 1b767c669e 40/41: * pyim-probe.el (pyim-probe-org-speed-commands): Updated., ELPA Syncer, 2022/06/04
- [elpa] externals/pyim 6ef8630475 11/41: pyim-candidates-create-like-znabc -> pyim-candidates-znabc-words, ELPA Syncer, 2022/06/04
- [elpa] externals/pyim 2aa48479b4 14/41: pyim-candidates-create-get-pymap-chars -> pyim-candidates-pymap-chars, ELPA Syncer, 2022/06/04
- [elpa] externals/pyim 016064e7fc 16/41: Update docstring., ELPA Syncer, 2022/06/04
- [elpa] externals/pyim 1330b436a6 27/41: Refactor pyim-page.el, ELPA Syncer, 2022/06/04
- [elpa] externals/pyim 302f1bff4b 34/41: Refactor pyim-preview.el,
ELPA Syncer <=
- [elpa] externals/pyim 987087e515 15/41: Update pyim-candidates-create-quanpin., ELPA Syncer, 2022/06/04
- [elpa] externals/pyim 35bf05ce3e 19/41: pyim-scheme-common -> pyim-scheme, ELPA Syncer, 2022/06/04
- [elpa] externals/pyim fa9f9f4244 24/41: Update pyim-candidates-dcache-words., ELPA Syncer, 2022/06/04
- [elpa] externals/pyim aaa5f728f9 25/41: Fix compile warn., ELPA Syncer, 2022/06/04
- [elpa] externals/pyim 29a112182a 28/41: Refactor pyim-candidates.el, ELPA Syncer, 2022/06/04
- [elpa] externals/pyim c4d73f836d 13/41: pyim-candidates-create-get-dcache-words -> pyim-candidates-dcache-words, ELPA Syncer, 2022/06/04
- [elpa] externals/pyim 3e53c5e923 20/41: pyim-candidates-create-quanpin -> pyim-candidates-quanpin, ELPA Syncer, 2022/06/04
- [elpa] externals/pyim c1cbba5f52 18/41: Fix pyim-tests.el, ELPA Syncer, 2022/06/04
- [elpa] externals/pyim 4c8b8afc5a 21/41: * pyim-candidates.el (pyim-candidates-quanpin): Simplify., ELPA Syncer, 2022/06/04
- [elpa] externals/pyim 7c6ece9d4d 26/41: * pyim-liberime.el (pyim-process-terminate-really): do not use :after., ELPA Syncer, 2022/06/04