coldnew / pangu-spacing

emacs minor-mode to add space between Chinese/Japanese/Korean and English characters.
144 stars 16 forks source link

Seems to affect non-Chinese non-ASCII characters (e.g. "ü") as well #26

Open x-ji opened 6 years ago

x-ji commented 6 years ago

If I write a German word (e.g. Kündigung), spaces are automatically inserted around ü, which is not sensible. This package should strictly only work on CJK characters.

I think this might have something to do with https://github.com/coldnew/pangu-spacing/issues/17. However that is a really special use case, support for which should only be enabled via a dedicated variable, instead of by default.

x-ji commented 6 years ago

Looked into the source code a bit but not sure why this happened:

(defvar pangu-spacing-chinese-before-english-regexp
  (rx (group-n 1 (category chinse-two-byte))
      (group-n 2 (in "a-zA-Z0-9")))
  "Regexp to find Chinese character before English character.")

(defvar pangu-spacing-chinese-after-english-regexp
  (rx (group-n 1 (in "a-zA-Z0-9"))
      (group-n 2 (category chinse-two-byte)))
  "Regexp to find Chinese character after English character.")

(defvar pangu-spacing-chinese-before-english-regexp-exclude
  (rx (group-n 1 (or (in "。,!?;:「」()、")))
      (group-n 2 (in "a-zA-Z0-9")))
  "Excluded regexp to find Chinese character before English character.")

(defvar pangu-spacing-chinese-after-english-regexp-exclude
  (rx (group-n 1 (in "a-zA-Z0-9"))
      (group-n 2 (or (in "。,!?;:「」()、"))))
  "Excluded regexp to find Chinese character after English character.")

These functions doesn't seem to include any non-Chinese character?