2015-08-01 14:58:51 +00:00
|
|
|
;;; packages.el --- Chinese Layer packages File for Spacemacs
|
2015-06-27 15:12:43 +00:00
|
|
|
;;
|
2018-01-04 07:00:25 +00:00
|
|
|
;; Copyright (c) 2012-2018 Sylvain Benner & Contributors
|
2015-06-27 15:12:43 +00:00
|
|
|
;;
|
|
|
|
;; Author: Sylvain Benner <sylvain.benner@gmail.com>
|
|
|
|
;; URL: https://github.com/syl20bnr/spacemacs
|
|
|
|
;;
|
|
|
|
;; This file is not part of GNU Emacs.
|
|
|
|
;;
|
|
|
|
;;; License: GPLv3
|
|
|
|
|
|
|
|
;; List of all packages to install and/or initialize. Built-in packages
|
|
|
|
;; which require an initialization must be listed explicitly in the list.
|
|
|
|
(setq chinese-packages
|
2015-11-17 00:23:02 +00:00
|
|
|
'(
|
2017-07-30 16:20:56 +00:00
|
|
|
(pyim :toggle (eq chinese-default-input-method 'pinyin))
|
2016-05-30 02:39:21 +00:00
|
|
|
(chinese-wbim :toggle (eq chinese-default-input-method 'wubi))
|
2016-07-06 10:19:53 +00:00
|
|
|
(fcitx :toggle chinese-enable-fcitx)
|
2015-11-17 00:23:02 +00:00
|
|
|
find-by-pinyin-dired
|
|
|
|
ace-pinyin
|
|
|
|
pangu-spacing
|
2016-05-30 02:39:21 +00:00
|
|
|
org
|
2016-06-02 01:33:40 +00:00
|
|
|
(youdao-dictionary :toggle chinese-enable-youdao-dict)
|
2018-08-12 21:57:51 +00:00
|
|
|
chinese-conv
|
2016-05-30 02:39:21 +00:00
|
|
|
))
|
2015-11-17 00:23:02 +00:00
|
|
|
|
|
|
|
(defun chinese/init-fcitx ()
|
|
|
|
(use-package fcitx
|
|
|
|
:init
|
|
|
|
(fcitx-evil-turn-on)))
|
|
|
|
|
2015-06-27 15:12:43 +00:00
|
|
|
(defun chinese/init-chinese-wbim ()
|
|
|
|
"Initialize chinese-wubi"
|
|
|
|
(use-package chinese-wbim
|
|
|
|
:if (eq 'wubi chinese-default-input-method)
|
|
|
|
:init
|
|
|
|
(progn
|
2015-07-05 04:34:27 +00:00
|
|
|
(autoload 'chinese-wbim-use-package "chinese-wubi"
|
|
|
|
"Another emacs input method")
|
2015-06-27 15:12:43 +00:00
|
|
|
;; Tooptip is not good enough, so disable it here.
|
|
|
|
(setq chinese-wbim-use-tooltip nil)
|
|
|
|
(register-input-method
|
|
|
|
"chinese-wubi" "euc-cn" 'chinese-wbim-use-package
|
|
|
|
"五笔" "汉字五笔输入法" "wb.txt")
|
|
|
|
(require 'chinese-wbim-extra)
|
|
|
|
(global-set-key ";" 'chinese-wbim-insert-ascii)
|
2015-07-05 04:34:27 +00:00
|
|
|
(setq default-input-method 'chinese-wubi))))
|
2015-06-27 15:12:43 +00:00
|
|
|
|
|
|
|
(defun chinese/init-youdao-dictionary ()
|
|
|
|
(use-package youdao-dictionary
|
2015-07-05 14:21:00 +00:00
|
|
|
:if chinese-enable-youdao-dict
|
|
|
|
:defer
|
2015-06-27 15:12:43 +00:00
|
|
|
:config
|
|
|
|
(progn
|
|
|
|
;; Enable Cache
|
2015-07-05 04:34:27 +00:00
|
|
|
(setq url-automatic-caching t
|
|
|
|
;; Set file path for saving search history
|
|
|
|
youdao-dictionary-search-history-file
|
|
|
|
(concat spacemacs-cache-directory ".youdao")
|
|
|
|
;; Enable Chinese word segmentation support
|
|
|
|
youdao-dictionary-use-chinese-word-segmentation t))))
|
2015-06-27 15:12:43 +00:00
|
|
|
|
2017-07-30 16:20:56 +00:00
|
|
|
(defun chinese/init-pyim ()
|
|
|
|
(use-package pyim
|
2015-06-27 15:12:43 +00:00
|
|
|
:if (eq 'pinyin chinese-default-input-method)
|
|
|
|
:init
|
|
|
|
(progn
|
2017-07-30 16:20:56 +00:00
|
|
|
(setq pyim-page-tooltip t
|
2017-03-10 13:22:26 +00:00
|
|
|
pyim-directory (expand-file-name "pyim/" spacemacs-cache-directory)
|
|
|
|
pyim-dcache-directory (expand-file-name "dcache/" pyim-directory)
|
2017-07-30 16:20:56 +00:00
|
|
|
default-input-method "pyim")
|
|
|
|
(evilified-state-evilify pyim-dm-mode pyim-dm-mode-map))))
|
2015-06-27 15:12:43 +00:00
|
|
|
|
|
|
|
(defun chinese/init-find-by-pinyin-dired ()
|
|
|
|
(use-package find-by-pinyin-dired
|
2018-03-04 04:37:53 +00:00
|
|
|
:defer t))
|
2015-06-27 15:12:43 +00:00
|
|
|
|
|
|
|
(defun chinese/init-ace-pinyin ()
|
|
|
|
(use-package ace-pinyin
|
2018-03-04 04:37:53 +00:00
|
|
|
:defer t
|
2015-06-27 15:12:43 +00:00
|
|
|
:init
|
|
|
|
(progn
|
2015-11-08 08:59:51 +00:00
|
|
|
(if chinese-enable-avy-pinyin
|
|
|
|
(setq ace-pinyin-use-avy t))
|
2015-06-27 15:12:43 +00:00
|
|
|
(ace-pinyin-global-mode t)
|
|
|
|
(spacemacs|hide-lighter ace-pinyin-mode))))
|
2015-08-01 07:16:52 +00:00
|
|
|
|
|
|
|
(defun chinese/init-pangu-spacing ()
|
|
|
|
(use-package pangu-spacing
|
2018-03-04 04:37:53 +00:00
|
|
|
:defer t
|
2015-08-01 07:16:52 +00:00
|
|
|
:init (progn (global-pangu-spacing-mode 1)
|
|
|
|
(spacemacs|hide-lighter pangu-spacing-mode)
|
|
|
|
;; Always insert `real' space in org-mode.
|
|
|
|
(add-hook 'org-mode-hook
|
|
|
|
'(lambda ()
|
|
|
|
(set (make-local-variable 'pangu-spacing-real-insert-separtor) t))))))
|
|
|
|
|
2018-08-12 21:57:51 +00:00
|
|
|
(defun chinese/init-chinese-conv ()
|
|
|
|
(use-package chinese-conv
|
|
|
|
:defer t))
|
|
|
|
|
2015-08-01 07:16:52 +00:00
|
|
|
(defun chinese/post-init-org ()
|
|
|
|
(defadvice org-html-paragraph (before org-html-paragraph-advice
|
|
|
|
(paragraph contents info) activate)
|
|
|
|
"Join consecutive Chinese lines into a single long line without
|
|
|
|
unwanted space when exporting org-mode to html."
|
|
|
|
(let* ((origin-contents (ad-get-arg 1))
|
|
|
|
(fix-regexp "[[:multibyte:]]")
|
|
|
|
(fixed-contents
|
|
|
|
(replace-regexp-in-string
|
|
|
|
(concat
|
|
|
|
"\\(" fix-regexp "\\) *\n *\\(" fix-regexp "\\)") "\\1\\2" origin-contents)))
|
|
|
|
(ad-set-arg 1 fixed-contents))))
|