branch: externals/pyim commit 66588aae5c154ca7ee39c269cd71a8fda64e868f Merge: 3692134d6f 7230c164b8 Author: tumashu <tuma...@163.com> Commit: GitHub <nore...@github.com>
Merge pull request #438 from redguardtoo/master use elint and byte-compile for CI --- .gitignore | 2 ++ pyim-candidates.el | 2 ++ pyim-common.el | 2 ++ pyim-cregexp.el | 6 +++++- pyim-dcache.el | 1 + pyim-imobjs.el | 1 + pyim-outcome.el | 1 + pyim-preview.el | 3 +++ pyim.el | 2 +- tests/Makefile | 20 ++++++++++++++----- tests/pyim-byte-compile.el | 49 ++++++++++++++++++++++++++++++++++++++++++++++ tests/pyim-elint.el | 34 ++++++++++++++++++++++++++++++++ 12 files changed, 116 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index b9578db745..5946b1e3d5 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,5 @@ /tests/pyim-tests-temp-* /tests/deps/ +TAGS +tags diff --git a/pyim-candidates.el b/pyim-candidates.el index bcf7a69988..0aa0321f8b 100644 --- a/pyim-candidates.el +++ b/pyim-candidates.el @@ -32,6 +32,8 @@ (require 'pyim-dcache) (require 'pyim-codes) (require 'pyim-pymap) +(require 'pyim-cregexp) +(require 'pyim-cstring) (defgroup pyim-candidates nil "Candidates of pyim." diff --git a/pyim-common.el b/pyim-common.el index 2a30a38ea6..3ab334a279 100644 --- a/pyim-common.el +++ b/pyim-common.el @@ -30,6 +30,8 @@ ;;; Code: ;; * 代码 :code: +(require 'cl-lib) +(require 'subr-x) (defgroup pyim-common nil "pyim common." diff --git a/pyim-cregexp.el b/pyim-cregexp.el index 7bcbbfbd09..c43ed445c1 100644 --- a/pyim-cregexp.el +++ b/pyim-cregexp.el @@ -28,9 +28,13 @@ ;;; Code: ;; * 代码 :code: (require 'cl-lib) -(require 'pyim-pymap) +(require 'isearch) (require 'xr) (require 'rx) +(require 'pyim-pymap) +(require 'pyim-scheme) +(require 'pyim-imobjs) +(require 'pyim-dcache) (defgroup pyim-cregexp nil "Chinese regexp tools for pyim." diff --git a/pyim-dcache.el b/pyim-dcache.el index 58e8235120..0a9885569d 100644 --- a/pyim-dcache.el +++ b/pyim-dcache.el @@ -29,6 +29,7 @@ ;; * 代码 :code: (require 'cl-lib) (require 'pyim-common) +(require 'pyim-pymap) (require 'url-util) (defgroup pyim-dcache nil diff --git a/pyim-imobjs.el b/pyim-imobjs.el index 9440b8b016..f606e67bae 100644 --- a/pyim-imobjs.el +++ b/pyim-imobjs.el @@ -30,6 +30,7 @@ (require 'cl-lib) (require 'pyim-common) (require 'pyim-pinyin) +(require 'pyim-scheme) (defgroup pyim-imobjs nil "Imobjs lib for pyim." diff --git a/pyim-outcome.el b/pyim-outcome.el index 47f88c4e23..55963409d9 100644 --- a/pyim-outcome.el +++ b/pyim-outcome.el @@ -29,6 +29,7 @@ ;; * 代码 :code: (require 'cl-lib) (require 'pyim-common) +(require 'pyim-scheme) (defgroup pyim-outcome nil "Outcome tools for pyim." diff --git a/pyim-preview.el b/pyim-preview.el index b5bec800a0..823198747a 100644 --- a/pyim-preview.el +++ b/pyim-preview.el @@ -30,6 +30,7 @@ (require 'cl-lib) (require 'pyim-common) (require 'pyim-process) +(require 'mule) (defgroup pyim-preview nil "Preview libs for pyim." @@ -41,6 +42,8 @@ (defvar pyim-preview-overlay nil "用于保存光标处预览字符串的 overlay.") +(defvar input-method-highlight-flag) ;; fixed compiling error + (pyim-register-local-variables '(pyim-preview-overlay)) ;; ** 待输入字符串预览 diff --git a/pyim.el b/pyim.el index e03389ffba..069d2897a1 100644 --- a/pyim.el +++ b/pyim.el @@ -223,7 +223,7 @@ Tip: 用户也可以利用 `pyim-outcome-trigger-function-default' 函数 ;; ** Pyim 输入法注册 ;;;###autoload -(register-input-method "pyim" "UTF-8" #'pyim-activate pyim-title) +(register-input-method "pyim" "UTF-8" #'pyim-activate pyim-title "") ;; ** PYim 输入法启动功能 ;;;###autoload diff --git a/tests/Makefile b/tests/Makefile index 4f276e8925..4c7f77248e 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -2,10 +2,11 @@ SHELL = /bin/sh EMACS ?= emacs +.PHONY: test lint clean deps compile + clean: - @rm -rf pyim-tests-temp-* + @rm -rf "pyim-tests-temp-*" "../*.elc" "*.elc" -.PHONY: deps deps: @mkdir -p deps; @if [ ! -f deps/xr.el ]; then curl -L "https://git.savannah.gnu.org/cgit/emacs/elpa.git/plain/xr.el?h=externals/xr" > deps/xr.el; fi; @@ -14,8 +15,17 @@ deps: ## Download pyim-basedict V0.5.0 (commit: 7495c974ada99f9fed96d8e85d8b97dabce9532c) @if [ ! -f deps/pyim-basedict.pyim ]; then curl -L "https://git.savannah.gnu.org/cgit/emacs/elpa.git/plain/pyim-basedict.pyim?h=externals/pyim-basedict&id=7495c974ada99f9fed96d8e85d8b97dabce9532c" > deps/pyim-basedict.pyim; fi; @if [ ! -f deps/pyim-basedict.el ]; then curl -L "https://git.savannah.gnu.org/cgit/emacs/elpa.git/plain/pyim-basedict.el?h=externals/pyim-basedict&id=7495c974ada99f9fed96d8e85d8b97dabce9532c" > deps/pyim-basedict.el; fi; + @if [ ! -f deps/posframe.el ]; then curl -L "https://raw.githubusercontent.com/tumashu/posframe/master/posframe.el" > deps/posframe.el; fi; + @if [ ! -f deps/liberime.el ]; then curl -L "https://raw.githubusercontent.com/merrickluo/liberime/master/liberime.el" > deps/liberime.el; fi; + + +lint: deps + @$(EMACS) --batch --quick --directory .. --directory ./deps --load ./pyim-elint.el 2>&1 | grep -vE "pyim-cregexp.el:[0-9]+:Warning: Empty varlist in let|pyim-indicator.el:[0-9]+:Error: Call to undefined function: posframe-show" | grep -E "([Ee]rror|[Ww]arning):" && exit 1 || exit 0 + +compile: deps clean + @$(EMACS) --batch --quick --directory .. --directory ./deps --load ./pyim-byte-compile.el 2>&1 | grep -E "([Ee]rror|[Ww]arning):" && exit 1 || exit 0 -.PHONY: test -test: deps clean +# test: lint compile deps clean +test: deps clean compile @$(EMACS) --batch --quick --directory .. --directory ./deps --load ./pyim-tests.el - @rm -rf pyim-tests-temp-* + @rm -rf "pyim-tests-temp-*" diff --git a/tests/pyim-byte-compile.el b/tests/pyim-byte-compile.el new file mode 100644 index 0000000000..09506e9204 --- /dev/null +++ b/tests/pyim-byte-compile.el @@ -0,0 +1,49 @@ +;;; pyim-elint.el --- syntax check the code -*- lexical-binding: t -*- + +;; Copyright (C) 2022 Free Software Foundation, Inc. +;; +;; Author: Chen Bin <chenbin...@gmail.com> +;; URL: https://github.com/tumashu/pyim + +;; This file is NOT part of GNU Emacs. + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation; either version 3, or (at your option) +;; any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program; if not, see <https://www.gnu.org/licenses/>. + +;;; Commentary: +;; Syntax check the pyim code. It's used in Emacs cli. +;; + +;;; Code: + +(require 'find-lisp) + +(let ((files (find-lisp-find-files-internal + "../" + (lambda (file dir) + (and (not (file-directory-p (expand-file-name file dir))) + (string-match "\\.el$" file) + (not (string-match "\\.dir-locals.el" file)))) + (lambda (dir parent) + (not (or (string= dir ".") + (string= dir "..") + (string= dir ".git") + (string= dir ".svn") + (string= dir ".deps") + (string= dir "tests") + (file-symlink-p (expand-file-name dir parent)))))))) + (dolist (file files) + (byte-compile-file file))) + +(provide 'pyim-byte-compile) +;;; pyim-elint.el ends here diff --git a/tests/pyim-elint.el b/tests/pyim-elint.el new file mode 100644 index 0000000000..cbcdac2085 --- /dev/null +++ b/tests/pyim-elint.el @@ -0,0 +1,34 @@ +;;; pyim-elint.el --- syntax check the code -*- lexical-binding: t -*- + +;; Copyright (C) 2022 Free Software Foundation, Inc. +;; +;; Author: Chen Bin <chenbin...@gmail.com> +;; URL: https://github.com/tumashu/pyim + +;; This file is NOT part of GNU Emacs. + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation; either version 3, or (at your option) +;; any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program; if not, see <https://www.gnu.org/licenses/>. + +;;; Commentary: +;; Syntax check the pyim code. It's used in Emacs cli. +;; + +;;; Code: +(require 'elint) + +(let ((elint-directory-skip-re "\\(\\.dir-locals\\|ldefs-boot\\|loaddefs\\)\\.el\\'")) + (elint-directory "..")) + +(provide 'pyim-elint) +;;; pyim-elint.el ends here