diff options
Diffstat (limited to 'src/cmds.c')
| -rw-r--r-- | src/cmds.c | 60 |
1 files changed, 35 insertions, 25 deletions
diff --git a/src/cmds.c b/src/cmds.c index 270fc39cabc..168ce8355ed 100644 --- a/src/cmds.c +++ b/src/cmds.c @@ -213,6 +213,36 @@ to t. */) return Qnil; } +static int nonundocount; + +static void +remove_excessive_undo_boundaries (void) +{ + bool remove_boundary = true; + + if (!EQ (Vthis_command, KVAR (current_kboard, Vlast_command))) + nonundocount = 0; + + if (NILP (Vexecuting_kbd_macro)) + { + if (nonundocount <= 0 || nonundocount >= 20) + { + remove_boundary = false; + nonundocount = 0; + } + nonundocount++; + } + + if (remove_boundary + && CONSP (BVAR (current_buffer, undo_list)) + && NILP (XCAR (BVAR (current_buffer, undo_list))) + /* Only remove auto-added boundaries, not boundaries + added by explicit calls to undo-boundary. */ + && EQ (BVAR (current_buffer, undo_list), last_undo_boundary)) + /* Remove the undo_boundary that was just pushed. */ + bset_undo_list (current_buffer, XCDR (BVAR (current_buffer, undo_list))); +} + DEFUN ("delete-char", Fdelete_char, Sdelete_char, 1, 2, "p\nP", doc: /* Delete the following N characters (previous if N is negative). Optional second arg KILLFLAG non-nil means kill instead (save in kill ring). @@ -227,6 +257,9 @@ because it respects values of `delete-active-region' and `overwrite-mode'. */) CHECK_NUMBER (n); + if (abs (XINT (n)) < 2) + remove_excessive_undo_boundaries (); + pos = PT + XINT (n); if (NILP (killflag)) { @@ -252,8 +285,6 @@ because it respects values of `delete-active-region' and `overwrite-mode'. */) return Qnil; } -static int nonundocount; - /* Note that there's code in command_loop_1 which typically avoids calling this. */ DEFUN ("self-insert-command", Fself_insert_command, Sself_insert_command, 1, 1, "p", @@ -267,34 +298,13 @@ After insertion, the value of `auto-fill-function' is called if the At the end, it runs `post-self-insert-hook'. */) (Lisp_Object n) { - bool remove_boundary = 1; CHECK_NUMBER (n); if (XFASTINT (n) < 0) error ("Negative repetition argument %"pI"d", XFASTINT (n)); - if (!EQ (Vthis_command, KVAR (current_kboard, Vlast_command))) - nonundocount = 0; - - if (NILP (Vexecuting_kbd_macro) - && !EQ (minibuf_window, selected_window)) - { - if (nonundocount <= 0 || nonundocount >= 20) - { - remove_boundary = 0; - nonundocount = 0; - } - nonundocount++; - } - - if (remove_boundary - && CONSP (BVAR (current_buffer, undo_list)) - && NILP (XCAR (BVAR (current_buffer, undo_list))) - /* Only remove auto-added boundaries, not boundaries - added be explicit calls to undo-boundary. */ - && EQ (BVAR (current_buffer, undo_list), last_undo_boundary)) - /* Remove the undo_boundary that was just pushed. */ - bset_undo_list (current_buffer, XCDR (BVAR (current_buffer, undo_list))); + if (XFASTINT (n) < 2) + remove_excessive_undo_boundaries (); /* Barf if the key that invoked this was not a character. */ if (!CHARACTERP (last_command_event)) |
