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
commita22ca1e0d0efd52996d5554fa328e02a7a66d863 (patch)
tree8b860a4a4e01f04484ae9138f1e33dd904635931 /src/cmds.c
parentcd82f42fe24d5c4c57319bd86cb9f36aafd2ff5a (diff)
downloademacs-a22ca1e0d0efd52996d5554fa328e02a7a66d863.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);