2015-12-02 14:23:39 +00:00
#+TITLE : Chinese layer
2015-06-27 15:12:43 +00:00
2019-05-02 21:49:30 +00:00
#+TAGS : i18n|layer
2018-09-19 03:54:47 +00:00
[[file:img/China.png ]] [[file:img/Chinese.png ]]
2015-06-27 15:12:43 +00:00
2019-05-07 20:05:06 +00:00
* Table of Contents :TOC_5_gh:noexport:
2017-05-22 14:16:12 +00:00
- [[#description ][Description ]]
2018-01-19 15:27:23 +00:00
- [[#features ][Features: ]]
2017-05-22 14:16:12 +00:00
- [[#install ][Install ]]
- [[#layer ][Layer ]]
- [[#configuration ][Configuration ]]
- [[#configure-the-default-input-method配置默认中文输入法 ][Configure the Default Input Method(配置默认中文输入法) ]]
- [[#configure-the-chinese-pyim-input-method配置中文拼音输入法 ][Configure the =Chinese-pyim= Input Method(配置中文拼音输入法) ]]
2018-08-12 21:57:51 +00:00
- [[#configure-chinese-conv-配置简繁转换 ][Configure =chinese-conv= (配置简繁转换) ]]
2017-05-22 14:16:12 +00:00
- [[#enable-fcitx ][Enable fcitx ]]
- [[#requirement ][Requirement ]]
2019-05-07 20:05:06 +00:00
- [[#linux ][Linux ]]
- [[#mac-os-x ][Mac OS X ]]
- [[#windows ][Windows ]]
2017-05-22 14:16:12 +00:00
- [[#enable-youdao有道-dictionary激活有道字典 ][Enable YouDao(有道) Dictionary(激活有道字典) ]]
- [[#set-monospaced-font-size设置等宽字体 ][Set monospaced font size(设置等宽字体) ]]
- [[#enabledisable-ace-pinyin-in-avy-goto-char ][Enable/Disable ace-pinyin in =avy-goto-char= ]]
2018-12-05 03:03:03 +00:00
- [[#key-bindings ][Key bindings ]]
2017-05-22 14:16:12 +00:00
- [[#youdao-dictionary ][Youdao Dictionary ]]
- [[#find-by-pinyin-dired ][Find-by-pinyin-dired ]]
2015-06-27 15:12:43 +00:00
* Description
2018-01-19 15:27:23 +00:00
This layer adds support for traditional Chinese script to Spacemacs.
** Features:
- Support for the [[https://en.wikipedia.org/wiki/Pinyin ][Pinyin(拼音) ]] input method via [[https://github.com/tumashu/chinese-pyim ][chinese-pyim ]].
- Support for the [[https://en.wikipedia.org/wiki/Wubi_method ][Wubi(五笔) ]] input method via [[https://github.com/andyque/chinese-wbim ][chinese-wbim ]].
- Integration of the native input method framework [[https://en.wikipedia.org/wiki/Fcitx ][fcitx ]] via [[https://github.com/cute-jumper/fcitx.el ][cute-jumper/fcitx.el ]].
- Integration of the [[https://en.wikipedia.org/wiki/Youdao ][Youdao(有道) Dictionary ]] via [[https://github.com/xuchunyang/youdao-dictionary.el ][youdao-dictionary ]].
- Support for file searches in =dired= using Chinese Pinyin characters via [[https://github.com/redguardtoo/find-by-pinyin-dired ][find-by-pinyin-dired ]].
- Support for jumping to Chinese Pinyin characters with =ace-jump-mode= via [[https://github.com/cute-jumper/ace-pinyin ][ace-pinyin ]].
2018-08-12 21:57:51 +00:00
- Support for conversion between simplified and traditional Chinese texts via [[https://github.com/gucong/emacs-chinese-conv/ ][chinese-conv ]].
2018-01-19 15:27:23 +00:00
- Automatic visual separation of Chinese and Latin characters via [[https://github.com/coldnew/pangu-spacing ][coldnew/pangu-spacing ]].
- Automatic joining of consecutive Chinese lines into a single long line without unwanted space when exporting org-mode to html.
2015-06-27 15:12:43 +00:00
* Install
** Layer
2016-01-06 05:21:55 +00:00
To use this configuration layer, add it to your =~/.spacemacs= . You will need to
add =chinese= to the existing =dotspacemacs-configuration-layers= list in this
file.
2015-07-05 04:34:27 +00:00
2015-06-27 15:12:43 +00:00
** Configuration
*** Configure the Default Input Method(配置默认中文输入法)
2016-04-13 03:31:38 +00:00
The default Chinese input method is =Chinese-pyim= , if you are a Wubi(五笔) user,
2015-11-08 08:59:51 +00:00
you could set the variable =chinese-default-input-method= to =wubi= :
2018-07-10 10:57:25 +00:00
2018-09-19 03:54:47 +00:00
#+BEGIN_SRC emacs-lisp
2015-06-27 15:12:43 +00:00
(setq-default dotspacemacs-configuration-layers '(
(chinese :variables chinese-default-input-method 'wubi)))
2018-09-19 03:54:47 +00:00
#+END_SRC
2015-07-05 04:34:27 +00:00
2015-06-27 15:12:43 +00:00
*** Configure the =Chinese-pyim= Input Method(配置中文拼音输入法)
2018-01-19 15:27:23 +00:00
The first time you use =Chinese-pyim= , you need to install the lexicon(词库)
file. Call =pyim-dicts-manager= to open up the settings buffer and
press =i e= to install the default lexicon. The lexicon is about 20MB, so you
2015-07-05 04:34:27 +00:00
should be patient when downloading starts. After the lexicon file is downloaded,
just press =s= to save and =R= to restart configuration.
2016-04-13 03:31:38 +00:00
2018-08-12 21:57:51 +00:00
*** Configure =chinese-conv= (配置简繁转换)
The =chinese-conv= package requires either [[https://github.com/BYVoid/OpenCC ][opencc ]] or [[https://github.com/xiaoyjy/cconv ][cconv ]] installed.
By default, =opencc= will be used as the backend, set
#+BEGIN_SRC emacs-lisp
(setq-default dotspacemacs-configuration-layers '((chinese :variables
chinese-conv-backend "cconv")))
#+END_SRC
to use =cconv= as the backend.
2018-10-23 14:18:21 +00:00
There is no default key binding for the conversions. Run
2018-08-12 21:57:51 +00:00
=M-x chinese-conv=
to replace arbitrary input, or
=M-x chinese-conv-replace=
to replace the current selection in-place.
2015-11-17 00:23:02 +00:00
*** Enable fcitx
#+BEGIN_SRC emacs-lisp
(setq-default dotspacemacs-configuration-layers '((chinese :variables
chinese-enable-fcitx t)))
#+END_SRC
2018-07-10 10:57:25 +00:00
2019-05-26 20:58:52 +00:00
If you don't need to type Chinese in minibuffer, you can temporarily disable fcitx in the minibuffer
2015-11-17 00:23:02 +00:00
with the following configuration.
#+BEGIN_SRC emacs-lisp
(fcitx-aggressive-setup)
#+END_SRC
2016-04-13 03:31:38 +00:00
2015-12-10 05:04:46 +00:00
**** Requirement
***** Linux
2018-01-19 15:27:23 +00:00
You need to install =fcitx= and =fcitx-remote= on your machine.
2015-12-11 07:03:02 +00:00
2015-12-10 05:04:46 +00:00
***** Mac OS X
2019-05-26 20:58:52 +00:00
We don't have a =fcitx= in OS X yet but we already added an emulation called
2015-12-11 07:03:02 +00:00
=fcitx-remote= to make you happy with other Chinese input-methods.
2015-11-17 00:23:02 +00:00
2015-12-10 05:04:46 +00:00
You can install [[https://github.com/CodeFalling/fcitx-remote-for-osx ][fcitx-remote-for-osx ]] from homebrew.
#+BEGIN_SRC shell
brew install fcitx-remote-for-osx --with-input-method=baidu-pinyin
#+END_SRC
=--with-input-method=baidu-pinyin= means install for Baidu-pinyin Input Method.
2015-12-11 07:03:02 +00:00
You can use =brew info fcitx-remote-for-osx= to get more options info for input
method support.
2015-12-10 05:04:46 +00:00
#+BEGIN_EXAMPLE
2018-09-19 03:54:47 +00:00
--with-input-method=
Select input method: baidu-pinyin(default), baidu-wubi, sogou-pinyin, qq-wubi, squirrel-rime, osx-pinyin
2015-12-10 05:04:46 +00:00
#+END_EXAMPLE
2015-12-11 07:03:02 +00:00
2015-12-10 05:04:46 +00:00
***** Windows
2016-07-07 05:38:26 +00:00
In order to use =fcitx.el= in Windows, you should install [[https://github.com/cute-jumper/fcitx-remote-for-windows ][fcitx-remote-for-windows ]].
2015-11-08 18:04:44 +00:00
2015-07-05 14:21:00 +00:00
*** Enable YouDao(有道) Dictionary(激活有道字典)
The YouDao Dictionary is disabled by default, if you want enable it.
2015-11-08 08:59:51 +00:00
You should set =chinese-enable-youdao-dict= to =t= .
2015-07-05 14:21:00 +00:00
#+BEGIN_SRC emacs-lisp
(setq-default dotspacemacs-configuration-layers '((chinese :variables
chinese-enable-youdao-dict t)))
#+END_SRC
2015-06-27 15:12:43 +00:00
*** Set monospaced font size(设置等宽字体)
2018-01-19 15:27:23 +00:00
If you are mixing Chinese script with Latin script, the text is not perfectly
2019-05-26 20:58:52 +00:00
aligned in org table. That's because normally the Chinese font size is not equal
2018-01-19 15:27:23 +00:00
to the Latin font size. You could call =spacemacs//set-monospaced-font= with
2015-09-28 06:05:18 +00:00
your own Chinese font name in =dotspacemacs/user-config= function.
2015-06-27 15:12:43 +00:00
Example configuration:
2018-07-10 10:57:25 +00:00
2015-07-05 04:34:27 +00:00
#+BEGIN_SRC emacs-lisp
2018-09-19 03:54:47 +00:00
;; Note: The Hiragino Sans GB is bundled with MacOS X.
;; If you are not using MacOS X, you should change it to another Chinese font name.
(spacemacs//set-monospaced-font "Source Code Pro" "Hiragino Sans GB" 14 16)
2015-07-05 04:34:27 +00:00
#+END_SRC
2015-06-27 15:12:43 +00:00
2015-11-08 08:59:51 +00:00
*** Enable/Disable ace-pinyin in =avy-goto-char=
You can use =avy-goto-char= with pinyin supported by default, if you want to
2018-01-19 15:27:23 +00:00
disable it. You can set =chinese-enable-avy-pinyin= to =nil= .
2015-11-08 08:59:51 +00:00
#+BEGIN_SRC emacs-lisp
(setq-default dotspacemacs-configuration-layers '((chinese :variables
chinese-enable-avy-pinyin nil)))
#+END_SRC
2018-12-05 03:03:03 +00:00
* Key bindings
2015-07-05 04:34:27 +00:00
Currently, there are no built-in key bindings for this layer. You could define
your own preference.
2015-06-27 15:12:43 +00:00
2015-07-05 04:34:27 +00:00
Here are a few suggested key bindings (remember that ~SPC o~ is reserved for
personal usage, spacemacs won´ t put any binding under this prefix):
2015-06-27 15:12:43 +00:00
2015-07-05 04:34:27 +00:00
** Youdao Dictionary
2018-09-19 03:54:47 +00:00
Bind ~SPC o y~ to =youdao-dictionary-search-at-point+= .
2015-06-27 15:12:43 +00:00
** Find-by-pinyin-dired
2015-07-05 04:34:27 +00:00
Bind ~SPC o d~ to =find-by-pinyin-dired=