aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRichard M. Stallman1995-08-21 22:02:50 +0000
committerRichard M. Stallman1995-08-21 22:02:50 +0000
commit59aadc813c30893d688c0722d53a9f6cd2430508 (patch)
tree9d974c13b766afa0833c553d1b5689bc76088abc /src
parent26ee1a5dd0d919d33c6a6ab29e3760cc0a6d8492 (diff)
downloademacs-59aadc813c30893d688c0722d53a9f6cd2430508.tar.gz
emacs-59aadc813c30893d688c0722d53a9f6cd2430508.zip
(Qpost_command_idle_hook, Vpost_command_idle_hook): New vars.
(syms_of_keyboard): Set up new vars. (command_loop_1): Run Qpost_command_idle_hook.
Diffstat (limited to 'src')
-rw-r--r--src/keyboard.c51
1 files changed, 39 insertions, 12 deletions
diff --git a/src/keyboard.c b/src/keyboard.c
index aed154bd3bb..db0c6881380 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -323,9 +323,14 @@ Lisp_Object Vlucid_menu_bar_dirty_flag;
323Lisp_Object Qrecompute_lucid_menubar, Qactivate_menubar_hook; 323Lisp_Object Qrecompute_lucid_menubar, Qactivate_menubar_hook;
324 324
325/* Hooks to run before and after each command. */ 325/* Hooks to run before and after each command. */
326Lisp_Object Qpre_command_hook, Qpost_command_hook; 326Lisp_Object Qpre_command_hook, Vpre_command_hook;
327Lisp_Object Vpre_command_hook, Vpost_command_hook; 327Lisp_Object Qpost_command_hook, Vpost_command_hook;
328Lisp_Object Qcommand_hook_internal, Vcommand_hook_internal; 328Lisp_Object Qcommand_hook_internal, Vcommand_hook_internal;
329/* Hook run after a command if there's no more input soon. */
330Lisp_Object Qpost_command_idle_hook, Vpost_command_idle_hook;
331
332/* Delay time in microseconds before running post-command-idle-hook. */
333int post_command_idle_delay;
329 334
330/* List of deferred actions to be performed at a later time. 335/* List of deferred actions to be performed at a later time.
331 The precise format isn't relevant here; we just check whether it is nil. */ 336 The precise format isn't relevant here; we just check whether it is nil. */
@@ -1089,6 +1094,14 @@ command_loop_1 ()
1089 if (!NILP (Vdeferred_action_list)) 1094 if (!NILP (Vdeferred_action_list))
1090 call0 (Vdeferred_action_function); 1095 call0 (Vdeferred_action_function);
1091 1096
1097 if (!NILP (XSYMBOL (Qpost_command_idle_hook)->value) && !NILP (Vrun_hooks))
1098 {
1099 if (NILP (Vunread_command_events)
1100 && NILP (Vexecuting_macro)
1101 && !NILP (sit_for (0, post_command_idle_delay, 0, 1)))
1102 safe_run_hooks (Qpost_command_idle_hook);
1103 }
1104
1092 /* Do this after running Vpost_command_hook, for consistency. */ 1105 /* Do this after running Vpost_command_hook, for consistency. */
1093 current_kboard->Vlast_command = this_command; 1106 current_kboard->Vlast_command = this_command;
1094 1107
@@ -1367,6 +1380,15 @@ command_loop_1 ()
1367 if (!NILP (Vdeferred_action_list)) 1380 if (!NILP (Vdeferred_action_list))
1368 safe_run_hooks (Qdeferred_action_function); 1381 safe_run_hooks (Qdeferred_action_function);
1369 1382
1383 if (!NILP (XSYMBOL (Qpost_command_idle_hook)->value)
1384 && !NILP (Vrun_hooks))
1385 {
1386 if (NILP (Vunread_command_events)
1387 && NILP (Vexecuting_macro)
1388 && !NILP (sit_for (0, post_command_idle_delay, 0, 1)))
1389 safe_run_hooks (Qpost_command_idle_hook);
1390 }
1391
1370 /* If there is a prefix argument, 1392 /* If there is a prefix argument,
1371 1) We don't want Vlast_command to be ``universal-argument'' 1393 1) We don't want Vlast_command to be ``universal-argument''
1372 (that would be dumb), so don't set Vlast_command, 1394 (that would be dumb), so don't set Vlast_command,
@@ -6996,6 +7018,9 @@ syms_of_keyboard ()
6996 Qpost_command_hook = intern ("post-command-hook"); 7018 Qpost_command_hook = intern ("post-command-hook");
6997 staticpro (&Qpost_command_hook); 7019 staticpro (&Qpost_command_hook);
6998 7020
7021 Qpost_command_idle_hook = intern ("post-command-idle-hook");
7022 staticpro (&Qpost_command_idle_hook);
7023
6999 Qdeferred_action_function = intern ("deferred-action-function"); 7024 Qdeferred_action_function = intern ("deferred-action-function");
7000 staticpro (&Qdeferred_action_function); 7025 staticpro (&Qdeferred_action_function);
7001 7026
@@ -7290,22 +7315,24 @@ Buffer modification stores t in this variable.");
7290 7315
7291 DEFVAR_LISP ("pre-command-hook", &Vpre_command_hook, 7316 DEFVAR_LISP ("pre-command-hook", &Vpre_command_hook,
7292 "Normal hook run before each command is executed.\n\ 7317 "Normal hook run before each command is executed.\n\
7293While the hook is run, its value is temporarily set to nil\n\ 7318Errors running the hook are caught and ignored.");
7294to avoid an unbreakable infinite loop if a hook function gets an error.\n\
7295As a result, a hook function cannot straightforwardly alter the value of\n\
7296`pre-command-hook'. See the Emacs Lisp manual for a way of\n\
7297implementing hook functions that alter the set of hook functions.");
7298 Vpre_command_hook = Qnil; 7319 Vpre_command_hook = Qnil;
7299 7320
7300 DEFVAR_LISP ("post-command-hook", &Vpost_command_hook, 7321 DEFVAR_LISP ("post-command-hook", &Vpost_command_hook,
7301 "Normal hook run after each command is executed.\n\ 7322 "Normal hook run after each command is executed.\n\
7302While the hook is run, its value is temporarily set to nil\n\ 7323Errors running the hook are caught and ignored.");
7303to avoid an unbreakable infinite loop if a hook function gets an error.\n\
7304As a result, a hook function cannot straightforwardly alter the value of\n\
7305`post-command-hook'. See the Emacs Lisp manual for a way of\n\
7306implementing hook functions that alter the set of hook functions.");
7307 Vpost_command_hook = Qnil; 7324 Vpost_command_hook = Qnil;
7308 7325
7326 DEFVAR_LISP ("post-command-idle-hook", &Vpost_command_idle_hook,
7327 "Normal hook run after each command is executed, if idle.\n\
7328Errors running the hook are caught and ignored.");
7329 Vpost_command_idle_hook = Qnil;
7330
7331 DEFVAR_INT ("post-command-idle-delay", &post_command_idle_delay,
7332 "Delay time before running `post-command-idle-delay'.\n\
7333This is measured in microseconds.");
7334 post_command_idle_delay = 100000;
7335
7309 DEFVAR_LISP ("lucid-menu-bar-dirty-flag", &Vlucid_menu_bar_dirty_flag, 7336 DEFVAR_LISP ("lucid-menu-bar-dirty-flag", &Vlucid_menu_bar_dirty_flag,
7310 "t means menu bar, specified Lucid style, needs to be recomputed."); 7337 "t means menu bar, specified Lucid style, needs to be recomputed.");
7311 Vlucid_menu_bar_dirty_flag = Qnil; 7338 Vlucid_menu_bar_dirty_flag = Qnil;