git clone 'git://'


Minor-mode to add space between Chinese and English characters.

License GPL3 MELPA MELPA Stable



Commentary (English)

pangu-spacing-mode is an minor-mode to auto add space between Chinese and English characters. Note that these white-space characters are not really added to the contents, it just like to do so.

Take following sentance for example:


After you use pangu-spacing-mdoe, you will see

 你好,我是 coldnew,我喜歡使用 emacs。

But the text doesn't be modify by this mode, after disable pangu-spacing-mode or use other text eidtor to open the file, you will still see:


pangu-spacing is named from paranoid-auto-spacing's README.

 Translation of paranoid-auto-spacing's README [1]

 If you are the one who feel quiet ill when see Chinese,
 English and digits characters squeezed together and
 want to add whitespace to separate them. This plugin (support
 Chrome and Firefox) is what you need when surfing the
 internet, it will add whitespace between Chinese,
 half-width English, digits and symbols automatically.

 These spaces between English and Chinese characters are called
 pangu-spacing by sinologist, since it separate the cobnfusion
 between full-width and half-width characters.
 Studies showed that who dislike to add whitespace between
 English and Chinese characters also have relationship problem.
 Almost 70 percent of them will get married to the one they
 don't love, the rest only can left the heritage to their cat.
 Indeed, love and writing need some space in good time.

 Let's go for it.


Commentary (Chinese)

pangu-spacing-mode 是一個可以自動幫你將中文與英文之間加上空白作為分隔的 minor-mode, 他的名稱來自於 paranoid-auto-spacing 上的 README。

 引述自 paranoid-auto-spacing README [1]

 坐立難安,忍不住想在它們之間加個空格。這個外掛(支援 Chrome 和 Firefox)

 走得很辛苦,有七成的比例會在 34 歲的時候跟自己不愛的人結婚,而其餘三成





If you have melpa and emacs24 installed, simply type:

 M-x package-install pangu-spacing

For cask user, just add following lines in your Cask file

 (source melpa)

 (depends-on "pangu-spacing")


In your .emacs

 (require 'pangu-spacing)
 (global-pangu-spacing-mode 1)

pangu-spacing-mode do not really insert space between English and Chinese by defaut, you should enable this option manually.

 (setq pangu-spacing-real-insert-separtor t)

After you enable this, space will be inserted before you save file.

If you only want to insert whitespace in some specific mode, but just add virtual space in other mode, you can use following code to achive this: (take org-mode as example)

 (add-hook 'org-mode-hook
           '(lambda ()
            (set (make-local-variable 'pangu-spacing-real-insert-separtor) t)))

Function Documentation

(pangu-spacing-search-buffer REGEXP START END FUNC)

Helper macro to search buffer and do func according regexp for pangu-spacing-mode.

(pangu-spacing-search-overlay FUNC REGEXP)

Helper macro to search and update overlay according func and regexp for pangu-sapce-mode.

(pangu-spacing-search-and-replace MATCH REGEXP)

Replace regexp with match in buffer.

(pangu-spacing-overlay-p OV)

Determine whether overlay OV was created by space-between.


Insert a space between English words and Chinese charactors in overlay.


Real insert separator between English words and Chinese charactors in buffer.

(pangu-spacing-region-has-pangu-spacing-overlays BEG END)

Check if region specified by BEG and END has overlay. Return t if it has at least one pangu-spacing overlay, nil if no overlay.

(pangu-spacing-make-overlay BEG END)

Allocate a pangu-spacing overlay in range.

(pangu-spacing-delete-overlay BEG END)

Delete all pangu-spacing-overlays in BUFFER.


Delete all pangu-spacing-overlays in BUFFER.


Markdown README file generated by make-readme-markdown.el