diff options
| author | Miles Bader | 2005-02-13 07:19:08 +0000 |
|---|---|---|
| committer | Miles Bader | 2005-02-13 07:19:08 +0000 |
| commit | dd75f82d04b1c7fb91fd3024021a3d7977154857 (patch) | |
| tree | 456488f67c9de7fec805140f39993e1e3bebac8f /src/undo.c | |
| parent | 3807ffd05dc6b10cef9066b4d3b49b24788313a9 (diff) | |
| parent | 9b981cb6861358a05a241509d73f2b8ea25c64ce (diff) | |
| download | emacs-dd75f82d04b1c7fb91fd3024021a3d7977154857.tar.gz emacs-dd75f82d04b1c7fb91fd3024021a3d7977154857.zip | |
Revision: miles@gnu.org--gnu-2005/emacs--unicode--0--patch-13
Merge from emacs--cvs-trunk--0
Patches applied:
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-83
- miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-89
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-90
Update from CVS: man/calc.texi: Add macro for LaTeX for info output.
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-91
- miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-94
Update from CVS
Diffstat (limited to 'src/undo.c')
| -rw-r--r-- | src/undo.c | 60 |
1 files changed, 45 insertions, 15 deletions
diff --git a/src/undo.c b/src/undo.c index eaf312be676..b4e16bfd0e5 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,24 +556,38 @@ 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; | 559 | /* Element (apply FUN . ARGS) means call FUN to undo. */ |
| 553 | /* Element (apply FUNNAME . ARGS) means call FUNNAME to undo. */ | 560 | struct buffer *save_buffer = current_buffer; |
| 561 | |||
| 554 | car = Fcar (cdr); | 562 | car = Fcar (cdr); |
| 563 | cdr = Fcdr (cdr); | ||
| 555 | if (INTEGERP (car)) | 564 | if (INTEGERP (car)) |
| 556 | { | 565 | { |
| 557 | /* Long format: (apply DELTA START END FUNNAME . ARGS). */ | 566 | /* Long format: (apply DELTA START END FUN . ARGS). */ |
| 558 | cdr = Fcdr (Fcdr (Fcdr (cdr))); | 567 | Lisp_Object delta = car; |
| 559 | car = Fcar (cdr); | 568 | Lisp_Object start = Fcar (cdr); |
| 569 | Lisp_Object end = Fcar (Fcdr (cdr)); | ||
| 570 | Lisp_Object start_mark = Fcopy_marker (start, Qnil); | ||
| 571 | Lisp_Object end_mark = Fcopy_marker (end, Qt); | ||
| 572 | |||
| 573 | cdr = Fcdr (Fcdr (cdr)); | ||
| 574 | apply1 (Fcar (cdr), Fcdr (cdr)); | ||
| 575 | |||
| 576 | /* Check that the function did what the entry said it | ||
| 577 | would do. */ | ||
| 578 | if (!EQ (start, Fmarker_position (start_mark)) | ||
| 579 | || (XINT (delta) + XINT (end) | ||
| 580 | != marker_position (end_mark))) | ||
| 581 | error ("Changes to be undone by function different than announced"); | ||
| 582 | Fset_marker (start_mark, Qnil, Qnil); | ||
| 583 | Fset_marker (end_mark, Qnil, Qnil); | ||
| 560 | } | 584 | } |
| 561 | cdr = Fcdr (cdr); | 585 | else |
| 562 | apply1 (car, cdr); | 586 | apply1 (car, cdr); |
| 563 | 587 | ||
| 564 | /* Make sure this produces at least one undo entry, | 588 | if (save_buffer != current_buffer) |
| 565 | so the test in `undo' for continuing an undo series | 589 | error ("Undo function switched buffer"); |
| 566 | will work right. */ | 590 | did_apply = 1; |
| 567 | if (EQ (oldlist, current_buffer->undo_list)) | ||
| 568 | current_buffer->undo_list | ||
| 569 | = Fcons (list3 (Qapply, Qcdr, Qnil), current_buffer->undo_list); | ||
| 570 | } | 591 | } |
| 571 | else if (STRINGP (car) && INTEGERP (cdr)) | 592 | else if (STRINGP (car) && INTEGERP (cdr)) |
| 572 | { | 593 | { |
| @@ -611,6 +632,15 @@ Return what remains of the list. */) | |||
| 611 | arg--; | 632 | arg--; |
| 612 | } | 633 | } |
| 613 | 634 | ||
| 635 | |||
| 636 | /* Make sure an apply entry produces at least one undo entry, | ||
| 637 | so the test in `undo' for continuing an undo series | ||
| 638 | will work right. */ | ||
| 639 | if (did_apply | ||
| 640 | && EQ (oldlist, current_buffer->undo_list)) | ||
| 641 | current_buffer->undo_list | ||
| 642 | = Fcons (list3 (Qapply, Qcdr, Qnil), current_buffer->undo_list); | ||
| 643 | |||
| 614 | UNGCPRO; | 644 | UNGCPRO; |
| 615 | return unbind_to (count, list); | 645 | return unbind_to (count, list); |
| 616 | } | 646 | } |