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

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
parent a36514d8
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -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
+54 −1
Original line number Diff line number Diff line
* 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.
全角 半角
+7 −4
Original line number Diff line number Diff line
;;; -*- 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)
+2 −3
Original line number Diff line number Diff line
;;; -*- 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)

+4 −4
Original line number Diff line number Diff line
;;; -*- 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
Loading