diff options
| author | Richard M. Stallman | 1997-07-15 19:22:53 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1997-07-15 19:22:53 +0000 |
| commit | e744155a80ab75b63876694a615f07d528e5da11 (patch) | |
| tree | e618612082464e4fe97f747fd9133423a550b1be /src/cmds.c | |
| parent | cda987f44864f8c11ee5a0405ae46c3fcf286761 (diff) | |
| download | emacs-e744155a80ab75b63876694a615f07d528e5da11.tar.gz emacs-e744155a80ab75b63876694a615f07d528e5da11.zip | |
(internal_self_insert): When overwriting, use replace_range.
Diffstat (limited to 'src/cmds.c')
| -rw-r--r-- | src/cmds.c | 39 |
1 files changed, 29 insertions, 10 deletions
diff --git a/src/cmds.c b/src/cmds.c index 68a6726dbb1..fac3791794f 100644 --- a/src/cmds.c +++ b/src/cmds.c | |||
| @@ -353,11 +353,13 @@ internal_self_insert (c, noautofill) | |||
| 353 | int hairy = 0; | 353 | int hairy = 0; |
| 354 | Lisp_Object tem; | 354 | Lisp_Object tem; |
| 355 | register enum syntaxcode synt; | 355 | register enum syntaxcode synt; |
| 356 | Lisp_Object overwrite; | 356 | Lisp_Object overwrite, string; |
| 357 | /* Length of multi-byte form of C. */ | 357 | /* Length of multi-byte form of C. */ |
| 358 | int len; | 358 | int len; |
| 359 | /* Working buffer and pointer for multi-byte form of C. */ | 359 | /* Working buffer and pointer for multi-byte form of C. */ |
| 360 | unsigned char workbuf[4], *str; | 360 | unsigned char workbuf[4], *str; |
| 361 | int number_to_delete = 0; | ||
| 362 | int spaces_to_insert = 0; | ||
| 361 | 363 | ||
| 362 | if (c >= 0200 && c <= 0377 | 364 | if (c >= 0200 && c <= 0377 |
| 363 | && ! NILP (current_buffer->enable_multibyte_characters)) | 365 | && ! NILP (current_buffer->enable_multibyte_characters)) |
| @@ -409,11 +411,12 @@ internal_self_insert (c, noautofill) | |||
| 409 | || XFASTINT (current_buffer->tab_width) > 20 | 411 | || XFASTINT (current_buffer->tab_width) > 20 |
| 410 | || !(target_clm % XFASTINT (current_buffer->tab_width)))))) | 412 | || !(target_clm % XFASTINT (current_buffer->tab_width)))))) |
| 411 | { | 413 | { |
| 414 | int pos = PT; | ||
| 415 | |||
| 412 | if (target_clm == 0) | 416 | if (target_clm == 0) |
| 413 | del_range (PT, forward_point (1)); | 417 | number_to_delete = forward_point (1) - PT; |
| 414 | else | 418 | else |
| 415 | { | 419 | { |
| 416 | int pos = PT; | ||
| 417 | /* The actual cursor position after the trial of moving | 420 | /* The actual cursor position after the trial of moving |
| 418 | to column TARGET_CLM. It is greater than TARGET_CLM | 421 | to column TARGET_CLM. It is greater than TARGET_CLM |
| 419 | if the TARGET_CLM is middle of multi-column | 422 | if the TARGET_CLM is middle of multi-column |
| @@ -422,15 +425,16 @@ internal_self_insert (c, noautofill) | |||
| 422 | int actual_clm | 425 | int actual_clm |
| 423 | = XFASTINT (Fmove_to_column (make_number (target_clm), Qnil)); | 426 | = XFASTINT (Fmove_to_column (make_number (target_clm), Qnil)); |
| 424 | 427 | ||
| 425 | del_range (pos, PT); | 428 | number_to_delete = PT - pos; |
| 429 | |||
| 426 | if (actual_clm > target_clm) | 430 | if (actual_clm > target_clm) |
| 427 | { | 431 | { |
| 428 | /* We deleted too many columns. Let's fill columns | 432 | /* We will delete too many columns. Let's fill columns |
| 429 | by spaces so that the remaining text won't move. */ | 433 | by spaces so that the remaining text won't move. */ |
| 430 | insert(" ", actual_clm - target_clm); | 434 | spaces_to_insert = actual_clm - target_clm; |
| 431 | SET_PT (pos); | ||
| 432 | } | 435 | } |
| 433 | } | 436 | } |
| 437 | SET_PT (pos); | ||
| 434 | hairy = 2; | 438 | hairy = 2; |
| 435 | } | 439 | } |
| 436 | hairy = 2; | 440 | hairy = 2; |
| @@ -460,13 +464,29 @@ internal_self_insert (c, noautofill) | |||
| 460 | if (MODIFF != modiff) | 464 | if (MODIFF != modiff) |
| 461 | hairy = 2; | 465 | hairy = 2; |
| 462 | } | 466 | } |
| 467 | |||
| 468 | if (number_to_delete) | ||
| 469 | { | ||
| 470 | string = make_string (str, len); | ||
| 471 | if (spaces_to_insert) | ||
| 472 | { | ||
| 473 | tem = Fmake_string (make_number (spaces_to_insert), | ||
| 474 | make_number (' ')); | ||
| 475 | string = concat2 (tem, string); | ||
| 476 | } | ||
| 477 | |||
| 478 | replace_range (PT, PT + number_to_delete, string, 1, 1); | ||
| 479 | SET_PT (PT + XSTRING (string)->size); | ||
| 480 | } | ||
| 481 | else | ||
| 482 | insert_and_inherit (str, len); | ||
| 483 | |||
| 463 | if ((c == ' ' || c == '\n') | 484 | if ((c == ' ' || c == '\n') |
| 464 | && !noautofill | 485 | && !noautofill |
| 465 | && !NILP (current_buffer->auto_fill_function)) | 486 | && !NILP (current_buffer->auto_fill_function)) |
| 466 | { | 487 | { |
| 467 | Lisp_Object tem; | 488 | Lisp_Object tem; |
| 468 | 489 | ||
| 469 | insert_and_inherit (str, len); | ||
| 470 | if (c == '\n') | 490 | if (c == '\n') |
| 471 | /* After inserting a newline, move to previous line and fill */ | 491 | /* After inserting a newline, move to previous line and fill */ |
| 472 | /* that. Must have the newline in place already so filling and */ | 492 | /* that. Must have the newline in place already so filling and */ |
| @@ -478,8 +498,6 @@ internal_self_insert (c, noautofill) | |||
| 478 | if (!NILP (tem)) | 498 | if (!NILP (tem)) |
| 479 | hairy = 2; | 499 | hairy = 2; |
| 480 | } | 500 | } |
| 481 | else | ||
| 482 | insert_and_inherit (str, len); | ||
| 483 | 501 | ||
| 484 | #ifdef HAVE_FACES | 502 | #ifdef HAVE_FACES |
| 485 | /* If previous command specified a face to use, use it. */ | 503 | /* If previous command specified a face to use, use it. */ |
| @@ -493,6 +511,7 @@ internal_self_insert (c, noautofill) | |||
| 493 | Vself_insert_face = Qnil; | 511 | Vself_insert_face = Qnil; |
| 494 | } | 512 | } |
| 495 | #endif | 513 | #endif |
| 514 | |||
| 496 | synt = SYNTAX (c); | 515 | synt = SYNTAX (c); |
| 497 | if ((synt == Sclose || synt == Smath) | 516 | if ((synt == Sclose || synt == Smath) |
| 498 | && !NILP (Vblink_paren_function) && INTERACTIVE | 517 | && !NILP (Vblink_paren_function) && INTERACTIVE |