Commit 72196558 authored by Yuanle Song's avatar Yuanle Song
Browse files

v1.2.6 use a single file distribution for melpa.

- renamed zero.el back to zero-framework.el
- to build a dist, just run "make".
  the zero.el template is in zero.el.in
- zero.el is built and added to git repo in git pre-commit hook. it will
  be kept in master branch.
- fixed a few package-lint style warning.
parent 66e0dbb5
VERSION := $(shell grep 'setq zero-version' zero.el | cut -d'"' -f2)
VERSION := $(shell grep 'setq zero-version' zero-framework.el | cut -d'"' -f2)
default: compile
pkg-el:
sed "s/PKG_VERSION/$(VERSION)/g" zero-pkg.el.tpl > zero-pkg.el
compile:
default: dist
#===============
# multiple file
#===============
check:
emacs -Q --batch -l zero-reload-all.el -f zero-rebuild -l zero-table.el -l zero-table-test.el -f ert-run-tests-batch
zip: pkg-el
zip:
git archive -o zero-el-$(VERSION).zip --prefix=zero/ HEAD
pkg: pkg-el
# Note: install from tar is not working. install from dir does work.
@echo "Creating tar for use with M-x package-install-file"
git archive -o zero-$(VERSION).tar --prefix=zero-$(VERSION)/ HEAD
@echo "Done"
#==========================
# 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.el
dist-check: build
emacs -Q --batch -l ~/.emacs.d/elpa/s-1.11.0/s.el -l zero.el -l zero-panel-test.el -l zero-pinyin-service-test.el -l zero-framework-test.el -l zero-pinyin-test.el -l zero-table.el -l zero-table-test.el -f ert-run-tests-batch
#====================
# other make targets
#====================
install-git-hooks:
rsync -air git-hooks/ .git/hooks/
version:
@echo $(VERSION)
.PHONY: default pkg-el compile zip pkg install-git-hooks version
.PHONY: default check zip dist build dist-check install-git-hooks version
* COMMENT -*- mode: org -*-
#+Date: 2019-09-01
Time-stamp: <2019-10-11>
Time-stamp: <2019-10-16>
* zero-el
zero-el provides zero-pinyin, an Emacs pinyin input method for Chinese and
zero library, which is an emacs Chinese input method framework.
zero-framework, which is an emacs Chinese input method framework.
* File list
- zero.el
- zero-framework.el
zero framework source code. This provides the framework and user interface
for zero-el.
......@@ -44,5 +44,5 @@ https://blog.emacsos.com/zero-el.html
* License
zero-el is under Apache License 2.0
ibus-compute-pixel-position function in zero.el is under GPLv3.
see NOTICE file.
zero--ibus-compute-pixel-position function in zero-framework.el is under
GPLv3. see NOTICE file.
#!/usr/bin/env python3
# coding=utf-8
"""
build zero.el from zero.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-panel.el") == "INCLUDE_ZERO_PANEL_EL"
assert placeholder_for_file("zero-pinyin-service.el") == (
"INCLUDE_ZERO_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.el.in") as tpl:
content = tpl.read()
expanded_content = expand_placeholder_for_files(content, [
"zero-panel.el",
"zero-framework.el",
"zero-table.el",
"zero-pinyin-service.el",
"zero-pinyin.el",
])
with open('zero.el', 'w') as out:
out.write(expanded_content)
if __name__ == '__main__':
main()
#!/bin/sh
set -e
make pkg-el compile
git add zero-pkg.el
make dist-check
git add zero.el
* COMMENT -*- mode: org -*-
#+Date: 2019-10-08
Time-stamp: <2019-10-11>
Time-stamp: <2019-10-16>
#+STARTUP: content
* notes :entry:
** 2019-04-01 zero.el a Chinese IM framework in emacs; FSM :doc:
......@@ -83,6 +83,65 @@ cd ~/lisp/elisp/zero/
* later :entry:
* current :entry:
**
** 2019-10-15 make package-lint happy on all el files.
- package-lint doesn't support multi-file package.
Need to add headers to make it happy.
Because it doesn't have concept on multi-file package, it insists all
functions in file start with file name prefix. I can't have zero-* utility
function in zero-panel.el
- M-x package-lint-current-buffer fail on zero.el file
this line:
(eval-when-compile (require 'cl-macs))
M-x package-lint-current-buffer fails on a fresh .el file with just that
line.
#+BEGIN_SRC sh
Debugger entered--Lisp error: (wrong-type-argument integer-or-marker-p nil)
package-lint--map-symbol-match("(\\s-*?require\\s-*?'cl-\\(?:macs\\|seq\\)\\_>" #f(compiled-function (_) #<bytecode 0x15e4cd9>))
package-lint--check-no-use-of-cl-lib-sublibraries()
package-lint--check-all()
package-lint-buffer()
package-lint-current-buffer()
funcall-interactively(package-lint-current-buffer)
call-interactively(package-lint-current-buffer record nil)
command-execute(package-lint-current-buffer record)
execute-extended-command(nil "package-lint-current-buffer" nil)
funcall-interactively(execute-extended-command nil "package-lint-current-buffer" nil)
call-interactively(execute-extended-command nil nil)
command-execute(execute-extended-command)
#+END_SRC
package-lint--check-no-use-of-cl-lib-sublibraries
'warning
"This file is not in the `cl-lib' ELPA compatibility package: require `cl-lib' instead."
says you should use cl-lib instead. may as well try that.
yes. that works.
- create a single file for distribution.
package-lint doesn't support multiple file pkg yet.
- create a single zero.el file for distribution.
rename current zero.el to zero-framework.el
create zero.el.in
- make build
should generate zero.el and run checks on it.
- insert content to zero.el.in
;;; Code:
;;; .*\.el ends here
- now package-lint should be fine.
- I should I put zero.el in a branch or a separate git repo?
separate git repo is better.
how to auto build and commit on source repo push?
use gocd CI, I can trigger a build. just run git add and git push there?
if run in the same repo, two branch is required.
- maybe just add zero.el in master branch and commit it anyway.
-
* done :entry:
** 2019-10-11 move tests to separated files.
otherwise (require 'zero-pinyin) will fail because (require 'ert) is not in
......
;;; zero-test.el --- tests for zero.el -*- lexical-binding: t -*-
;;; zero-framework-test.el --- tests for zero-framework.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-framework.el
;;; Code:
(require 'zero)
(require 'zero-framework)
(require 'ert)
(ert-deftest zero-cycle-list ()
......@@ -39,6 +39,6 @@
(should (string-equal "hehe" (zero-convert-str-to-full-width "hehe")))
(should (string-equal "(A)" (zero-convert-str-to-full-width "(A)"))))
(provide 'zero-test)
(provide 'zero-framework-test)
;;; zero-test.el ends here
;;; zero-framework-test.el ends here
This diff is collapsed.
......@@ -14,6 +14,8 @@
;;; Commentary:
;; use dbus to communicate with zero-panel service.
;;; Code:
;;================
......
......@@ -29,7 +29,7 @@
;; dependencies
;;==============
(require 'zero)
(require 'zero-framework)
(require 'zero-pinyin-service)
;;===============================
......@@ -37,7 +37,7 @@
;;===============================
(defvar zero-pinyin-state nil "Zero-pinyin internal state. could be nil or `*zero-pinyin-state-im-partial-commit*'.")
(defconst *zero-pinyin-state-im-partial-commit* 'IM-PARTIAL-COMMIT)
(defconst zero-pinyin--state-im-partial-commit 'IM-PARTIAL-COMMIT)
(defvar zero-pinyin-used-preedit-str-lengths nil
"Accompany `zero-candidates', marks how many preedit-str chars are used for each candidate.")
......@@ -143,26 +143,26 @@ COMPLETE-FUNC the callback function when async call completes. it's called with
(if (= used-len (length zero-preedit-str))
(progn
(zero-debug "commit in full\n")
(zero-set-state *zero-state-im-waiting-input*)
(zero-set-state zero--state-im-waiting-input)
(zero-commit-text candidate)
(zero-pinyin-service-commit-candidate-async
candidate
(nth n-prime zero-pinyin-candidates-pinyin-indices))
t)
(zero-debug "partial commit, in partial commit mode now.\n")
(setq zero-pinyin-state *zero-pinyin-state-im-partial-commit*)
(setq zero-pinyin-state zero-pinyin--state-im-partial-commit)
(setq zero-pinyin-pending-str candidate)
(setq zero-pinyin-pending-preedit-str (substring zero-preedit-str used-len))
(setq zero-pinyin-pending-pinyin-indices
(nth n-prime zero-pinyin-candidates-pinyin-indices))
(zero-pinyin-pending-preedit-str-changed)
t))
((eq zero-pinyin-state *zero-pinyin-state-im-partial-commit*)
((eq zero-pinyin-state zero-pinyin--state-im-partial-commit)
(if (= used-len (length zero-pinyin-pending-preedit-str))
(progn
(zero-debug "finishes partial commit\n")
(setq zero-pinyin-state nil)
(zero-set-state *zero-state-im-waiting-input*)
(zero-set-state zero--state-im-waiting-input)
(zero-commit-text (concat zero-pinyin-pending-str candidate))
(zero-pinyin-service-commit-candidate-async
(concat zero-pinyin-pending-str candidate)
......@@ -196,13 +196,13 @@ Otherwise, just return nil."
(cond
((null zero-pinyin-state)
(when (= used-len (length zero-preedit-str))
(zero-set-state *zero-state-im-waiting-input*)
(zero-set-state zero--state-im-waiting-input)
(zero-commit-text candidate)
t))
((eq zero-pinyin-state *zero-pinyin-state-im-partial-commit*)
((eq zero-pinyin-state zero-pinyin--state-im-partial-commit)
(when (= used-len (length zero-pinyin-pending-preedit-str))
(setq zero-pinyin-state nil)
(zero-set-state *zero-state-im-waiting-input*)
(zero-set-state zero--state-im-waiting-input)
(zero-commit-text (concat zero-pinyin-pending-str candidate))
t))
(t (error "Unexpected zero-pinyin-state: %s" zero-pinyin-state))))))
......@@ -215,7 +215,7 @@ This is different from zero-framework because I need to support partial commit"
(new-fetch-size (* zero-candidates-per-page (+ 2 zero-current-page))))
(if (and (< len new-fetch-size)
(< zero-fetch-size new-fetch-size))
(let ((preedit-str (if (eq zero-pinyin-state *zero-pinyin-state-im-partial-commit*) zero-pinyin-pending-preedit-str zero-preedit-str)))
(let ((preedit-str (if (eq zero-pinyin-state zero-pinyin--state-im-partial-commit) zero-pinyin-pending-preedit-str zero-preedit-str)))
(zero-pinyin-build-candidates-async
preedit-str
new-fetch-size
......@@ -247,14 +247,14 @@ CH the character user typed."
(t (let ((str (zero-convert-punctuation ch)))
(if str
(when (zero-pinyin-commit-first-candidate-in-full)
(zero-set-state *zero-state-im-waiting-input*)
(zero-set-state zero--state-im-waiting-input)
(insert str))
(setq zero-pinyin-state nil)
(zero-append-char-to-preedit-str ch))))))
(defun zero-pinyin-get-preedit-str-for-panel ()
"Return the preedit string that should show in panel."
(if (eq zero-pinyin-state *zero-pinyin-state-im-partial-commit*)
(if (eq zero-pinyin-state zero-pinyin--state-im-partial-commit)
(concat zero-pinyin-pending-str zero-pinyin-pending-preedit-str)
zero-preedit-str))
......@@ -265,7 +265,7 @@ CH the character user typed."
(defun zero-pinyin-backspace ()
"Handle backspace key in `*zero-state-im-preediting*' state."
(if (eq zero-pinyin-state *zero-pinyin-state-im-partial-commit*)
(if (eq zero-pinyin-state zero-pinyin--state-im-partial-commit)
(zero-pinyin-preedit-str-changed)
(zero-backspace-default)))
......@@ -286,7 +286,7 @@ DIGIT 0 means delete 10th candidate."
(defun zero-digit-argument ()
"Allow C-<digit> to DeleteCandidate in `*zero-state-im-preediting*' state."
(interactive)
(unless (eq zero-state *zero-state-im-preediting*)
(unless (eq zero-state zero--state-im-preediting)
(error "`zero-digit-argument' called in non preediting state"))
(if (memq 'control (event-modifiers last-command-event))
(let* ((char (if (integerp last-command-event)
......
;;; zero-pkg.el --- Zero 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.
;; Version: 1.2.5
;; URL: https://gitlab.emacsos.com/sylecn/zero-el
;; Package-Version: 1.2.5
;; Package-Requires: ((emacs "24") (s "1.2.0"))
;;; Commentary:
;; defines zero package.
;;; Code:
(define-package "zero" "1.2.5"
"a Chinese input method framework"
'((emacs "24")
(s "1.2.0")))
(provide 'zero-pkg)
;;; zero-pkg.el ends here
......@@ -27,8 +27,8 @@ SOURCE-DIR where to find the zero source dir."
(dolist (f '("zero-quickdial.el"
"zero-panel.el"
"zero-panel-test.el"
"zero.el"
"zero-test.el"
"zero-framework.el"
"zero-framework-test.el"
"zero-pinyin-service.el"
"zero-pinyin-service-test.el"
"zero-pinyin.el"
......@@ -43,8 +43,8 @@ SOURCE-DIR where to find the zero source dir."
(dolist (f '("zero-quickdial.elc"
"zero-panel.elc"
"zero-panel-test.elc"
"zero.elc"
"zero-test.elc"
"zero-framework.elc"
"zero-framework-test.elc"
"zero-pinyin-service.elc"
"zero-pinyin-service-test.elc"
"zero-pinyin.elc"
......
......@@ -29,7 +29,7 @@
;; dependencies
;;==============
(require 'zero)
(require 'zero-framework)
;;===============================
;; basic data and emacs facility
......
This diff is collapsed.
;;; zero-pkg.el --- Zero package file -*- lexical-binding: t -*-
;;; zero.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.
......@@ -15,19 +15,51 @@
;; Version: PKG_VERSION
;; URL: https://gitlab.emacsos.com/sylecn/zero-el
;; Package-Version: PKG_VERSION
;; Package-Requires: ((emacs "24") (s "1.2.0"))
;; Package-Requires: ((emacs "24.3") (s "1.2.0"))
;;; Commentary:
;; defines zero package.
;; zero.el is auto-generated from multiple other files. see zero.el.in and
;; build.py for details. It's created because package-lint doesn't support
;; multi-file package yet (issue #111).
;;
;; zero is a Chinese input method framework for Emacs, implemented
;; as an Emacs minor mode.
;;
;; zero-pinyin is bundled with zero, to use pinyin input method, add to
;; ~/.emacs file:
;;
;; (require 'zero-pinyin)
;; (zero-set-default-im 'pinyin)
;; ;; Now you may bind a key to zero-toggle to make it easy to
;; ;; switch on/off the input method.
;; (global-set-key (kbd "<f5>") 'zero-toggle)
;;
;; zero 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-punctuation-level *zero-punctuation-level-full*)
;;
;; zero 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-full-width-mode t)
;;
;;; Code:
(define-package "zero" "PKG_VERSION"
"a Chinese input method framework"
'((emacs "24")
(s "1.2.0")))
(require 'dbus)
(eval-when-compile (require 'cl-lib))
(require 's)
INCLUDE_ZERO_PANEL_EL
INCLUDE_ZERO_FRAMEWORK_EL
INCLUDE_ZERO_TABLE_EL
INCLUDE_ZERO_PINYIN_SERVICE_EL
INCLUDE_ZERO_PINYIN_EL
(provide 'zero-pkg)
(provide 'zero)
;;; zero-pkg.el ends here
;;; zero.el ends here
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment