branch: externals/pyim commit dad6b82a062798c8bb5cf272981cf660eb1509bc Author: Feng Shu <tuma...@163.com> Commit: Feng Shu <tuma...@163.com>
Add pyim--delete-region-or-chars --- pyim.el | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/pyim.el b/pyim.el index 42381767b9..d4a998b8a2 100644 --- a/pyim.el +++ b/pyim.el @@ -618,16 +618,19 @@ FILE 的格式与 `pyim-dcache-export' 生成的文件格式相同, (code (nth 0 code-info-at-point)) (char-num-need-delete (nth 1 code-info-at-point))) - (when mark-active - (delete-region - (region-beginning) (region-end))) - (when (and (not mark-active) - (> char-num-need-delete 0)) - (backward-delete-char char-num-need-delete)) + (pyim--delete-region-or-chars char-num-need-delete) (when (> (length code) 0) (pyim-add-unread-command-events code) (pyim-process-force-input-chinese)))) +(defun pyim--delete-region-or-chars (&optional num) + "删除 region 或者光标之前 NUM 个字符。" + (if mark-active + (delete-region + (region-beginning) (region-end)) + (when (and (numberp num) (> num 0)) + (backward-delete-char num)))) + ;; ** 编码反查功能 (defun pyim-search-word-code () "选择词条,然后反查它的 code。"