File tree 1 file changed +12
-12
lines changed
1 file changed +12
-12
lines changed Original file line number Diff line number Diff line change 63
63
(defvar emt--root (file-name-directory (or load-file-name buffer-file-name))
64
64
" The path to the root of the package." )
65
65
66
- (defvar emt--cjk-char-regex-forward (format " \\ W*\\ (\\ cc\\ |\\ cj\\ |\\ ch\\ )" )
67
- " Regex for CJK char." )
68
-
69
- (defvar emt--cjk-char-regex-backward (format " \\ (\\ cc\\ |\\ cj\\ |\\ ch\\ )\\ W*" )
66
+ (defvar emt--cjk-char-regex (format " ^\\ W*\\ (\\ cc\\ |\\ cj\\ |\\ ch\\ )+\\ W*$ " )
70
67
" Regex for CJK char." )
71
68
72
69
(defvar emt--lib-loaded nil
107
104
If DIRECTION is `'forward' , return the bounds of the string forward.
108
105
If DIRECTION is `'backward' , return the bounds of the string backward.
109
106
If DIRECTION is `'all' , return the bounds of the string forward and backward."
110
- (let ((beg (point ))
111
- (end (point )))
107
+ (let* ((pos (point ))
108
+ (beg pos)
109
+ (end pos))
112
110
(when (or (eq direction 'forward ) (eq direction 'all ))
113
- (when (looking-at emt--cjk-char-regex-forward)
114
- (save-excursion
115
- (forward-word )
111
+ (save-excursion
112
+ (forward-word )
113
+ (when (string-match-p emt--cjk-char-regex
114
+ (buffer-substring-no-properties pos (point )))
116
115
(setq end (point )))))
117
116
(when (or (eq direction 'backward ) (eq direction 'all ))
118
- (when (looking-back emt--cjk-char-regex-backward nil )
119
- (save-excursion
120
- (backward-word )
117
+ (save-excursion
118
+ (backward-word )
119
+ (when (string-match-p emt--cjk-char-regex
120
+ (buffer-substring-no-properties (point ) pos))
121
121
(setq beg (point )))))
122
122
(cons beg end)))
123
123
You can’t perform that action at this time.
0 commit comments