aboutsummaryrefslogtreecommitdiffstats
path: root/src/cmds.c
diff options
context:
space:
mode:
authorStefan Monnier2011-03-06 16:22:16 -0500
committerStefan Monnier2011-03-06 16:22:16 -0500
commit0d6459dfb52188481bfd6bb53f1b2f653ecd6a5d (patch)
tree306b87fc2903ad23343f3c84be1cccfa72e5a97e /src/cmds.c
parent798cb64441228d473f7bdd213183c70fb582595c (diff)
parent892777baa1739fa5f1f2d1c2975488c3e6f57bae (diff)
downloademacs-0d6459dfb52188481bfd6bb53f1b2f653ecd6a5d.tar.gz
emacs-0d6459dfb52188481bfd6bb53f1b2f653ecd6a5d.zip
Merge from trunk
Diffstat (limited to 'src/cmds.c')
-rw-r--r--src/cmds.c42
1 files changed, 23 insertions, 19 deletions
diff --git a/src/cmds.c b/src/cmds.c
index 336bf1154f9..5e6884c0807 100644
--- a/src/cmds.c
+++ b/src/cmds.c
@@ -381,33 +381,37 @@ internal_self_insert (int c, EMACS_INT n)
381 { 381 {
382 EMACS_INT pos = PT; 382 EMACS_INT pos = PT;
383 EMACS_INT pos_byte = PT_BYTE; 383 EMACS_INT pos_byte = PT_BYTE;
384
385 /* FIXME: Check for integer overflow when calculating
386 target_clm and actual_clm. */
387
384 /* Column the cursor should be placed at after this insertion. 388 /* Column the cursor should be placed at after this insertion.
385 The correct value should be calculated only when necessary. */ 389 The correct value should be calculated only when necessary. */
386 int target_clm = ((int) current_column () /* iftc */ 390 EMACS_INT target_clm = (current_column ()
387 + n * (int) XINT (Fchar_width (make_number (c)))); 391 + n * XINT (Fchar_width (make_number (c))));
388 392
389 /* The actual cursor position after the trial of moving 393 /* The actual cursor position after the trial of moving
390 to column TARGET_CLM. It is greater than TARGET_CLM 394 to column TARGET_CLM. It is greater than TARGET_CLM
391 if the TARGET_CLM is middle of multi-column 395 if the TARGET_CLM is middle of multi-column
392 character. In that case, the new point is set after 396 character. In that case, the new point is set after
393 that character. */ 397 that character. */
394 int actual_clm 398 EMACS_INT actual_clm
395 = (int) XFASTINT (Fmove_to_column (make_number (target_clm), 399 = XFASTINT (Fmove_to_column (make_number (target_clm), Qnil));
396 Qnil)); 400
397 401 chars_to_delete = PT - pos;
398 chars_to_delete = PT - pos; 402
399 403 if (actual_clm > target_clm)
400 if (actual_clm > target_clm) 404 {
401 { /* We will delete too many columns. Let's fill columns 405 /* We will delete too many columns. Let's fill columns
402 by spaces so that the remaining text won't move. */ 406 by spaces so that the remaining text won't move. */
403 EMACS_INT actual = PT_BYTE; 407 EMACS_INT actual = PT_BYTE;
404 DEC_POS (actual); 408 DEC_POS (actual);
405 if (FETCH_CHAR (actual) == '\t') 409 if (FETCH_CHAR (actual) == '\t')
406 /* Rather than add spaces, let's just keep the tab. */ 410 /* Rather than add spaces, let's just keep the tab. */
407 chars_to_delete--; 411 chars_to_delete--;
408 else 412 else
409 spaces_to_insert = actual_clm - target_clm; 413 spaces_to_insert = actual_clm - target_clm;
410 } 414 }
411 415
412 SET_PT_BOTH (pos, pos_byte); 416 SET_PT_BOTH (pos, pos_byte);
413 } 417 }