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

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

[elpa] externals/pyim f5bc9da4fe 5/5: * pyim-dhashcache.el (pyim-dhashca


From: ELPA Syncer
Subject: [elpa] externals/pyim f5bc9da4fe 5/5: * pyim-dhashcache.el (pyim-dhashcache-export): Use sort-lines.
Date: Sat, 11 Jun 2022 19:57:50 -0400 (EDT)

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

    * pyim-dhashcache.el (pyim-dhashcache-export): Use sort-lines.
---
 pyim-dhashcache.el  | 5 ++++-
 tests/pyim-tests.el | 4 ++++
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/pyim-dhashcache.el b/pyim-dhashcache.el
index d4ff1093a1..d79b0bf110 100644
--- a/pyim-dhashcache.el
+++ b/pyim-dhashcache.el
@@ -39,6 +39,7 @@
 (require 'pyim-dcache)
 (require 'pyim-dict)
 (require 'pyim-scheme)
+(require 'sort)
 
 (defvar pyim-dhashcache-count-types
   `((day
@@ -718,7 +719,6 @@ pyim 使用的词库文件是简单的文本文件,编码 *强制* 为 \\='utf
 如果 CONFIRM 为 non-nil,文件存在时将会提示用户是否覆盖,
 默认为覆盖模式"
   (with-temp-buffer
-    (insert ";;; -*- coding: utf-8-unix -*-\n")
     (maphash
      (lambda (key value)
        (let ((value (cl-remove-if
@@ -733,6 +733,9 @@ pyim 使用的词库文件是简单的文本文件,编码 *强制* 为 \\='utf
          (when value
            (insert (format "%s %s\n" key (mapconcat #'identity value " "))))))
      dcache)
+    (sort-lines nil (point-min) (point-max))
+    (goto-char (point-min))
+    (insert ";;; -*- coding: utf-8-unix -*-\n")
     (pyim-dcache-write-file file confirm)))
 
 (cl-defmethod pyim-dcache-export-words-and-counts
diff --git a/tests/pyim-tests.el b/tests/pyim-tests.el
index 829f0e1e81..485eb77bf5 100644
--- a/tests/pyim-tests.el
+++ b/tests/pyim-tests.el
@@ -1033,6 +1033,7 @@
         (file (pyim-tests-make-temp-file)))
     (puthash "你好" 10 pyim-dhashcache-iword2count)
     (puthash "尼耗" 1 pyim-dhashcache-iword2count)
+    (puthash "wo-hao" (list "我好") pyim-dhashcache-icode2word)
     (puthash "ni-hao" (list "你好" "尼耗") pyim-dhashcache-icode2word)
     (pyim-dcache-export-words-and-counts file)
     (with-temp-buffer
@@ -1041,6 +1042,7 @@
                      ";;; -*- coding: utf-8-unix -*-
 你好 10
 尼耗 1
+我好 0
 ")))
     (pyim-dcache-export-words-and-counts file nil t)
     (with-temp-buffer
@@ -1049,6 +1051,7 @@
                      ";;; -*- coding: utf-8-unix -*-
 你好
 尼耗
+我好
 ")))
     (pyim-dcache-export-personal-words file)
     (with-temp-buffer
@@ -1056,6 +1059,7 @@
       (should (equal (buffer-string)
                      ";;; -*- coding: utf-8-unix -*-
 ni-hao 你好 尼耗
+wo-hao 我好
 ")))))
 
 (ert-deftest pyim-tests-pyim-dcache-insert-word ()



reply via email to

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