Skip to content

Commit

Permalink
Keep compatibility since Emacs has removed typo.
Browse files Browse the repository at this point in the history
the missing `chinse-two-byte` may broken the package

emacs-mirror/emacs@4437d73
  • Loading branch information
nailuoGG committed Aug 14, 2024
1 parent 2303013 commit 000aa10
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions pangu-spacing.el
Original file line number Diff line number Diff line change
Expand Up @@ -167,19 +167,25 @@ When you set t here, the space will be insert when you save file."
;; [Emacs-diffs] trunk r115873: Fix misspelling of 'chinese' in rx.
;;
;; Url: http://lists.gnu.org/archive/html/emacs-diffs/2014-01/msg00049.html
;;
(defun pangu-spacing-chinese-two-byte-category ()
"Return the correct category name for Chinese two-byte characters."
(if (assq 'chinese-two-byte rx--categories)
"chinese-two-byte"
"chinse-two-byte"))

(defvar pangu-spacing-include-regexp
;; we didn't add korean because korean-hangul-two-byte is not implemented
(rx (or (and (or (group-n 3 (any "。,!?;:「」()、"))
(group-n 1 (or (category chinse-two-byte)
(category japanese-hiragana-two-byte)
(category japanese-katakana-two-byte))))
(group-n 2 (in "a-zA-Z0-9")))
(and (group-n 1 (in "a-zA-Z0-9"))
(or (group-n 3 (any "。,!?;:「」()、"))
(group-n 2 (or (category chinse-two-byte)
(category japanese-hiragana-two-byte)
(category japanese-katakana-two-byte)))))))
(eval `(rx (or (and (or (group-n 3 (any "。,!?;:「」()、"))
(group-n 1 (or (category ,(intern (pangu-spacing-chinese-two-byte-category)))
(category japanese-hiragana-two-byte)
(category japanese-katakana-two-byte))))
(group-n 2 (in "a-zA-Z0-9")))
(and (group-n 1 (in "a-zA-Z0-9"))
(or (group-n 3 (any "。,!?;:「」()、"))
(group-n 2 (or (category ,(intern (pangu-spacing-chinese-two-byte-category)))
(category japanese-hiragana-two-byte)
(category japanese-katakana-two-byte))))))))
"Regexp to find Chinese character before English character.
Group 1 contains the character before the potential pangu
Expand Down

0 comments on commit 000aa10

Please sign in to comment.