Commit 1ac9108a authored by Stefan Monnier's avatar Stefan Monnier

* cmds.c (nonundocount): New global variable.

(keys_of_cmds): Initialize it.
(Fself_insert_command): Use it to combine upto 20 sequential chars
into a single undo entry, just like the Qself_insert_command code in
keyboard.c does.
Call frame_make_pointer_invisible, also like the Qself_insert_command
code in keyboard.c does.
* keyboard.c (command_loop_1): Use the new global nonundocount rather
than its own local replacement for it.
parent cf6e27cf
This diff is collapsed.
......@@ -315,15 +315,42 @@ N was explicitly specified. */)
return value;
}
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",
doc: /* Insert the character you type.
Whichever character you type to run this command is inserted. */)
Whichever character you type to run this command is inserted.
Before insertion, `expand-abbrev' is executed if the inserted character does
not have word syntax and the previous character in the buffer does.
After insertion, the value of `auto-fill-function' is called if the
`auto-fill-chars' table has a non-nil value for the inserted character. */)
(n)
Lisp_Object n;
{
CHECK_NUMBER (n);
int remove_boundary = 1;
if (!EQ (Vthis_command, 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 (current_buffer->undo_list)
&& NILP (XCAR (current_buffer->undo_list)))
/* Remove the undo_boundary that was just pushed. */
current_buffer->undo_list = XCDR (current_buffer->undo_list);
/* Barf if the key that invoked this was not a character. */
if (!CHARACTERP (last_command_event))
......@@ -353,9 +380,13 @@ Whichever character you type to run this command is inserted. */)
else
while (XINT (n) > 0)
{
int val;
/* Ok since old and new vals both nonneg */
XSETFASTINT (n, XFASTINT (n) - 1);
internal_self_insert (character, XFASTINT (n) != 0);
val = internal_self_insert (character, XFASTINT (n) != 0);
if (val == 2)
nonundocount = 0;
frame_make_pointer_invisible ();
}
}
......@@ -611,6 +642,7 @@ keys_of_cmds ()
{
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");
......
......@@ -1519,12 +1519,13 @@ cancel_hourglass_unwind (arg)
}
#endif
extern int nonundocount; /* Declared in cmds.c. */
Lisp_Object
command_loop_1 ()
{
Lisp_Object cmd;
int lose;
int nonundocount;
Lisp_Object keybuf[30];
int i;
int prev_modiff = 0;
......@@ -1540,7 +1541,6 @@ command_loop_1 ()
waiting_for_input = 0;
cancel_echoing ();
nonundocount = 0;
this_command_key_count = 0;
this_command_key_count_reset = 0;
this_single_command_key_start = 0;
......@@ -1898,7 +1898,7 @@ command_loop_1 ()
#endif
nonundocount = 0;
if (NILP (current_kboard->Vprefix_arg))
if (NILP (current_kboard->Vprefix_arg)) /* FIXME: Why? --Stef */
Fundo_boundary ();
Fcommand_execute (Vthis_command, Qnil, Qnil, Qnil);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment