diff options
| author | Richard M. Stallman | 1997-05-16 08:08:49 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1997-05-16 08:08:49 +0000 |
| commit | a22ca1e0d0efd52996d5554fa328e02a7a66d863 (patch) | |
| tree | 8b860a4a4e01f04484ae9138f1e33dd904635931 /src/cmds.c | |
| parent | cd82f42fe24d5c4c57319bd86cb9f36aafd2ff5a (diff) | |
| download | emacs-a22ca1e0d0efd52996d5554fa328e02a7a66d863.tar.gz emacs-a22ca1e0d0efd52996d5554fa328e02a7a66d863.zip | |
(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.c | 32 |
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; | |||
| 39 | /* This is the command that set up Vself_insert_face. */ | 39 | /* This is the command that set up Vself_insert_face. */ |
| 40 | Lisp_Object Vself_insert_face_command; | 40 | Lisp_Object Vself_insert_face_command; |
| 41 | 41 | ||
| 42 | /* Offset to add to a non-ASCII value when inserting it. */ | ||
| 43 | int nonascii_insert_offset; | ||
| 44 | |||
| 42 | extern Lisp_Object Qface; | 45 | extern Lisp_Object Qface; |
| 43 | 46 | ||
| 44 | /* Return buffer position which is N characters after `point'. */ | 47 | /* Return buffer position which is N characters after `point'. */ |
| @@ -297,6 +300,8 @@ Whichever character you type to run this command is inserted.") | |||
| 297 | (n) | 300 | (n) |
| 298 | Lisp_Object n; | 301 | Lisp_Object n; |
| 299 | { | 302 | { |
| 303 | int character = XINT (last_command_char); | ||
| 304 | |||
| 300 | CHECK_NUMBER (n, 0); | 305 | CHECK_NUMBER (n, 0); |
| 301 | 306 | ||
| 302 | /* Barf if the key that invoked this was not a character. */ | 307 | /* 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.") | |||
| 304 | bitch_at_user (); | 309 | bitch_at_user (); |
| 305 | else if (XINT (n) >= 2 && NILP (current_buffer->overwrite_mode)) | 310 | else if (XINT (n) >= 2 && NILP (current_buffer->overwrite_mode)) |
| 306 | { | 311 | { |
| 312 | int modified_char = character; | ||
| 313 | /* Add the offset to the character, for Finsert_char. | ||
| 314 | We pass internal_self_insert the unmodified character | ||
| 315 | because it itself does this offsetting. */ | ||
| 316 | if (modified_char >= 0200 && modified_char <= 0377 | ||
| 317 | && ! NILP (current_buffer->enable_multibyte_characters)) | ||
| 318 | modified_char += nonascii_insert_offset; | ||
| 319 | |||
| 307 | XSETFASTINT (n, XFASTINT (n) - 2); | 320 | XSETFASTINT (n, XFASTINT (n) - 2); |
| 308 | /* The first one might want to expand an abbrev. */ | 321 | /* The first one might want to expand an abbrev. */ |
| 309 | internal_self_insert (XINT (last_command_char), 1); | 322 | internal_self_insert (character, 1); |
| 310 | /* The bulk of the copies of this char can be inserted simply. | 323 | /* The bulk of the copies of this char can be inserted simply. |
| 311 | We don't have to handle a user-specified face specially | 324 | We don't have to handle a user-specified face specially |
| 312 | because it will get inherited from the first char inserted. */ | 325 | because it will get inherited from the first char inserted. */ |
| 313 | Finsert_char (last_command_char, n, Qt); | 326 | Finsert_char (make_number (modified_char), n, Qt); |
| 314 | /* The last one might want to auto-fill. */ | 327 | /* The last one might want to auto-fill. */ |
| 315 | internal_self_insert (XINT (last_command_char), 0); | 328 | internal_self_insert (character, 0); |
| 316 | } | 329 | } |
| 317 | else | 330 | else |
| 318 | while (XINT (n) > 0) | 331 | while (XINT (n) > 0) |
| 319 | { | 332 | { |
| 320 | /* Ok since old and new vals both nonneg */ | 333 | /* Ok since old and new vals both nonneg */ |
| 321 | XSETFASTINT (n, XFASTINT (n) - 1); | 334 | XSETFASTINT (n, XFASTINT (n) - 1); |
| 322 | internal_self_insert (XINT (last_command_char), XFASTINT (n) != 0); | 335 | internal_self_insert (character, XFASTINT (n) != 0); |
| 323 | } | 336 | } |
| 324 | 337 | ||
| 325 | return Qnil; | 338 | return Qnil; |
| @@ -346,6 +359,10 @@ internal_self_insert (c, noautofill) | |||
| 346 | /* Working buffer and pointer for multi-byte form of C. */ | 359 | /* Working buffer and pointer for multi-byte form of C. */ |
| 347 | unsigned char workbuf[4], *str; | 360 | unsigned char workbuf[4], *str; |
| 348 | 361 | ||
| 362 | if (c >= 0200 && c <= 0377 | ||
| 363 | && ! NILP (current_buffer->enable_multibyte_characters)) | ||
| 364 | c += nonascii_insert_offset; | ||
| 365 | |||
| 349 | overwrite = current_buffer->overwrite_mode; | 366 | overwrite = current_buffer->overwrite_mode; |
| 350 | if (!NILP (Vbefore_change_function) || !NILP (Vafter_change_function) | 367 | if (!NILP (Vbefore_change_function) || !NILP (Vafter_change_function) |
| 351 | || !NILP (Vbefore_change_functions) || !NILP (Vafter_change_functions)) | 368 | || !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'."); | |||
| 514 | More precisely, a char with closeparen syntax is self-inserted."); | 531 | More precisely, a char with closeparen syntax is self-inserted."); |
| 515 | Vblink_paren_function = Qnil; | 532 | Vblink_paren_function = Qnil; |
| 516 | 533 | ||
| 534 | DEFVAR_INT ("nonascii-insert-offset", &nonascii_insert_offset, | ||
| 535 | "Offset to add to a non-ascii code 0200...0377 when inserting it.\n\ | ||
| 536 | This applies only when multibyte characters are enabled, and it serves\n\ | ||
| 537 | to convert a Latin-1 or similar 8-bit character code to the corresponding\n\ | ||
| 538 | Emacs character code."); | ||
| 539 | nonascii_insert_offset = 0; | ||
| 540 | |||
| 517 | defsubr (&Sforward_point); | 541 | defsubr (&Sforward_point); |
| 518 | defsubr (&Sforward_char); | 542 | defsubr (&Sforward_char); |
| 519 | defsubr (&Sbackward_char); | 543 | defsubr (&Sbackward_char); |