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

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

[elpa] externals/pyim 61512db: Add pyim-register-local-variables and pyi


From: ELPA Syncer
Subject: [elpa] externals/pyim 61512db: Add pyim-register-local-variables and pyim-recreate-local-variables
Date: Fri, 23 Apr 2021 19:57:14 -0400 (EDT)

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

    Add pyim-register-local-variables and  pyim-recreate-local-variables
    
    * pyim-common.el (pyim-register-local-variables)
    (pyim-recreate-local-variables): New functions.
---
 pyim-candidates.el  |  3 +++
 pyim-common.el      | 16 ++++++++++++++++
 pyim-imobjs.el      |  3 +++
 pyim-outcome.el     |  3 +++
 pyim-preview.el     |  4 ++++
 pyim-punctuation.el |  7 +++++++
 pyim.el             | 36 +++++++++---------------------------
 7 files changed, 45 insertions(+), 27 deletions(-)

diff --git a/pyim-candidates.el b/pyim-candidates.el
index eea09a6..92aadc7 100644
--- a/pyim-candidates.el
+++ b/pyim-candidates.el
@@ -53,6 +53,9 @@
 
 细节信息请参考 `pyim-page-refresh' 的 docstring.")
 
+(pyim-register-local-variables
+ '(pyim-candidates pyim-candidate-position))
+
 (defun pyim-candidates-create-timer-function ()
   "Function used by `pyim-candidates-create-timer'"
   (let* ((scheme-name (pyim-scheme-name))
diff --git a/pyim-common.el b/pyim-common.el
index 2d8be66..a21a3f0 100644
--- a/pyim-common.el
+++ b/pyim-common.el
@@ -37,6 +37,22 @@
 
 (defvar pyim-debug nil)
 
+(defvar pyim-local-variable-list nil
+  "A list of buffer local variable.")
+
+(defun pyim-register-local-variables (vars)
+  "Recode variables VARS to `pyim-local-variable-list'."
+  (dolist (var vars)
+    (cl-pushnew var pyim-local-variable-list)
+    (make-variable-buffer-local var)
+    (put var 'permanent-local t))
+  pyim-local-variable-list)
+
+(defun pyim-recreate-local-variables ()
+  "Kill then make all variables in `pyim-local-variable-list'."
+  (mapc #'kill-local-variable pyim-local-variable-list)
+  (mapc #'make-local-variable pyim-local-variable-list))
+
 (defun pyim-string-match-p (regexp string &optional start)
   "与 `string-match-p' 类似,如果 REGEXP 和 STRING 是非字符串时,
 不会报错。"
diff --git a/pyim-imobjs.el b/pyim-imobjs.el
index 297bfe9..348690b 100644
--- a/pyim-imobjs.el
+++ b/pyim-imobjs.el
@@ -28,6 +28,7 @@
 ;;; Code:
 ;; * 代码                                                           :code:
 (require 'cl-lib)
+(require 'pyim-common)
 
 (defgroup pyim-imobjs nil
   "Imobjs lib for pyim."
@@ -76,6 +77,8 @@ imobj 组合构成在一起,构成了 imobjs 这个概念。比如:
 2. shuangpin: (\"h\" \"ao\" \"h\" \"c\")
 3. wubi:      (\"aaaa\")")
 
+(pyim-register-local-variables '(pyim-imobjs))
+
 (defun pyim-imobjs-create (entered &optional scheme-name)
   "按照 SCHEME-NAME 对应的输入法方案,从 ENTERED 字符串中创建一个
 或者多个 imobj 组成的列表,不同的输入法,imobj 的结构也是不一样的。"
diff --git a/pyim-outcome.el b/pyim-outcome.el
index 7e4d1ac..5be5f78 100644
--- a/pyim-outcome.el
+++ b/pyim-outcome.el
@@ -28,6 +28,7 @@
 ;;; Code:
 ;; * 代码                                                           :code:
 (require 'cl-lib)
+(require 'pyim-common)
 
 (defgroup pyim-outcome nil
   "Outcome tools for pyim."
@@ -168,6 +169,8 @@ pyim 的 translate-trigger-char 要占用一个键位,为了防止用户
           prefer-trigger-chars)
       user-trigger-char)))
 
+(pyim-register-local-variables '(pyim-outcome-history))
+
 ;; Fix compile warn.
 (declare-function pyim-create-word-at-point "pyim")
 (declare-function pyim-delete-word-at-point "pyim")
diff --git a/pyim-preview.el b/pyim-preview.el
index 6b93f4a..db10de4 100644
--- a/pyim-preview.el
+++ b/pyim-preview.el
@@ -28,6 +28,7 @@
 ;;; Code:
 ;; * 代码                                                           :code:
 (require 'cl-lib)
+(require 'pyim-common)
 
 (defgroup pyim-preview nil
   "Preview libs for pyim."
@@ -39,6 +40,9 @@
 (defvar pyim-preview-overlay nil
   "用于保存光标处预览字符串的 overlay.")
 
+(pyim-register-local-variables
+ '(pyim-preview-overlay pyim-local-variable-list))
+
 ;; ** 待输入字符串预览
 (defun pyim-preview-setup-overlay ()
   "设置 pyim 光标处实时预览功能所需要的 overlay.
diff --git a/pyim-punctuation.el b/pyim-punctuation.el
index 6ec65d5..9c6addd 100644
--- a/pyim-punctuation.el
+++ b/pyim-punctuation.el
@@ -28,6 +28,7 @@
 ;;; Code:
 ;; * 代码                                                           :code:
 (require 'cl-lib)
+(require 'pyim-common)
 
 (defgroup pyim-punctuation nil
   "Punctuation libs for pyim."
@@ -93,6 +94,12 @@ pyim 输入半角标点,函数列表中每个函数都有一个参数:char 
 
 If you don't like this function, set the variable to nil")
 
+(pyim-register-local-variables
+ '(pyim-punctuation-translate-p
+   pyim-punctuation-pair-status
+   pyim-punctuation-escape-list
+   pyim-punctuation-half-width-functions))
+
 (defvar pyim-input-ascii)
 (declare-function pyim-auto-switch-english-input-p "pyim")
 
diff --git a/pyim.el b/pyim.el
index 8ac8051..54f6fb9 100644
--- a/pyim.el
+++ b/pyim.el
@@ -159,31 +159,14 @@
     map)
   "Pyim 的 Keymap.")
 
-;; ** 将变量转换为 local 变量
-(defvar pyim-local-variable-list
-  '(pyim-imobjs
-    pyim-outcome-history
-    pyim-preview-overlay
-    pyim-candidates
-    pyim-candidate-position
-    pyim-input-ascii
-    ;; pyim-english-input-switch-functions
-    pyim-punctuation-half-width-functions
-    pyim-translating
-    pyim-last-created-word
-
-    input-method-function
-    inactivate-current-input-method-function
-    describe-current-input-method-function
-
-    pyim-punctuation-translate-p
-    pyim-punctuation-pair-status
-    pyim-punctuation-escape-list)
-  "A list of buffer local variable.")
-
-(dolist (var pyim-local-variable-list)
-  (make-variable-buffer-local var)
-  (put var 'permanent-local t))
+(pyim-register-local-variables
+ '(pyim-input-ascii
+   pyim-translating
+   pyim-last-created-word
+   input-method-function
+   inactivate-current-input-method-function
+   ;;pyim-english-input-switch-functions
+   describe-current-input-method-function))
 
 ;; ** 注册 Pyim 输入法
 ;;;###autoload
@@ -213,8 +196,7 @@ pyim 使用函数 `pyim-start' 启动输入法的时候,会将变量
 会执行 `pyim-input-method' 这个函数。`pyim-input-method' 又调用函
 数`pyim-start-translation'."
   (interactive)
-  (mapc #'kill-local-variable pyim-local-variable-list)
-  (mapc #'make-local-variable pyim-local-variable-list)
+  (pyim-recreate-local-variables)
   (when (and restart save-personal-dcache)
     (pyim-dcache-save-caches))
 



reply via email to

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