aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1998-02-12 05:20:33 +0000
committerRichard M. Stallman1998-02-12 05:20:33 +0000
commit4cf9710d502cb9889ca496bbc3d69156551d56ca (patch)
tree595214cb285b428d3868cf7271d000400b81d1fb
parent2c3af3383d981c04cc45a2a7105343ce9a269eef (diff)
downloademacs-4cf9710d502cb9889ca496bbc3d69156551d56ca.tar.gz
emacs-4cf9710d502cb9889ca496bbc3d69156551d56ca.zip
(Vnonascii_translate_table): New variable.
(unibyte_char_to_multibyte): Use Vnonascii_translate_table. (syms_of_charset): Defvar it.
-rw-r--r--src/charset.c33
1 files changed, 26 insertions, 7 deletions
diff --git a/src/charset.c b/src/charset.c
index 1dc6e0aebdc..c7aaca185b1 100644
--- a/src/charset.c
+++ b/src/charset.c
@@ -101,6 +101,10 @@ int _fetch_multibyte_char_len;
101/* Offset to add to a non-ASCII value when inserting it. */ 101/* Offset to add to a non-ASCII value when inserting it. */
102int nonascii_insert_offset; 102int nonascii_insert_offset;
103 103
104/* Translation table for converting non-ASCII unibyte characters
105 to multibyte codes, or nil. */
106Lisp_Object Vnonascii_translate_table;
107
104#define min(X, Y) ((X) < (Y) ? (X) : (Y)) 108#define min(X, Y) ((X) < (Y) ? (X) : (Y))
105#define max(X, Y) ((X) > (Y) ? (X) : (Y)) 109#define max(X, Y) ((X) > (Y) ? (X) : (Y))
106 110
@@ -277,8 +281,8 @@ unify_char (table, c, charset, c1, c2)
277#define DEFAULT_NONASCII_INSERT_OFFSET 0x800 281#define DEFAULT_NONASCII_INSERT_OFFSET 0x800
278 282
279/* Convert the unibyte character C to multibyte 283/* Convert the unibyte character C to multibyte
280 based on nonascii_insert_offset. Note that copy_text in insdel.c 284 based on Vnonascii_translate_table or nonascii_insert_offset.
281 has similar code. */ 285 Note that copy_text in insdel.c has similar code. */
282 286
283int 287int
284unibyte_char_to_multibyte (c) 288unibyte_char_to_multibyte (c)
@@ -286,7 +290,9 @@ unibyte_char_to_multibyte (c)
286{ 290{
287 if (c >= 0200 && c < 0400) 291 if (c >= 0200 && c < 0400)
288 { 292 {
289 if (nonascii_insert_offset > 0) 293 if (! NILP (Vnonascii_translate_table))
294 c = XINT (Faref (Vnonascii_translate_table, make_number (c)));
295 else if (nonascii_insert_offset > 0)
290 c += nonascii_insert_offset; 296 c += nonascii_insert_offset;
291 else 297 else
292 c += DEFAULT_NONASCII_INSERT_OFFSET; 298 c += DEFAULT_NONASCII_INSERT_OFFSET;
@@ -1702,12 +1708,25 @@ An ID of a unification table is an index of this vector.");
1702 leading_code_private_22 = LEADING_CODE_PRIVATE_22; 1708 leading_code_private_22 = LEADING_CODE_PRIVATE_22;
1703 1709
1704 DEFVAR_INT ("nonascii-insert-offset", &nonascii_insert_offset, 1710 DEFVAR_INT ("nonascii-insert-offset", &nonascii_insert_offset,
1705 "Offset to add to a non-ascii code 0200...0377 when inserting it.\n\ 1711 "Offset for converting non-ASCII unibyte codes 0200...0377 to multibyte.\n\
1706This applies only when multibyte characters are enabled, and it serves\n\ 1712This is used for converting unibyte text to multibyte,\n\
1707to convert a Latin-1 or similar 8-bit character code to the corresponding\n\ 1713and for inserting character codes specified by number.\n\n\
1708Emacs character code."); 1714Conversion is performed only when multibyte characters are enabled,\n\
1715and it serves to convert a Latin-1 or similar 8-bit character code\n\
1716to the corresponding Emacs character code.\n\
1717If `nonascii-translate-table' is non-nil, it overrides this variable.");
1709 nonascii_insert_offset = 0; 1718 nonascii_insert_offset = 0;
1710 1719
1720 DEFVAR_LISP ("nonascii-translate-table", &Vnonascii_translate_table,
1721 "Translate table for converting non-ASCII unibyte codes to multibyte.\n\
1722This is used for converting unibyte text to multibyte,\n\
1723and for inserting character codes specified by number.\n\n\
1724Conversion is performed only when multibyte characters are enabled,\n\
1725and it serves to convert a Latin-1 or similar 8-bit character code\n\
1726to the corresponding Emacs character code.\n\n\
1727If this is nil, `nonascii-insert-offset' is used instead.");
1728 Vnonascii_translate_table = Qnil;
1729
1711 DEFVAR_INT ("min-composite-char", &min_composite_char, 1730 DEFVAR_INT ("min-composite-char", &min_composite_char,
1712 "Minimum character code of a composite character."); 1731 "Minimum character code of a composite character.");
1713 min_composite_char = MIN_CHAR_COMPOSITION; 1732 min_composite_char = MIN_CHAR_COMPOSITION;