diff options
| author | Kim F. Storm | 2005-02-07 11:44:00 +0000 |
|---|---|---|
| committer | Kim F. Storm | 2005-02-07 11:44:00 +0000 |
| commit | 4ac03187067e06eaddc7277e63e95e63aacaea24 (patch) | |
| tree | 1e75063169eab5725b6dc0d0827e6912f46b1a92 /src/undo.c | |
| parent | 140281f6219a8b22136afcbef904ef4812e428e0 (diff) | |
| download | emacs-4ac03187067e06eaddc7277e63e95e63aacaea24.tar.gz emacs-4ac03187067e06eaddc7277e63e95e63aacaea24.zip | |
(Fprimitive_undo): Record max one dummmy apply element.
Diffstat (limited to 'src/undo.c')
| -rw-r--r-- | src/undo.c | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/src/undo.c b/src/undo.c index eaf312be676..5483060eb48 100644 --- a/src/undo.c +++ b/src/undo.c | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | /* undo handling for GNU Emacs. | 1 | /* undo handling for GNU Emacs. |
| 2 | Copyright (C) 1990, 1993, 1994, 2000 Free Software Foundation, Inc. | 2 | Copyright (C) 1990, 1993, 1994, 2000, 2002, 2004, 2005 |
| 3 | Free Software Foundation, Inc. | ||
| 3 | 4 | ||
| 4 | This file is part of GNU Emacs. | 5 | This file is part of GNU Emacs. |
| 5 | 6 | ||
| @@ -454,6 +455,8 @@ Return what remains of the list. */) | |||
| 454 | Lisp_Object next; | 455 | Lisp_Object next; |
| 455 | int count = SPECPDL_INDEX (); | 456 | int count = SPECPDL_INDEX (); |
| 456 | register int arg; | 457 | register int arg; |
| 458 | Lisp_Object oldlist; | ||
| 459 | int did_apply = 0; | ||
| 457 | 460 | ||
| 458 | #if 0 /* This is a good feature, but would make undo-start | 461 | #if 0 /* This is a good feature, but would make undo-start |
| 459 | unable to do what is expected. */ | 462 | unable to do what is expected. */ |
| @@ -470,6 +473,8 @@ Return what remains of the list. */) | |||
| 470 | arg = XINT (n); | 473 | arg = XINT (n); |
| 471 | next = Qnil; | 474 | next = Qnil; |
| 472 | GCPRO2 (next, list); | 475 | GCPRO2 (next, list); |
| 476 | /* I don't think we need to gcpro oldlist, as we use it only | ||
| 477 | to check for EQ. ++kfs */ | ||
| 473 | 478 | ||
| 474 | /* In a writable buffer, enable undoing read-only text that is so | 479 | /* In a writable buffer, enable undoing read-only text that is so |
| 475 | because of text properties. */ | 480 | because of text properties. */ |
| @@ -479,6 +484,8 @@ Return what remains of the list. */) | |||
| 479 | /* Don't let `intangible' properties interfere with undo. */ | 484 | /* Don't let `intangible' properties interfere with undo. */ |
| 480 | specbind (Qinhibit_point_motion_hooks, Qt); | 485 | specbind (Qinhibit_point_motion_hooks, Qt); |
| 481 | 486 | ||
| 487 | oldlist = current_buffer->undo_list; | ||
| 488 | |||
| 482 | while (arg > 0) | 489 | while (arg > 0) |
| 483 | { | 490 | { |
| 484 | while (CONSP (list)) | 491 | while (CONSP (list)) |
| @@ -549,7 +556,6 @@ Return what remains of the list. */) | |||
| 549 | } | 556 | } |
| 550 | else if (EQ (car, Qapply)) | 557 | else if (EQ (car, Qapply)) |
| 551 | { | 558 | { |
| 552 | Lisp_Object oldlist = current_buffer->undo_list; | ||
| 553 | /* Element (apply FUNNAME . ARGS) means call FUNNAME to undo. */ | 559 | /* Element (apply FUNNAME . ARGS) means call FUNNAME to undo. */ |
| 554 | car = Fcar (cdr); | 560 | car = Fcar (cdr); |
| 555 | if (INTEGERP (car)) | 561 | if (INTEGERP (car)) |
| @@ -560,13 +566,7 @@ Return what remains of the list. */) | |||
| 560 | } | 566 | } |
| 561 | cdr = Fcdr (cdr); | 567 | cdr = Fcdr (cdr); |
| 562 | apply1 (car, cdr); | 568 | apply1 (car, cdr); |
| 563 | 569 | did_apply = 1; | |
| 564 | /* Make sure this produces at least one undo entry, | ||
| 565 | so the test in `undo' for continuing an undo series | ||
| 566 | will work right. */ | ||
| 567 | if (EQ (oldlist, current_buffer->undo_list)) | ||
| 568 | current_buffer->undo_list | ||
| 569 | = Fcons (list3 (Qapply, Qcdr, Qnil), current_buffer->undo_list); | ||
| 570 | } | 570 | } |
| 571 | else if (STRINGP (car) && INTEGERP (cdr)) | 571 | else if (STRINGP (car) && INTEGERP (cdr)) |
| 572 | { | 572 | { |
| @@ -611,6 +611,15 @@ Return what remains of the list. */) | |||
| 611 | arg--; | 611 | arg--; |
| 612 | } | 612 | } |
| 613 | 613 | ||
| 614 | |||
| 615 | /* Make sure an apply entry produces at least one undo entry, | ||
| 616 | so the test in `undo' for continuing an undo series | ||
| 617 | will work right. */ | ||
| 618 | if (did_apply | ||
| 619 | && EQ (oldlist, current_buffer->undo_list)) | ||
| 620 | current_buffer->undo_list | ||
| 621 | = Fcons (list3 (Qapply, Qcdr, Qnil), current_buffer->undo_list); | ||
| 622 | |||
| 614 | UNGCPRO; | 623 | UNGCPRO; |
| 615 | return unbind_to (count, list); | 624 | return unbind_to (count, list); |
| 616 | } | 625 | } |