Mercurial > emacs
comparison lisp/international/kinsoku.el @ 88155:d7ddb3e565de
sync with trunk
author | Henrik Enberg <henrik.enberg@telia.com> |
---|---|
date | Mon, 16 Jan 2006 00:03:54 +0000 |
parents | 0d8b17d428b5 |
children |
comparison
equal
deleted
inserted
replaced
88154:8ce476d3ba36 | 88155:d7ddb3e565de |
---|---|
1 ;;; kinsoku.el --- `Kinsoku' processing funcs -*- coding: iso-2022-7bit; -*- | 1 ;;; kinsoku.el --- `Kinsoku' processing funcs -*- coding: iso-2022-7bit; -*- |
2 | 2 |
3 ;; Copyright (C) 1995 Electrotechnical Laboratory, JAPAN. | 3 ;; Copyright (C) 1997, 2003 Free Software Foundation, Inc. |
4 ;; Licensed to the Free Software Foundation. | 4 ;; Copyright (C) 1995, 1997, 1998 |
5 ;; National Institute of Advanced Industrial Science and Technology (AIST) | |
6 ;; Registration Number H14PRO021 | |
5 | 7 |
6 ;; Keywords: mule, kinsoku | 8 ;; Keywords: mule, kinsoku |
7 | 9 |
8 ;; This file is part of GNU Emacs. | 10 ;; This file is part of GNU Emacs. |
9 | 11 |
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
18 ;; GNU General Public License for more details. | 20 ;; GNU General Public License for more details. |
19 | 21 |
20 ;; You should have received a copy of the GNU General Public License | 22 ;; You should have received a copy of the GNU General Public License |
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the | 23 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 24 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
23 ;; Boston, MA 02111-1307, USA. | 25 ;; Boston, MA 02110-1301, USA. |
24 | 26 |
25 ;;; Commentary: | 27 ;;; Commentary: |
26 | 28 |
27 ;; `Kinsoku' processing is to prohibit specific characters to be | 29 ;; `Kinsoku' processing is to prohibit specific characters to be |
28 ;; placed at beginning of line or at end of line. Characters not to | 30 ;; placed at beginning of line or at end of line. Characters not to |
105 ;; Japanese JISX0208 | 107 ;; Japanese JISX0208 |
106 "$B!F!H!J!L!N!P!R!T!V!X!Z!k!l!m!n!w!x(B\ | 108 "$B!F!H!J!L!N!P!R!T!V!X!Z!k!l!m!n!w!x(B\ |
107 $A!.!0#"#(!2!4!6!8!:!<!>!c!d!e#@!f!l(B" | 109 $A!.!0#"#(!2!4!6!8!:!<!>!c!d!e#@!f!l(B" |
108 ;; Chinese GB2312 | 110 ;; Chinese GB2312 |
109 "$A(E(F(G(H(I(J(K(L(M(N(O(P(Q(R(S(T(U(V(W(X(Y(h(B\ | 111 "$A(E(F(G(H(I(J(K(L(M(N(O(P(Q(R(S(T(U(V(W(X(Y(h(B\ |
110 $(0!>!@!B!D!F!H!J!L!N!P!R!T!V!X!Z!\!^!`!b(B" | 112 \$(0!>!@!B!D!F!H!J!L!N!P!R!T!V!X!Z!\!^!`!b(B" |
111 ;; Chinese BIG5 | 113 ;; Chinese BIG5 |
112 "$(0!d!f!h!j!k!q!p"i"j"k"n"x$u$v$w$x$y$z${(B\ | 114 "$(0!d!f!h!j!k!q!p"i"j"k"n"x$u$v$w$x$y$z${(B\ |
113 $(0$|$}$~%!%"%#%$%%%&%'%(%)%*%+%:(B")) | 115 $(0$|$}$~%!%"%#%$%%%&%'%(%)%*%+%:(B")) |
114 (len (length kinsoku-eol)) | 116 (len (length kinsoku-eol)) |
115 (idx 0) | 117 (idx 0) |
119 idx (1+ idx)) | 121 idx (1+ idx)) |
120 (modify-category-entry ch ?<))) | 122 (modify-category-entry ch ?<))) |
121 | 123 |
122 ;; Try to resolve `kinsoku' restriction by making the current line longer. | 124 ;; Try to resolve `kinsoku' restriction by making the current line longer. |
123 (defun kinsoku-longer () | 125 (defun kinsoku-longer () |
124 (let ((pos-and-column (save-excursion | 126 (let ((pos-and-column |
125 (forward-char 1) | 127 (save-excursion |
126 (while (aref (char-category-set (following-char)) ?>) | 128 (forward-char 1) |
127 (forward-char 1)) | 129 (while (and (not (eolp)) |
128 (cons (point) (current-column))))) | 130 (or (aref (char-category-set (following-char)) ?>) |
131 ;; protect non-kinsoku words | |
132 (not (or (eq (preceding-char) ? ) | |
133 (aref (char-category-set (preceding-char)) | |
134 ?|))))) | |
135 (forward-char 1)) | |
136 (cons (point) (current-column))))) | |
129 (if (or (<= kinsoku-limit 0) | 137 (if (or (<= kinsoku-limit 0) |
130 (< (cdr pos-and-column) (+ (current-fill-column) kinsoku-limit))) | 138 (< (cdr pos-and-column) (+ (current-fill-column) kinsoku-limit))) |
131 (goto-char (car pos-and-column))))) | 139 (goto-char (car pos-and-column))))) |
132 | 140 |
133 ;; Try to resolve `kinsoku' restriction by making the current line shorter. | 141 ;; Try to resolve `kinsoku' restriction by making the current line shorter. |
134 ;; The line can't be broken before the buffer position LINEBEG. | 142 ;; The line can't be broken before the buffer position LINEBEG. |
135 (defun kinsoku-shorter (linebeg) | 143 (defun kinsoku-shorter (linebeg) |
136 (let ((pos (save-excursion | 144 (let ((pos (save-excursion |
137 (forward-char -1) | 145 (forward-char -1) |
138 (while (and (< linebeg (point)) | 146 (while (and |
139 (or (aref (char-category-set (preceding-char)) ?<) | 147 (< linebeg (point)) |
140 (aref (char-category-set (following-char)) ?>))) | 148 (or (aref (char-category-set (preceding-char)) ?<) |
149 (aref (char-category-set (following-char)) ?>) | |
150 ;; protect non-kinsoku words | |
151 (not (or (eq (preceding-char) ? ) | |
152 (aref (char-category-set (preceding-char)) | |
153 ?|))))) | |
141 (forward-char -1)) | 154 (forward-char -1)) |
142 (point)))) | 155 (point)))) |
143 (if (< linebeg pos) | 156 (if (< linebeg pos) |
144 (goto-char pos)))) | 157 (goto-char pos)))) |
145 | 158 |
168 (not (kinsoku-longer))) | 181 (not (kinsoku-longer))) |
169 ;; The character before point can't be placed at end of line. | 182 ;; The character before point can't be placed at end of line. |
170 (aref (char-category-set (preceding-char)) ?<)) | 183 (aref (char-category-set (preceding-char)) ?<)) |
171 (kinsoku-shorter linebeg)))) | 184 (kinsoku-shorter linebeg)))) |
172 | 185 |
186 ;;; arch-tag: e6b036bc-9e5b-4e9f-a22c-4ed04e37777e | |
173 ;;; kinsoku.el ends here | 187 ;;; kinsoku.el ends here |