diff --git a/pangu-spacing.el b/pangu-spacing.el index 4c7157a..f36ba6d 100644 --- a/pangu-spacing.el +++ b/pangu-spacing.el @@ -158,7 +158,6 @@ When you set t here, the space will be insert when you save file." :type 'list) ;;;; Local variables - ;; NOTE: ;; We use `chinse-two-byte' instead of `chinese-two-byte', since there ;; are some typo in emacs version 21.1-24.3. For more information, @@ -167,19 +166,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 @@ -212,14 +217,14 @@ pangu-spacing-mode." "Helper macro to search and update overlay according func and regexp for pangu-sapce-mode." `(pangu-spacing-search-buffer ,regexp ,beg ,end - (,func (match-beginning 1) (match-end 1)))) + (,func (match-beginning 1) (match-end 1)))) (defun pangu-spacing-org-mode-at-special-region () (interactive) (let ((element (org-element-at-point))) (when (or (member (org-element-type element) '(src-block keyword example-block export-block - latex-environment planning)) + latex-environment planning)) (member (car (org-element-context element)) '(inline-src-block timestamp link code verbatim))) t))) @@ -230,7 +235,7 @@ pangu-sapce-mode." check for special region that shall not write real pangu-space" :group 'pangu-spacing :type '(alist :key-type (symbol) - :value-type (function))) + :value-type (function))) (defun pangu-spacing-search-and-replace (match regexp) "Replace regexp with match in buffer."