Skip to content
Commits on Source (1)
  • Yuanle Song's avatar
    v2.0.5 switch to multi-file package. · c3ab74f0
    Yuanle Song authored
    - dropped build scripts and files for single-file distribution.
    - updated git pre-commit hook to run "make check" instead of "make dist"
    - renamed zero-input-framework to zero-input. This is to conform "there
      should be a library with the same name as package name" rule.
    - rename .el.in to .el.tpl.
      melpa build process will do something on .el.in, which I do not expect.
    - "make tar" is a little messy because emacs doesn't support git archive
      generated tar file.
    - add zero-input-pkg.el in git, melpa build hangs when this file is not
      present.
    c3ab74f0
*-test.el export-ignore
*-debug.el export-ignore
git-hooks/ export-ignore
zero-input-reload-all.el export-ignore
.gitattributes export-ignore
.gitignore export-ignore
*.zip
*.elc
*.tar
*.tmp
build/
VERSION := $(shell grep 'setq zero-input-version' zero-input-framework.el | cut -d'"' -f2)
VERSION := $(shell grep 'setq zero-input-version' zero-input.el | cut -d'"' -f2)
TAR_BUILD_DIR := build
default: dist
default: check
#===============
# multiple file
#===============
check:
emacs -Q --batch -l zero-input-reload-all.el -f zero-input-rebuild -l zero-input-table.el -l zero-input-table-test.el -f ert-run-tests-batch
sed "s/PKG_VERSION/$(VERSION)/g" zero-input-pkg.el.tpl > zero-input-pkg.tmp
if ! diff -q zero-input-pkg.tmp zero-input-pkg.el; then mv zero-input-pkg.tmp zero-input-pkg.el; fi
tar: check
git archive -o zero-input-$(VERSION).tar --prefix=zero-input-$(VERSION)/ HEAD
rm -rf $(TAR_BUILD_DIR)/ && mkdir -p $(TAR_BUILD_DIR)/
tar xf zero-input-$(VERSION).tar -C $(TAR_BUILD_DIR)/
sed "s/PKG_VERSION/$(VERSION)/g" zero-input-pkg.el.tpl > $(TAR_BUILD_DIR)/zero-input-$(VERSION)/zero-input-pkg.el
rm zero-input-$(VERSION).tar
tar cf zero-input-$(VERSION).tar -C $(TAR_BUILD_DIR)/ zero-input-$(VERSION)
tar -tf zero-input-$(VERSION).tar
zip:
git archive -o zero-input-el-$(VERSION).zip --prefix=zero-input/ HEAD
#==========================
# single file distribution
#==========================
dist: dist-check
build:
if [ ! -x ~/.local/bin/pytest ]; then python3 -m pip install --user pytest; fi
~/.local/bin/pytest build.py
./build.py
sed -i "s/PKG_VERSION/$(VERSION)/g" zero-input.el
dist-check: build
@echo "testing byte-compile is clean..."
emacs -Q --batch -l ~/.emacs.d/elpa/s-1.11.0/s.el --eval='(byte-compile-file "zero-input.el")'
@echo "running unit tests..."
emacs -Q --batch -l ~/.emacs.d/elpa/s-1.11.0/s.el -l zero-input.el -l zero-input-panel-test.el -l zero-input-pinyin-service-test.el -l zero-input-framework-test.el -l zero-input-pinyin-test.el -l zero-input-table.el -l zero-input-table-test.el -f ert-run-tests-batch
#====================
# other make targets
#====================
......@@ -29,4 +26,4 @@ install-git-hooks:
rsync -air git-hooks/ .git/hooks/
version:
@echo $(VERSION)
.PHONY: default check zip dist build dist-check install-git-hooks version
.PHONY: default check tar zip dist build dist-check install-git-hooks version
* COMMENT -*- mode: org -*-
#+Date: 2019-09-01
Time-stamp: <2019-10-28>
Time-stamp: <2019-11-05>
* zero-el
* zero-input
zero-el provides zero-input-pinyin, an Emacs pinyin input method for Chinese
and zero-input-framework, which is an emacs Chinese input method framework.
zero-input provides zero-input-pinyin, an Emacs pinyin input method for
Chinese and zero-input, which is an emacs Chinese input method framework.
* File list
- zero-input.el
It's a generated file for one-file package distribution. Not used for
development.
- zero-input-framework.el
zero framework source code. This provides the framework and user interface
for zero-el.
for zero-input.
- zero-input-panel.el
......@@ -36,18 +31,18 @@ and zero-input-framework, which is an emacs Chinese input method framework.
- zero-input-reload-all.el
zero-el development utility.
development utility.
- zero-input-table.el
serves as an example of how to use zero framework to create new input
methods.
* introduce to zero-el
* introduce to zero-input
https://blog.emacsos.com/zero-el.html
* License
zero-el is under Apache License 2.0
zero-input is under Apache License 2.0
zero-input--ibus-compute-pixel-position function in zero-input-framework.el is
under GPLv3. see NOTICE file.
#!/usr/bin/env python3
# coding=utf-8
"""
build zero-input.el from zero-input.el.in and other el files
"""
import logging
logger = logging.getLogger(__name__)
def placeholder_for_file(fn):
"""return placeholder that should be used for filename.
"""
return "INCLUDE_" + fn.replace('-', '_').replace('.', '_').upper()
def test_placeholder_for_file():
assert placeholder_for_file("zero-input-panel.el") == (
"INCLUDE_ZERO_INPUT_PANEL_EL")
assert placeholder_for_file("zero-input-pinyin-service.el") == (
"INCLUDE_ZERO_INPUT_PINYIN_SERVICE_EL")
def get_el_file_body(fn):
rows = []
append = False
with open(fn) as f:
for line in f:
if append:
if '(require ' in line:
logger.debug("skipping require call: %s", line)
continue
rows.append(line)
if line.startswith('(provide'):
break
else:
if line.startswith(";;; Code:"):
rows.append(";; body of %s\n" % (fn,))
append = True
return "".join(rows)
def expand_placeholder_for_files(old_content, filenames):
"""replace INCLUDE_FOO_BAR_EL by body of foo-bar.el.
"""
result = old_content
for fn in filenames:
result = result.replace(placeholder_for_file(fn),
get_el_file_body(fn))
return result
def main():
logging.basicConfig(
format='%(asctime)s [%(module)s] %(levelname)-8s %(message)s',
level=logging.INFO)
with open("zero-input.el.in") as tpl:
content = tpl.read()
expanded_content = expand_placeholder_for_files(content, [
"zero-input-panel.el",
"zero-input-framework.el",
"zero-input-table.el",
"zero-input-pinyin-service.el",
"zero-input-pinyin.el",
])
with open('zero-input.el', 'w') as out:
out.write(expanded_content)
if __name__ == '__main__':
main()
#!/bin/sh
set -e
if git branch |grep '^\* master'; then
make dist-check
git add zero-input.el
fi
make check
git add zero-input-pkg.el
This diff is collapsed.
;;; zero-input-pinyin.el --- A pinyin input method for zero-input-framework -*- lexical-binding: t -*-
;;; zero-input-pinyin.el --- A pinyin input method for zero-input framework -*- lexical-binding: t -*-
;; Licensed under the Apache License, Version 2.0 (the "License");
;; you may not use this file except in compliance with the License.
......@@ -29,7 +29,7 @@
;; dependencies
;;==============
(require 'zero-input-framework)
(require 'zero-input)
(require 'zero-input-pinyin-service)
;;===============================
......@@ -220,7 +220,8 @@ Otherwise, just return nil."
(defun zero-input-pinyin-page-down ()
"Handle page down for zero-input-pinyin.
This is different from zero-input-framework because I need to support partial commit"
This is different from zero-input framework because I need to
support partial commit"
(let ((len (length zero-input-candidates))
(new-fetch-size (* zero-input-candidates-per-page (+ 2 zero-input-current-page))))
(if (and (< len new-fetch-size)
......
;;; zero-input-pkg.el --- zero-input package file -*- lexical-binding: t -*-
;; Licensed under the Apache License, Version 2.0 (the "License");
;; you may not use this file except in compliance with the License.
;; You may obtain a copy of the License at
;;
;; http://www.apache.org/licenses/LICENSE-2.0
;;
;; Unless required by applicable law or agreed to in writing, software
;; distributed under the License is distributed on an "AS IS" BASIS,
;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
;; See the License for the specific language governing permissions and
;; limitations under the License.
;; Authors: Yuanle Song <sylecn@gmail.com>
;; Maintainer: Yuanle Song <sylecn@gmail.com>
;; URL: https://gitlab.emacsos.com/sylecn/zero-el
;;; Commentary:
;; zero-input package file. For more information, see
;; Info: (elisp) Multi-file Packages
;;; Code:
(define-package "zero-input" "2.0.5"
"A Chinese input method framework with built-in pinyin input method"
'((emacs "24.3") (s "1.2.0")))
;;; zero-input-pkg.el ends here
;;; zero-input-pkg.el --- zero-input package file -*- lexical-binding: t -*-
;; Licensed under the Apache License, Version 2.0 (the "License");
;; you may not use this file except in compliance with the License.
;; You may obtain a copy of the License at
;;
;; http://www.apache.org/licenses/LICENSE-2.0
;;
;; Unless required by applicable law or agreed to in writing, software
;; distributed under the License is distributed on an "AS IS" BASIS,
;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
;; See the License for the specific language governing permissions and
;; limitations under the License.
;; Authors: Yuanle Song <sylecn@gmail.com>
;; Maintainer: Yuanle Song <sylecn@gmail.com>
;; URL: https://gitlab.emacsos.com/sylecn/zero-el
;;; Commentary:
;; zero-input package file. For more information, see
;; Info: (elisp) Multi-file Packages
;;; Code:
(define-package "zero-input" "PKG_VERSION"
"A Chinese input method framework with built-in pinyin input method"
'((emacs "24.3") (s "1.2.0")))
;;; zero-input-pkg.el ends here
......@@ -27,8 +27,8 @@ SOURCE-DIR where to find the zero source dir."
(dolist (f '("zero-input-quickdial.el"
"zero-input-panel.el"
"zero-input-panel-test.el"
"zero-input-framework.el"
"zero-input-framework-test.el"
"zero-input.el"
"zero-input-test.el"
"zero-input-pinyin-service.el"
"zero-input-pinyin-service-test.el"
"zero-input-pinyin.el"
......@@ -43,8 +43,8 @@ SOURCE-DIR where to find the zero source dir."
(dolist (f '("zero-input-quickdial.elc"
"zero-input-panel.elc"
"zero-input-panel-test.elc"
"zero-input-framework.elc"
"zero-input-framework-test.elc"
"zero-input.elc"
"zero-input-test.elc"
"zero-input-pinyin-service.elc"
"zero-input-pinyin-service-test.elc"
"zero-input-pinyin.elc"
......
......@@ -29,7 +29,7 @@
;; dependencies
;;==============
(require 'zero-input-framework)
(require 'zero-input)
;;===============================
;; basic data and emacs facility
......
;;; zero-input-framework-test.el --- tests for zero-input-framework.el -*- lexical-binding: t -*-
;;; zero-input-test.el --- tests for zero-input.el -*- lexical-binding: t -*-
;; Licensed under the Apache License, Version 2.0 (the "License");
;; you may not use this file except in compliance with the License.
......@@ -14,11 +14,11 @@
;;; Commentary:
;; tests for zero-input-framework.el
;; tests for zero-input.el
;;; Code:
(require 'zero-input-framework)
(require 'zero-input)
(require 'ert)
(ert-deftest zero-input-cycle-list ()
......@@ -39,6 +39,6 @@
(should (string-equal "hehe" (zero-input-convert-str-to-full-width "hehe")))
(should (string-equal "(A)" (zero-input-convert-str-to-full-width "(A)"))))
(provide 'zero-input-framework-test)
(provide 'zero-input-test)
;;; zero-input-framework-test.el ends here
;;; zero-input-test.el ends here
This diff is collapsed.
;;; zero-input.el --- Zero Chinese input method framework -*- lexical-binding: t -*-
;; Licensed under the Apache License, Version 2.0 (the "License");
;; you may not use this file except in compliance with the License.
;; You may obtain a copy of the License at
;;
;; http://www.apache.org/licenses/LICENSE-2.0
;;
;; Unless required by applicable law or agreed to in writing, software
;; distributed under the License is distributed on an "AS IS" BASIS,
;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
;; See the License for the specific language governing permissions and
;; limitations under the License.
;; Version: PKG_VERSION
;; URL: https://gitlab.emacsos.com/sylecn/zero-el
;; Package-Requires: ((emacs "24.3") (s "1.2.0"))
;;; Commentary:
;; zero-input.el is auto-generated from multiple other files. see
;; zero-input.el.in and build.py for details. It's created because
;; package-lint doesn't support multi-file package yet (issue #111).
;;
;; zero-input is a Chinese input method framework for Emacs, implemented as an
;; Emacs minor mode.
;;
;; zero-input-pinyin is bundled with zero, to use pinyin input method, add to
;; ~/.emacs file:
;;
;; (require 'zero-input)
;; (zero-input-set-default-im 'pinyin)
;; ;; Now you may bind a key to zero-input-mode to make it easy to
;; ;; switch on/off the input method.
;; (global-set-key (kbd "<f5>") 'zero-input-mode)
;;
;; zero-input supports Chinese punctuation mapping. There are three modes,
;; none, basic, and full. The default is basic mode, which only map most
;; essential punctuations. You can cycle zero-punctuation-level in current
;; buffer by C-c , , You can change default Chinese punctuation level:
;;
;; (setq-default zero-input-punctuation-level
;; zero-input-punctuation-level-full)
;;
;; zero-input supports full-width mode. You can toggle full-width mode in
;; current buffer by C-c , . You can enable full-width mode by default:
;;
;; (setq-default zero-input-full-width-p t)
;;
;;; Code:
(require 'dbus)
(eval-when-compile (require 'cl-lib))
(require 's)
INCLUDE_ZERO_INPUT_PANEL_EL
INCLUDE_ZERO_INPUT_FRAMEWORK_EL
INCLUDE_ZERO_INPUT_TABLE_EL
INCLUDE_ZERO_INPUT_PINYIN_SERVICE_EL
INCLUDE_ZERO_INPUT_PINYIN_EL
(provide 'zero-input)
;;; zero-input.el ends here