branch: externals/pyim commit ce1ee215f7e9e41d2cdd3f353700e97940e07031 Author: Feng Shu <tuma...@163.com> Commit: Feng Shu <tuma...@163.com>
* pyim-cloudim.el (pyim-cloudim:baidu, pyim-cloudim:google): Handle buffer is nil. --- pyim-cloudim.el | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/pyim-cloudim.el b/pyim-cloudim.el index 32af111b98..3e8a7b1358 100644 --- a/pyim-cloudim.el +++ b/pyim-cloudim.el @@ -55,10 +55,12 @@ (defun pyim-cloudim:baidu (string scheme-name) "使用 baidu 云输入法引擎搜索 STRING, 获取词条列表。" (when (equal scheme-name 'quanpin) - (with-current-buffer (pyim-cloudim-url-retrieve-sync - (format "https://olime.baidu.com/py?py=%s" string) - t nil 0.1) - (pyim-cloudim-parse-baidu-buffer)))) + (let ((buffer (pyim-cloudim-url-retrieve-sync + (format "https://olime.baidu.com/py?py=%s" string) + t nil 0.2))) + (when (bufferp buffer) + (with-current-buffer buffer + (pyim-cloudim-parse-baidu-buffer)))))) (defun pyim-cloudim-url-retrieve-sync (url &optional silent inhibit-cookies timeout) "Pyim 版本的 `url-retrieve-synchronously'. @@ -134,10 +136,12 @@ (defun pyim-cloudim:google (string scheme-name) "使用 google 云输入法引擎搜索 STRING, 获取词条列表。" (when (eq scheme-name 'quanpin) - (with-current-buffer (pyim-cloudim-url-retrieve-sync - (format "https://www.google.cn/inputtools/request?ime=pinyin&text=%s" string) - t nil 0.1) - (pyim-cloudim-parse-google-buffer)))) + (let ((buffer (pyim-cloudim-url-retrieve-sync + (format "https://www.google.cn/inputtools/request?ime=pinyin&text=%s" string) + t nil 0.2))) + (when (bufferp buffer) + (with-current-buffer buffer + (pyim-cloudim-parse-google-buffer)))))) (defun pyim-cloudim-parse-google-buffer () "解析 `pyim-cloudim-url-retrieve-sync' 返回的 google buffer."