aboutsummaryrefslogtreecommitdiffstats
path: root/src/cmds.c
diff options
context:
space:
mode:
authorStefan Monnier2009-08-12 05:07:48 +0000
committerStefan Monnier2009-08-12 05:07:48 +0000
commit1ac9108a3d6f91efbf9dc479af92d0f46faf30a7 (patch)
treec239abeed9573b080ab721c44a1afd11705b4177 /src/cmds.c
parentcf6e27cf471ef190f74f84659fcea68b38218656 (diff)
downloademacs-1ac9108a3d6f91efbf9dc479af92d0f46faf30a7.tar.gz
emacs-1ac9108a3d6f91efbf9dc479af92d0f46faf30a7.zip
* 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.
Diffstat (limited to 'src/cmds.c')
-rw-r--r--src/cmds.c36
1 files changed, 34 insertions, 2 deletions
diff --git a/src/cmds.c b/src/cmds.c
index 33472b5710b..c66db7a3f11 100644
--- a/src/cmds.c
+++ b/src/cmds.c
@@ -315,15 +315,42 @@ N was explicitly specified. */)
315 return value; 315 return value;
316} 316}
317 317
318int nonundocount;
319
318/* Note that there's code in command_loop_1 which typically avoids 320/* Note that there's code in command_loop_1 which typically avoids
319 calling this. */ 321 calling this. */
320DEFUN ("self-insert-command", Fself_insert_command, Sself_insert_command, 1, 1, "p", 322DEFUN ("self-insert-command", Fself_insert_command, Sself_insert_command, 1, 1, "p",
321 doc: /* Insert the character you type. 323 doc: /* Insert the character you type.
322Whichever character you type to run this command is inserted. */) 324Whichever character you type to run this command is inserted.
325Before insertion, `expand-abbrev' is executed if the inserted character does
326not have word syntax and the previous character in the buffer does.
327After insertion, the value of `auto-fill-function' is called if the
328`auto-fill-chars' table has a non-nil value for the inserted character. */)
323 (n) 329 (n)
324 Lisp_Object n; 330 Lisp_Object n;
325{ 331{
326 CHECK_NUMBER (n); 332 CHECK_NUMBER (n);
333 int remove_boundary = 1;
334
335 if (!EQ (Vthis_command, current_kboard->Vlast_command))
336 nonundocount = 0;
337
338 if (NILP (Vexecuting_kbd_macro)
339 && !EQ (minibuf_window, selected_window))
340 {
341 if (nonundocount <= 0 || nonundocount >= 20)
342 {
343 remove_boundary = 0;
344 nonundocount = 0;
345 }
346 nonundocount++;
347 }
348
349 if (remove_boundary
350 && CONSP (current_buffer->undo_list)
351 && NILP (XCAR (current_buffer->undo_list)))
352 /* Remove the undo_boundary that was just pushed. */
353 current_buffer->undo_list = XCDR (current_buffer->undo_list);
327 354
328 /* Barf if the key that invoked this was not a character. */ 355 /* Barf if the key that invoked this was not a character. */
329 if (!CHARACTERP (last_command_event)) 356 if (!CHARACTERP (last_command_event))
@@ -353,9 +380,13 @@ Whichever character you type to run this command is inserted. */)
353 else 380 else
354 while (XINT (n) > 0) 381 while (XINT (n) > 0)
355 { 382 {
383 int val;
356 /* Ok since old and new vals both nonneg */ 384 /* Ok since old and new vals both nonneg */
357 XSETFASTINT (n, XFASTINT (n) - 1); 385 XSETFASTINT (n, XFASTINT (n) - 1);
358 internal_self_insert (character, XFASTINT (n) != 0); 386 val = internal_self_insert (character, XFASTINT (n) != 0);
387 if (val == 2)
388 nonundocount = 0;
389 frame_make_pointer_invisible ();
359 } 390 }
360 } 391 }
361 392
@@ -611,6 +642,7 @@ keys_of_cmds ()
611{ 642{
612 int n; 643 int n;
613 644
645 nonundocount = 0;
614 initial_define_key (global_map, Ctl ('I'), "self-insert-command"); 646 initial_define_key (global_map, Ctl ('I'), "self-insert-command");
615 for (n = 040; n < 0177; n++) 647 for (n = 040; n < 0177; n++)
616 initial_define_key (global_map, n, "self-insert-command"); 648 initial_define_key (global_map, n, "self-insert-command");