From ac77a8833124b2dc0f5754b50efca7e38d33081a Mon Sep 17 00:00:00 2001 From: Yuanle Song <sylecn@gmail.com> Date: Thu, 10 Oct 2019 01:51:49 +0800 Subject: [PATCH] v1.2.3 added zero-pkg.el; more style fixes. - merge lexical-binding line with file intro line - allow capitalize zero in some docstring/error msg - add "make pkg" this will create tar for package.el --- Makefile | 6 ++++- operational | 55 +++++++++++++++++++++++++++++++++++++++++- zero-framework.el | 11 ++++++--- zero-panel.el | 5 ++-- zero-pinyin-service.el | 8 +++--- zero-pinyin.el | 8 +++--- zero-pkg.el | 31 ++++++++++++++++++++++++ zero-quickdial.el | 3 +-- zero-reload-all.el | 3 +-- zero-table.el | 4 +-- 10 files changed, 109 insertions(+), 25 deletions(-) create mode 100644 zero-pkg.el diff --git a/Makefile b/Makefile index 3d67ee1..8a344ef 100644 --- a/Makefile +++ b/Makefile @@ -4,4 +4,8 @@ compile: emacs -Q --batch -l zero-reload-all.el -f zero-rebuild -l zero-table.el -f ert-run-tests-batch zip: git archive -o zero-el-$(VERSION).zip --prefix=zero/ HEAD -.PHONY: zip compile +pkg: + echo "Creating tar for package.el distribution..." + git archive -o zero-$(VERSION).tar --prefix=zero/$(VERSION) HEAD + echo "Done" +.PHONY: compile zip pkg diff --git a/operational b/operational index 35813a9..080e52d 100644 --- a/operational +++ b/operational @@ -1,6 +1,6 @@ * COMMENT -*- mode: org -*- #+Date: 2019-10-08 -Time-stamp: <2019-10-08> +Time-stamp: <2019-10-10> #+STARTUP: content * notes :entry: ** 2019-04-01 zero-framework.el a Chinese IM framework in emacs; FSM :doc: @@ -80,6 +80,59 @@ cd ~/lisp/elisp/zero/ * later :entry: * current :entry: ** +** 2019-10-09 release zero-el on melpa +melpa/CONTRIBUTING.org at master · melpa/melpa · GitHub +https://github.com/melpa/melpa/blob/master/CONTRIBUTING.org + +Making your package ready for inclusion +https://github.com/melpa/melpa/blob/master/CONTRIBUTING.org#making-your-package-ready-for-inclusion + +Packaging Basics - GNU Emacs Lisp Reference Manual +https://www.gnu.org/software/emacs/manual/html_node/elisp/Packaging-Basics.html#Packaging-Basics + +name: zero +version: 1.2.2 +brief: a Chinese input method framework +long: zero is a Chinese input method framework for Emacs, implemented +as an Emacs minor mode. A zero-pinyin input method is included with zero +distribution. +dependencies: s + +progress: +Preparing a pull request to MELPA +https://github.com/melpa/melpa/blob/master/CONTRIBUTING.org#preparing-a-pull-request-to-melpa + +- problems + - should I create two pkg, one for zero-framework and one for zero-pinyin? + does melpa require two repo for this? + - minimum s version? + I only use s-contains-p s-join. + checked github + tag 1.2.0 already include these functions. + https://github.com/magnars/s.el/blob/1.2.0/s.el + - TODO Note that there is no way to control the order in which files are + byte-compiled. + - how to add autoload magic comments? + + https://www.gnu.org/software/emacs/manual/html_node/elisp/Autoload.html + + A magic autoload comment (often called an autoload cookie) consists of + ‘;;;###autoload’, on a line by itself, just before the real definition of + the function in its autoloadable source file. + + add this for some user commands. + zero-set-im + zero-set-default-im + zero-on + zero-toggle + - run package-lint + - Prefix function names with #’ (i.e., the special form function) instead of + just ’ (i.e., the special form quote) to tell the compiler this is a + function reference. E.g., (seq-filter #'evenp list). + + I don't think this is necessary in my code. + - + * done :entry: ** 2019-10-08 support full-width characters and symbols. 全角 半角 diff --git a/zero-framework.el b/zero-framework.el index 73d03c6..141f01d 100644 --- a/zero-framework.el +++ b/zero-framework.el @@ -1,5 +1,4 @@ -;;; -*- lexical-binding: t -*- -;;; zero-framework.el --- zero Chinese input method framework +;;; zero-framework.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. @@ -139,8 +138,8 @@ If item is not in lst, return nil." ;;===================== ;; zero-el version -(defvar zero-version nil "zero-el package version.") -(setq zero-version "1.2.2") +(defvar zero-version nil "Zero-el package version.") +(setq zero-version "1.2.3") ;; FSM state (defconst *zero-state-im-off* 'IM-OFF) @@ -774,6 +773,7 @@ LEVEL the level to set to." (zero-cycle-list zero-punctuation-levels zero-punctuation-level)) (message "punctuation level set to %s" zero-punctuation-level)) +;;;###autoload (defun zero-set-im (im-name) "Select zero input method for current buffer. @@ -835,12 +835,14 @@ if IM-NAME is nil, use default empty input method" (setq zero-preedit-start-func nil) (setq zero-preedit-end-func nil))) +;;;###autoload (defun zero-set-default-im (im-name) "Set given IM-NAME as default zero input method." (unless (symbolp im-name) (signal 'wrong-type-argument (list 'symbolp im-name))) (setq-default zero-im im-name)) +;;;###autoload (defun zero-on () "Turn on `zero-mode'." (interactive) @@ -857,6 +859,7 @@ if IM-NAME is nil, use default empty input method" (zero-reset) (zero-set-state *zero-state-im-off*)) +;;;###autoload (defun zero-toggle () "Toggle `zero-mode'." (interactive) diff --git a/zero-panel.el b/zero-panel.el index f4b3991..a0bb6bc 100644 --- a/zero-panel.el +++ b/zero-panel.el @@ -1,5 +1,4 @@ -;;; -*- lexical-binding: t -*- -;;; zero-panel --- provide emacs interface for zero-panel dbus service. +;;; zero-panel --- Provide emacs interface for zero-panel dbus service. -*- 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. @@ -31,7 +30,7 @@ EVENT and ERROR are error-handler arguments." (when (or (string-equal "com.emacsos.zero.Panel" (dbus-event-interface-name event)) (s-contains-p "com.emacsos.zero.Panel" (cadr error))) - (error "zero-panel dbus failed: %S" (cadr error)))) + (error "Zero-panel dbus failed: %S" (cadr error)))) (add-hook 'dbus-event-error-functions 'zero-panel-error-handler) diff --git a/zero-pinyin-service.el b/zero-pinyin-service.el index 8b1189e..caeba8b 100644 --- a/zero-pinyin-service.el +++ b/zero-pinyin-service.el @@ -1,5 +1,4 @@ -;;; -*- lexical-binding: t -*- -;;; zero-pinyin-service.el --- provide emacs interface for zero-pinyin-service dbus service. +;;; zero-pinyin-service.el --- Provide emacs interface for zero-pinyin-service dbus service. -*- 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. @@ -22,13 +21,14 @@ ;;================ (require 'dbus) +(require 's) (defun zero-pinyin-service-error-handler (event error) "Handle dbus errors." (when (or (string-equal "com.emacsos.zero.ZeroPinyinService1" (dbus-event-interface-name event)) (s-contains-p "com.emacsos.zero.ZeroPinyinService1" (cadr error))) - (error "zero-pinyin-service dbus failed: %S" (cadr error)))) + (error "`zero-pinyin-service' dbus failed: %S" (cadr error)))) (add-hook 'dbus-event-error-functions 'zero-pinyin-service-error-handler) @@ -92,7 +92,7 @@ GET-CANDIDATES-COMPLETE the async handler function." (:struct :int32 7 :int32 55))))) (defun zero-pinyin-service-commit-candidate-async (candidate candidate_pinyin_indices) - "Commit CANDIDATE asynchronously." + "Commit candidate asynchronously." ;; don't care about the result, so no callback. (zero-pinyin-service-async-call "CommitCandidate" nil diff --git a/zero-pinyin.el b/zero-pinyin.el index bbea2e3..f633c14 100644 --- a/zero-pinyin.el +++ b/zero-pinyin.el @@ -1,5 +1,4 @@ -;;; -*- lexical-binding: t -*- -;;; zero-pinyin.el --- a pinyin input method for zero-framework +;;; zero-pinyin.el --- A pinyin input method for zero-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. @@ -27,7 +26,6 @@ ;; dependencies ;;============== -(require 's) (require 'zero-framework) (require 'zero-pinyin-service) @@ -35,7 +33,7 @@ ;; basic data and emacs facility ;;=============================== -(defvar zero-pinyin-state nil "zero-pinyin internal state. could be nil or `*zero-pinyin-state-im-partial-commit*'.") +(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) (defvar zero-pinyin-used-preedit-str-lengths nil @@ -283,7 +281,7 @@ DIGIT 0 means delete 10th candidate." "Allow C-<digit> to DeleteCandidate in `*zero-state-im-preediting*' state." (interactive) (unless (eq zero-state *zero-state-im-preediting*) - (error "zero-digit-argument called in non preediting state")) + (error "`zero-digit-argument' called in non preediting state")) (if (memq 'control (event-modifiers last-command-event)) (let* ((char (if (integerp last-command-event) last-command-event diff --git a/zero-pkg.el b/zero-pkg.el new file mode 100644 index 0000000..dda4c6a --- /dev/null +++ b/zero-pkg.el @@ -0,0 +1,31 @@ +;;; 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.3 +;; Package-Version: 1.2.3 +;; URL: https://gitlab.emacsos.com/sylecn/zero-el + +;;; Commentary: + +;; defines zero package. + +;;; Code: + +(define-package "zero" "1.2.3" + "a Chinese input method framework" + '((s "1.2.0"))) + +(provide 'zero-pkg) + +;;; zero-pkg.el ends here diff --git a/zero-quickdial.el b/zero-quickdial.el index 9bacc89..52e7669 100644 --- a/zero-quickdial.el +++ b/zero-quickdial.el @@ -1,5 +1,4 @@ -;;; -*- lexical-binding: t -*- -;;; zero-quickdial --- quickdial input method written as an emacs minor mode. +;;; zero-quickdial --- quickdial input method written as an emacs minor mode. -*- 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. diff --git a/zero-reload-all.el b/zero-reload-all.el index 8e1465a..50f2988 100644 --- a/zero-reload-all.el +++ b/zero-reload-all.el @@ -1,5 +1,4 @@ -;;; -*- no-byte-compile: t; -*- -;;; zero-reload-all.el --- reload zero-el in correct order +;;; zero-reload-all.el --- reload zero-el in correct order -*- no-byte-compile: t; -*- ;; Licensed under the Apache License, Version 2.0 (the "License"); ;; you may not use this file except in compliance with the License. diff --git a/zero-table.el b/zero-table.el index 50ad31b..da94009 100644 --- a/zero-table.el +++ b/zero-table.el @@ -1,5 +1,4 @@ -;;; -*- no-byte-compile: t; -*- -;;; zero-table.el --- a demo table based input method based on zero-framework.el +;;; zero-table.el --- a demo table based input method based on zero-framework.el -*- no-byte-compile: t; 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. @@ -30,7 +29,6 @@ ;; dependencies ;;============== -(require 's) (require 'zero-framework) ;;=============================== -- GitLab