summaryrefslogtreecommitdiff
path: root/src/cmds.c
diff options
context:
space:
mode:
authorPhillip Lord <phillip.lord@newcastle.ac.uk>2015-08-06 21:33:58 +0100
committerPhillip Lord <phillip.lord@russet.org.uk>2015-11-12 21:06:05 +0000
commit44dfa86b7d382b84564d68472da1448d08f48129 (patch)
tree778e2228ec90a4401b2be6cd7b258ee44a212b26 /src/cmds.c
parent0aec2aaccd8b745fa7214f3edd453c04a04bfba4 (diff)
downloademacs-44dfa86b7d382b84564d68472da1448d08f48129.tar.gz
The heuristic that Emacs uses to add an `undo-boundary' has been
reworked, as it interacts poorly with functions on `post-command-hook' or `after-change-functions'. * lisp/simple.el: New section added. * src/cmds.c (remove_excessive_undo_boundaries): Now in lisp. (self_insert_command): Calls simple.el to amalgamate. (delete_char): Calls simple.el to amalgamate. * src/keyboard.c (last_undo_boundary): Removed. * src/undo.c (run_undoable_change): New function.
Diffstat (limited to 'src/cmds.c')
-rw-r--r--src/cmds.c41
1 files changed, 7 insertions, 34 deletions
diff --git a/src/cmds.c b/src/cmds.c
index a975a8ed4e0..6f19a046893 100644
--- a/src/cmds.c
+++ b/src/cmds.c
@@ -220,36 +220,6 @@ 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).
@@ -265,7 +235,7 @@ because it respects values of `delete-active-region' and `overwrite-mode'. */)
CHECK_NUMBER (n);
if (abs (XINT (n)) < 2)
- remove_excessive_undo_boundaries ();
+ call0 (Qundo_auto__amalgamate);
pos = PT + XINT (n);
if (NILP (killflag))
@@ -311,7 +281,7 @@ At the end, it runs `post-self-insert-hook'. */)
error ("Negative repetition argument %"pI"d", XFASTINT (n));
if (XFASTINT (n) < 2)
- remove_excessive_undo_boundaries ();
+ call0 (Qundo_auto__amalgamate);
/* Barf if the key that invoked this was not a character. */
if (!CHARACTERP (last_command_event))
@@ -321,7 +291,7 @@ At the end, it runs `post-self-insert-hook'. */)
XINT (last_command_event));
int val = internal_self_insert (character, XFASTINT (n));
if (val == 2)
- nonundocount = 0;
+ Fset (Qundo_auto__this_command_amalgamating, Qnil);
frame_make_pointer_invisible (SELECTED_FRAME ());
}
@@ -526,6 +496,10 @@ internal_self_insert (int c, EMACS_INT n)
void
syms_of_cmds (void)
{
+ DEFSYM (Qundo_auto__amalgamate, "undo-auto--amalgamate");
+ DEFSYM (Qundo_auto__this_command_amalgamating,
+ "undo-auto--this-command-amalgamating");
+
DEFSYM (Qkill_forward_chars, "kill-forward-chars");
/* A possible value for a buffer's overwrite-mode variable. */
@@ -555,7 +529,6 @@ keys_of_cmds (void)
{
int n;
- nonundocount = 0;
initial_define_key (global_map, Ctl ('I'), "self-insert-command");
for (n = 040; n < 0177; n++)
initial_define_key (global_map, n, "self-insert-command");