comparison src/keyboard.c @ 71947:4bc25e59ebd1

(Vcommand_error_function): New variable. (syms_of_keyboard): Defvar it. (cmd_error_internal): Simplify, and handle Vcommand_error_function.
author Richard M. Stallman <rms@gnu.org>
date Mon, 17 Jul 2006 21:00:58 +0000
parents 838f4260201e
children 802436ff7a47
comparison
equal deleted inserted replaced
71946:db54d1f64f25 71947:4bc25e59ebd1
240 static int inhibit_local_menu_bar_menus; 240 static int inhibit_local_menu_bar_menus;
241 241
242 /* Nonzero means C-g should cause immediate error-signal. */ 242 /* Nonzero means C-g should cause immediate error-signal. */
243 int immediate_quit; 243 int immediate_quit;
244 244
245 /* The user's hook function for outputting an error message. */
246 Lisp_Object Vcommand_error_function;
247
245 /* The user's ERASE setting. */ 248 /* The user's ERASE setting. */
246 Lisp_Object Vtty_erase_char; 249 Lisp_Object Vtty_erase_char;
247 250
248 /* Character to recognize as the help char. */ 251 /* Character to recognize as the help char. */
249 Lisp_Object Vhelp_char; 252 Lisp_Object Vhelp_char;
1228 void 1231 void
1229 cmd_error_internal (data, context) 1232 cmd_error_internal (data, context)
1230 Lisp_Object data; 1233 Lisp_Object data;
1231 char *context; 1234 char *context;
1232 { 1235 {
1233 Lisp_Object stream;
1234 int kill_emacs_p = 0;
1235 struct frame *sf = SELECTED_FRAME (); 1236 struct frame *sf = SELECTED_FRAME ();
1236
1237 Vquit_flag = Qnil;
1238 Vinhibit_quit = Qt;
1239 clear_message (1, 0);
1240
1241 /* If the window system or terminal frame hasn't been initialized
1242 yet, or we're not interactive, it's best to dump this message out
1243 to stderr and exit. */
1244 if (!sf->glyphs_initialized_p
1245 /* This is the case of the frame dumped with Emacs, when we're
1246 running under a window system. */
1247 || (!NILP (Vwindow_system)
1248 && !inhibit_window_system
1249 && FRAME_TERMCAP_P (sf))
1250 || noninteractive)
1251 {
1252 stream = Qexternal_debugging_output;
1253 kill_emacs_p = 1;
1254 }
1255 else
1256 {
1257 Fdiscard_input ();
1258 message_log_maybe_newline ();
1259 bitch_at_user ();
1260 stream = Qt;
1261 }
1262 1237
1263 /* The immediate context is not interesting for Quits, 1238 /* The immediate context is not interesting for Quits,
1264 since they are asyncronous. */ 1239 since they are asyncronous. */
1265 if (EQ (XCAR (data), Qquit)) 1240 if (EQ (XCAR (data), Qquit))
1266 Vsignaling_function = Qnil; 1241 Vsignaling_function = Qnil;
1267 1242
1268 print_error_message (data, stream, context, Vsignaling_function); 1243 Vquit_flag = Qnil;
1244 Vinhibit_quit = Qt;
1245
1246 /* Use user's specified output function if any. */
1247 if (!NILP (Vcommand_error_function))
1248 call3 (Vcommand_error_function, data,
1249 build_string (context ? context : ""),
1250 Vsignaling_function);
1251 /* If the window system or terminal frame hasn't been initialized
1252 yet, or we're not interactive, write the message to stderr and exit. */
1253 else if (!sf->glyphs_initialized_p
1254 /* This is the case of the frame dumped with Emacs, when we're
1255 running under a window system. */
1256 || (!NILP (Vwindow_system)
1257 && !inhibit_window_system
1258 && FRAME_TERMCAP_P (sf))
1259 || noninteractive)
1260 {
1261 print_error_message (data, Qexternal_debugging_output,
1262 context, Vsignaling_function);
1263 Fterpri (Qexternal_debugging_output);
1264 Fkill_emacs (make_number (-1));
1265 }
1266 else
1267 {
1268 clear_message (1, 0);
1269 Fdiscard_input ();
1270 message_log_maybe_newline ();
1271 bitch_at_user ();
1272
1273 print_error_message (data, Qt, context, Vsignaling_function);
1274 }
1269 1275
1270 Vsignaling_function = Qnil; 1276 Vsignaling_function = Qnil;
1271
1272 /* If the window system or terminal frame hasn't been initialized
1273 yet, or we're in -batch mode, this error should cause Emacs to exit. */
1274 if (kill_emacs_p)
1275 {
1276 Fterpri (stream);
1277 Fkill_emacs (make_number (-1));
1278 }
1279 } 1277 }
1280 1278
1281 Lisp_Object command_loop_1 (); 1279 Lisp_Object command_loop_1 ();
1282 Lisp_Object command_loop_2 (); 1280 Lisp_Object command_loop_2 ();
1283 Lisp_Object top_level_1 (); 1281 Lisp_Object top_level_1 ();
11482 doc: /* If non-nil, any keyboard input throws to this symbol. 11480 doc: /* If non-nil, any keyboard input throws to this symbol.
11483 The value of that variable is passed to `quit-flag' and later causes a 11481 The value of that variable is passed to `quit-flag' and later causes a
11484 peculiar kind of quitting. */); 11482 peculiar kind of quitting. */);
11485 Vthrow_on_input = Qnil; 11483 Vthrow_on_input = Qnil;
11486 11484
11485 DEFVAR_LISP ("command-error-function", &Vcommand_error_function,
11486 doc: /* If non-nil, function to output error messages.
11487 The arguments are the error data, a list of the form
11488 (SIGNALED-CONDITIONS . SIGNAL-DATA)
11489 such as just as `condition-case' would bind its variable to,
11490 the context (a string which normally goes at the start of the message),
11491 and the Lisp function within which the error was signaled. */);
11492 Vcommand_error_function = Qnil;
11493
11487 DEFVAR_LISP ("enable-disabled-menus-and-buttons", 11494 DEFVAR_LISP ("enable-disabled-menus-and-buttons",
11488 &Venable_disabled_menus_and_buttons, 11495 &Venable_disabled_menus_and_buttons,
11489 doc: /* If non-nil, don't ignore events produced by disabled menu items and tool-bar. 11496 doc: /* If non-nil, don't ignore events produced by disabled menu items and tool-bar.
11490 11497
11491 Help functions bind this to allow help on disabled menu items 11498 Help functions bind this to allow help on disabled menu items