summaryrefslogtreecommitdiff
path: root/src/cmds.c
diff options
context:
space:
mode:
authorRichard M. Stallman <rms@gnu.org>1997-05-16 08:08:49 +0000
committerRichard M. Stallman <rms@gnu.org>1997-05-16 08:08:49 +0000
commit3acc45c3644711fc93afd1cd68fc6c4873692a3f (patch)
treed2d8c139b1fdff1a5988d087b791a4bf1da53706 /src/cmds.c
parentc497a01eb2990ca2c87475569984fa6e5060ae6d (diff)
downloademacs-3acc45c3644711fc93afd1cd68fc6c4873692a3f.tar.gz
(nonascii_insert_offset): New variable.
(Fself_insert_command, internal_self_insert): Add nonascii_insert_offset to what we insert, when appropriate. (syms_of_cmds): Set up Lisp variable.
Diffstat (limited to 'src/cmds.c')
-rw-r--r--src/cmds.c32
1 files changed, 28 insertions, 4 deletions
diff --git a/src/cmds.c b/src/cmds.c
index 77a4114acff..8b51e69de48 100644
--- a/src/cmds.c
+++ b/src/cmds.c
@@ -39,6 +39,9 @@ Lisp_Object Vself_insert_face;
/* This is the command that set up Vself_insert_face. */
Lisp_Object Vself_insert_face_command;
+/* Offset to add to a non-ASCII value when inserting it. */
+int nonascii_insert_offset;
+
extern Lisp_Object Qface;
/* Return buffer position which is N characters after `point'. */
@@ -297,6 +300,8 @@ Whichever character you type to run this command is inserted.")
(n)
Lisp_Object n;
{
+ int character = XINT (last_command_char);
+
CHECK_NUMBER (n, 0);
/* Barf if the key that invoked this was not a character. */
@@ -304,22 +309,30 @@ Whichever character you type to run this command is inserted.")
bitch_at_user ();
else if (XINT (n) >= 2 && NILP (current_buffer->overwrite_mode))
{
+ int modified_char = character;
+ /* Add the offset to the character, for Finsert_char.
+ We pass internal_self_insert the unmodified character
+ because it itself does this offsetting. */
+ if (modified_char >= 0200 && modified_char <= 0377
+ && ! NILP (current_buffer->enable_multibyte_characters))
+ modified_char += nonascii_insert_offset;
+
XSETFASTINT (n, XFASTINT (n) - 2);
/* The first one might want to expand an abbrev. */
- internal_self_insert (XINT (last_command_char), 1);
+ internal_self_insert (character, 1);
/* The bulk of the copies of this char can be inserted simply.
We don't have to handle a user-specified face specially
because it will get inherited from the first char inserted. */
- Finsert_char (last_command_char, n, Qt);
+ Finsert_char (make_number (modified_char), n, Qt);
/* The last one might want to auto-fill. */
- internal_self_insert (XINT (last_command_char), 0);
+ internal_self_insert (character, 0);
}
else
while (XINT (n) > 0)
{
/* Ok since old and new vals both nonneg */
XSETFASTINT (n, XFASTINT (n) - 1);
- internal_self_insert (XINT (last_command_char), XFASTINT (n) != 0);
+ internal_self_insert (character, XFASTINT (n) != 0);
}
return Qnil;
@@ -346,6 +359,10 @@ internal_self_insert (c, noautofill)
/* Working buffer and pointer for multi-byte form of C. */
unsigned char workbuf[4], *str;
+ if (c >= 0200 && c <= 0377
+ && ! NILP (current_buffer->enable_multibyte_characters))
+ c += nonascii_insert_offset;
+
overwrite = current_buffer->overwrite_mode;
if (!NILP (Vbefore_change_function) || !NILP (Vafter_change_function)
|| !NILP (Vbefore_change_functions) || !NILP (Vafter_change_functions))
@@ -514,6 +531,13 @@ If `last-command' does not equal this value, we ignore `self-insert-face'.");
More precisely, a char with closeparen syntax is self-inserted.");
Vblink_paren_function = Qnil;
+ DEFVAR_INT ("nonascii-insert-offset", &nonascii_insert_offset,
+ "Offset to add to a non-ascii code 0200...0377 when inserting it.\n\
+This applies only when multibyte characters are enabled, and it serves\n\
+to convert a Latin-1 or similar 8-bit character code to the corresponding\n\
+Emacs character code.");
+ nonascii_insert_offset = 0;
+
defsubr (&Sforward_point);
defsubr (&Sforward_char);
defsubr (&Sbackward_char);