Mercurial > hg > xemacs-beta
annotate lisp/mule/kinsoku.el @ 5750:66d2f63df75f
Correct some spelling and formatting in behavior.el.
Mentioned in tracker issue 826, the third thing mentioned there (the file
name at the bottom of the file) had already been fixed.
lisp/ChangeLog addition:
2013-08-05 Aidan Kehoe <kehoea@parhasard.net>
* behavior.el:
(override-behavior):
Correct some spelling and formatting here, thank you Steven
Mitchell in tracker issue 826.
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Mon, 05 Aug 2013 10:05:32 +0100 |
parents | 4dee0387b9de |
children |
rev | line source |
---|---|
502 | 1 ;; kinsoku.el -- Kinsoku (line wrap) processing for XEmacs/Mule -*- coding: iso-2022-7bit; -*- |
333 | 2 |
3 ;; Copyright (C) 1997 Free Software Foundation, Inc. | |
4 ;; This file is part of Mule (MULtilingual Enhancement of XEmacs). | |
5 ;; This file contains Japanese and Chinese characters. | |
6 | |
5404
91b3aa59f49b
Convert lisp/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents:
908
diff
changeset
|
7 ;; XEmacs is free software: you can redistribute it and/or modify it |
91b3aa59f49b
Convert lisp/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents:
908
diff
changeset
|
8 ;; under the terms of the GNU General Public License as published by the |
91b3aa59f49b
Convert lisp/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents:
908
diff
changeset
|
9 ;; Free Software Foundation, either version 3 of the License, or (at your |
91b3aa59f49b
Convert lisp/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents:
908
diff
changeset
|
10 ;; option) any later version. |
333 | 11 |
5404
91b3aa59f49b
Convert lisp/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents:
908
diff
changeset
|
12 ;; XEmacs is distributed in the hope that it will be useful, but WITHOUT |
91b3aa59f49b
Convert lisp/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents:
908
diff
changeset
|
13 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
91b3aa59f49b
Convert lisp/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents:
908
diff
changeset
|
14 ;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
91b3aa59f49b
Convert lisp/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents:
908
diff
changeset
|
15 ;; for more details. |
333 | 16 |
17 ;; Written by Jareth Hein (jhod@po.iijnet.or.jp) based off of | |
18 ;; code by S.Tomura, Electrotechnical Lab. (tomura@etl.go.jp) from | |
19 ;; Mule-2.3 | |
20 | |
21 ;;; Special characters for JIS code | |
22 ;;; "$B!!!"!#!$!%!&!'!'!(!)!*!+!,!-!.!/(B" | |
23 ;;; "$B!0!1!2!3!4!5!6!7!8!9!:!;!<!=!>!?(B" | |
24 ;;; "$B!@!A!B!C!D!E!F!G!H!I!J!K!L!M!N!O(B" | |
25 ;;; "$B!P!Q!R!S!T!U!V!W!X!Y!Z![!\!]!^!_(B" | |
26 ;;; "$B!`!a!b!c!d!e!f!g!h!i!j!k!l!m!n!o(B" | |
27 ;;; "$B!p!q!r!s!t!u!v!w!x!y!z!{!|!}!~(B" | |
28 ;;; "$B"!"""#"$"%"&"'"(")"*"+","-".(B " | |
29 ;;; "$B&!&"&#&$&%&&&'&(&)&*&+&,&-&.&/(B" | |
30 ;;; "$B&0&1&2&3&4&5&6&7&8(B" | |
31 ;;; "$B&A&B&C&D&E&F&G&H&I&J&K&L&M&N&O(B" | |
32 ;;; "$B&P&Q&R&S&T&U&V&W&X(B" | |
33 ;;; "$B'!'"'#'$'%'&'''(')'*'+','-'.'/(B" | |
34 ;;; "$B'0'1'2'3'4'5'6'7'8'9':';'<'='>'?(B" | |
35 ;;; "$B'@'A(B" | |
36 ;;; "$B'Q'R'S'T'U'V'W'X'Y'Z'['\']'^'_!I(B | |
37 ;;; "$B'`'a'b'c'd'e'f'g'h'i'j'k'l'm'n'o(B" | |
38 ;;; "$B'p'q(B" | |
39 ;;; $B#0#1#2#3#4#5#6#7#8#9#A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$9$:$;$<$=$>$?(B | |
114 ;;;$(0$@$A$B$C$D$E$F$G$H$I$J$K$L$M$N$O(B | |
115 ;;;$(0$P$Q$R$S$T$U$V$W$X$Y$Z$[$\$]$^$_(B | |
116 ;;;$(0$`$a$b$c$d$e$f$g$h$i$j$k$l$m$n$o(B | |
117 ;;;$(0$p$q$r$s$t$u$v$w$x$y$z${$|$}$~(B | |
118 ;;; $(0%!%"%#%$%%%&%'%(%)%*%+%,%-%.%/(B | |
119 ;;;$(0%0%1%2%3%4%5%6%7%8%9%:%;%<%=%>%?(B | |
120 | |
121 (defvar kinsoku-ascii nil "Do kinsoku-processing for ASCII.") | |
122 (make-variable-buffer-local 'kinsoku-ascii) | |
123 (set-default 'kinsoku-ascii nil) | |
124 (defvar kinsoku-jis t "Do kinsoku-processing for JISX0208.") | |
125 (make-variable-buffer-local 'kinsoku-jis) | |
126 (set-default 'kinsoku-jis t) | |
127 (defvar kinsoku-gb t "Do kinsoku-processing for GB2312.") | |
128 (make-variable-buffer-local 'kinsoku-gb) | |
129 (set-default 'kinsoku-gb t) | |
130 (defvar kinsoku-big5 t "Do kinsoku-processing for Big5..") | |
131 (make-variable-buffer-local 'kinsoku-big5) | |
132 (set-default 'kinsoku-big5 t) | |
133 | |
134 (defvar kinsoku-ascii-bol "!)-_~}]:;',.?" "BOL kinsoku for ASCII.") | |
135 (defvar kinsoku-ascii-eol "({[" "EOL kinsoku for ASCII.") | |
136 (defvar kinsoku-jis-bol | |
137 (concat "$B!"!#!$!%!&!'!(!)!*!+!,!-!.!/!0!1!2!3!4!5!6!7!8!9!:!;!<!=!>(B" | |
138 "$B!?!@!A!B!C!D!E!G!I!K!M!O!Q!S!U!W!Y![!k!l!m!n(B" | |
139 "$B$!$#$%$'$)$C$c$e$g$n%!%#%%%'%)%C%c%e%g%n%u%v(B") | |
140 "BOL kinsoku for JISX0208.") | |
141 (defvar kinsoku-jis-eol | |
142 "$B!F!H!J!L!N!P!R!T!V!X!Z!k!l!m!n!w!x(B" | |
143 "EOL kinsoku for JISX0208.") | |
144 (defvar kinsoku-gb-bol | |
145 (concat "$A!"!##.#,!$!%!&!'!(!)!*!+!,!-!/!1#)!3!5!7!9!;!=(B" | |
146 "$A!?#;#:#?#!!@!A!B!C!c!d!e!f#/#\#"#_#~#|(e(B") | |
147 "BOL kinsoku for GB2312.") | |
148 (defvar kinsoku-gb-eol | |
149 (concat "$A!.!0#"#(!2!4!6!8!:!<!>!c!d!e#@!f!l(B" | |
150 "$A(E(F(G(H(I(J(K(L(M(N(O(P(Q(R(S(T(U(V(W(X(Y(h(B") | |
151 "EOL kinsoku for GB2312.") | |
152 (defvar kinsoku-big5-bol | |
153 (concat "$(0!"!#!$!%!&!'!(!)!*!+!,!-!.!/!0!1!2(B" | |
154 "$(0!3!4!5!6!7!8!9!:!;!<!=!?!A!C!E!G!I!K(B" | |
155 "$(0!M!O!Q(B $(0!S!U!W!Y![!]!_!a!c!e!g!i!k!q(B" | |
156 "$(0"#"$"%"&"'"(")"*"+","2"3"4"j"k"l"x%7(B") | |
157 "BOL kinsoku for BIG5.") | |
158 (defvar kinsoku-big5-eol | |
159 (concat "$(0!>!@!B!D!F!H!J!L!N!P!R!T!V!X!Z!\!^!`!b(B" | |
160 "$(0!d!f!h!j!k!q!p"i"j"k"n"x$u$v$w$x$y$z${(B" | |
161 "$(0$|$}$~%!%"%#%$%%%&%'%(%)%*%+%:(B") | |
162 "EOL kinsoku for BIG5.") | |
163 | |
164 (define-category ?s "Kinsoku forbidden start of line characters") | |
165 (define-category ?e "Kinsoku forbidden end of line characters") | |
166 | |
167 ;; kinsoku ascii | |
771 | 168 (loop for char in (string-to-list kinsoku-ascii-bol) |
333 | 169 do (modify-category-entry char ?s)) |
908 | 170 (loop for char in (string-to-list kinsoku-ascii-eol) |
333 | 171 do (modify-category-entry char ?e)) |
172 ;; kinsoku-jis | |
771 | 173 (loop for char in (string-to-list kinsoku-jis-bol) |
333 | 174 do (modify-category-entry char ?s)) |
771 | 175 (loop for char in (string-to-list kinsoku-jis-eol) |
333 | 176 do (modify-category-entry char ?e)) |
177 ;; kinsoku-gb | |
908 | 178 (loop for char in (string-to-list kinsoku-gb-bol) |
333 | 179 do (modify-category-entry char ?s)) |
908 | 180 (loop for char in (string-to-list kinsoku-gb-eol) |
333 | 181 do (modify-category-entry char ?e)) |
182 ;; kinsoku-big5 | |
908 | 183 (loop for char in (string-to-list kinsoku-big5-bol) |
333 | 184 do (modify-category-entry char ?s)) |
908 | 185 (loop for char in (string-to-list kinsoku-big5-eol) |
333 | 186 do (modify-category-entry char ?e)) |
187 | |
188 (defun kinsoku-bol-p () | |
189 "Check if point would break forbidden beginning-of-line rules | |
190 Uses category \'s\' to check. | |
191 point$B$G2~9T$9$k$H9TF,6XB'$K?($l$k$+$I$&$+$r$+$($9!#(B | |
192 $B9TF,6XB'J8;z$O(B\'s\'$B$N(Bcategory$B$G;XDj$9$k!#(B" | |
908 | 193 (let ((before (char-before)) |
194 (after (char-after))) | |
195 (if (and after | |
333 | 196 (or |
908 | 197 (and kinsoku-ascii (char-in-category-p after ?a)) |
198 (and kinsoku-jis (or (char-in-category-p after ?j) | |
199 (and before | |
200 (char-in-category-p before ?j)))) | |
201 (and kinsoku-gb (or (char-in-category-p after ?c) | |
202 (and before | |
203 (char-in-category-p before ?c)))) | |
204 (and kinsoku-big5 (or (char-in-category-p after ?t) | |
205 (and before | |
206 (char-in-category-p before ?t)))))) | |
207 (char-in-category-p after ?s) | |
333 | 208 nil))) |
209 | |
210 (defun kinsoku-eol-p () | |
211 "Check if point would break forbidden end-of-line rules | |
212 Uses category \'e\' to check. | |
213 point$B$G2~9T$9$k$H9TKv6XB'$K?($l$k$+$I$&$+$r$+$($9!#(B | |
214 $B9TKv6XB'J8;z$O(B\'s\'$B$N(Bcategory$B$G;XDj$9$k!#(B" | |
908 | 215 (let ((before (char-before)) |
216 (after (char-after))) | |
217 (if (and before | |
333 | 218 (or |
908 | 219 (and kinsoku-ascii (char-in-category-p before ?a)) |
220 (and kinsoku-jis (or (char-in-category-p before ?j) | |
221 (and after | |
222 (char-in-category-p after ?j)))) | |
223 (and kinsoku-gb (or (char-in-category-p before ?c) | |
224 (and after | |
225 (char-in-category-p after ?c)))) | |
226 (and kinsoku-big5 (or (char-in-category-p before ?t) | |
227 (and after | |
228 (char-in-category-p after ?t)))))) | |
229 (char-in-category-p before ?e) | |
333 | 230 nil))) |
231 | |
232 (defvar kinsoku-extend-limit nil | |
233 "Defines how many characters kinsoku will search forward before giving up. | |
234 A value of nil equates to infinity. | |
235 $B6XB'=hM}$G9T$r?-$P$7$FNI$$H>3QJ8;z?t$r;XDj$9$k!#(B | |
236 $BHsIi@0?t0J30$N>l9g$OL58BBg$r0UL#$9$k!#(B") | |
237 | |
238 (defun kinsoku-process () | |
239 "Move to a point that will not break forbidden line break rules. | |
240 $B6XB'$K?($l$J$$E@$X0\F0$9$k!#(B | |
241 point$B$,9TF,6XB'$K?($l$k>l9g$O9T$r?-$P$7$F!"6XB'$K?($l$J$$E@$rC5$9!#(B | |
242 point$B$,9TKv6XB'$K?($l$k>l9g$O9T$r=L$a$F!"6XB'$K?($l$J$$E@$rC5$9!#(B | |
243 $B$?$@$7!"9T?-$P$7H>3QJ8;z?t$,(Bkinsoku-extend-limit$B$r1[$($k$H!"(B | |
244 $B9T$r=L$a$F6XB'$K?($l$J$$E@$rC5$9!#(B" | |
245 (let ((bol-kin nil) (eol-kin nil)) | |
246 (if (and (not (bolp)) | |
247 (not (eolp)) | |
248 (or (setq bol-kin (kinsoku-bol-p)) | |
249 (setq eol-kin (kinsoku-eol-p)))) | |
250 (cond(bol-kin (kinsoku-process-extend)) | |
251 (eol-kin (kinsoku-process-shrink)))))) | |
252 | |
253 (defun kinsoku-process-extend () | |
5384
3889ef128488
Fix misspelled words, and some grammar, across the entire source tree.
Jerry James <james@xemacs.org>
parents:
5287
diff
changeset
|
254 "Move point forward to a point permissible for line-breaking. |
333 | 255 $B9T$r?-$P$7$F6XB'$K?($l$J$$E@$X0\F0$9$k!#(B" |
256 (let ((max-column (+ fill-column | |
257 (if (and (numberp kinsoku-extend-limit) | |
258 (>= kinsoku-extend-limit 0)) | |
259 kinsoku-extend-limit | |
5384
3889ef128488
Fix misspelled words, and some grammar, across the entire source tree.
Jerry James <james@xemacs.org>
parents:
5287
diff
changeset
|
260 10000))) ;;; 10000 is deliberately unreasonably large |
333 | 261 ch1 ch2) |
262 (while (and (setq ch1 (char-after)) | |
263 (<= (+ (current-column) | |
264 (char-width ch1 )) | |
265 max-column) | |
266 (not (bolp)) | |
267 (not (eolp)) | |
268 (or (kinsoku-eol-p) | |
269 (kinsoku-bol-p) | |
270 ;;; don't break in the middle of an English word | |
271 (and (char-in-category-p ch1 ?a) | |
272 (setq ch2 (char-before)) | |
273 (char-in-category-p ch2 ?a) | |
274 (= ?w (char-syntax ch2)) | |
275 (= ?w (char-syntax ch1))))) | |
276 (forward-char)) | |
277 (if (or (kinsoku-eol-p) (kinsoku-bol-p)) | |
278 (kinsoku-process-shrink)))) | |
279 | |
280 (defun kinsoku-process-shrink () | |
5384
3889ef128488
Fix misspelled words, and some grammar, across the entire source tree.
Jerry James <james@xemacs.org>
parents:
5287
diff
changeset
|
281 "Move point backward to a point permissible for line-breaking. |
333 | 282 $B9T$r=L$a$F6XB'$K?($l$J$$E@$X0\F0$9$k!#(B" |
283 (let (ch1 ch2) | |
284 (while (and (not (bolp)) | |
285 (not (eolp)) | |
286 (or (kinsoku-bol-p) | |
287 (kinsoku-eol-p) | |
288 ;;; don't break in the middle of an English word | |
289 (and | |
290 (char-in-category-p (setq ch1 (following-char)) ?a) | |
291 (char-in-category-p (setq ch2 (preceding-char)) ?a) | |
292 (= ?w (char-syntax ch2)) | |
293 (= ?w (char-syntax ch1))))) | |
294 (backward-char)))) |