emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/pyim c510a7d: Handle (rx-to-string "") => "\\(?:\\)" pr


From: ELPA Syncer
Subject: [elpa] externals/pyim c510a7d: Handle (rx-to-string "") => "\\(?:\\)" problem
Date: Tue, 9 Mar 2021 03:57:08 -0500 (EST)

branch: externals/pyim
commit c510a7d7202ff0d5cc9a49e344cd27de65df1f2a
Author: Feng Shu <tumashu@163.com>
Commit: Feng Shu <tumashu@163.com>

    Handle (rx-to-string "") => "\\(?:\\)" problem
    
    * pyim.el (pyim-cregexp-build, pyim-cregexp-build-1)
    (pyim-ivy-cregexp): Handle (rx-to-string "") => "\\(?:\\)" problem
---
 pyim.el | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/pyim.el b/pyim.el
index e3ff5ea..537899a 100644
--- a/pyim.el
+++ b/pyim.el
@@ -3834,14 +3834,17 @@ PUNCT-LIST 格式类似:
 (defun pyim-cregexp-build (string)
   "根据 STRING 构建一个中文 regexp, 用于 \"拼音搜索汉字\".
 比如:\"nihao\" -> \"[你呢...][好号...] \\| nihao\""
-  (or (ignore-errors
-        (rx-to-string (pyim-cregexp-build-from-rx
-                       (lambda (x)
-                         (if (stringp x)
-                             (xr (pyim-cregexp-build-1 x))
-                           x))
-                       (xr string))))
-      string))
+  ;; FIXME: (rx-to-string "") => "\\(?:\\)"
+  (if (equal string "")
+      string
+    (or (ignore-errors
+          (rx-to-string (pyim-cregexp-build-from-rx
+                         (lambda (x)
+                           (if (stringp x)
+                               (xr (pyim-cregexp-build-1 x))
+                             x))
+                         (xr string))))
+        string)))
 
 (defun pyim-cregexp-build-from-rx (fn rx-form)
   (cond
@@ -3875,7 +3878,8 @@ PUNCT-LIST 格式类似:
       (setq scheme-name pyim-cregexp-fallback-scheme))
     (mapconcat
      (lambda (string)
-       (if (or (pyim-string-match-p "[^a-z']+" string))
+       (if (or (pyim-string-match-p "[^a-z']+" string)
+               (equal string ""))
            string
          (let* ((imobjs (pyim-imobjs-create
                          (replace-regexp-in-string "'" "" string)
@@ -3999,9 +4003,7 @@ PUNCT-LIST 格式类似:
                             (cdr y))
                     (list (pyim-cregexp-build (car y)))))
                 x)
-      (if (string= "" x)
-          x
-        (pyim-cregexp-build x)))))
+      (pyim-cregexp-build x))))
 
 (defun pyim-convert-cregexp-at-point (&optional insert-only)
   "将光标前的字符串按拼音的规则转换为一个搜索中文的 regexp.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]