comparison src/event-stream.c @ 563:183866b06e0b

[xemacs-hg @ 2001-05-24 07:50:48 by ben] Makefile.in.in, abbrev.c, alloc.c, buffer.c, bytecode.c, callint.c, callproc.c, casetab.c, chartab.c, cmdloop.c, cmds.c, console-msw.c, console-msw.h, console-stream.c, console-tty.c, console-x.c, console.c, data.c, database.c, debug.c, device-gtk.c, device-msw.c, device-tty.c, device-x.c, device.c, dialog-gtk.c, dialog-msw.c, dialog-x.c, dialog.c, dired-msw.c, dired.c, doc.c, doprnt.c, dragdrop.c, editfns.c, eldap.c, eldap.h, elhash.c, emacs-widget-accessors.c, emacs.c, emodules.c, esd.c, eval.c, event-Xt.c, event-gtk.c, event-msw.c, event-stream.c, events.c, extents.c, faces.c, file-coding.c, fileio.c, filelock.c, floatfns.c, fns.c, font-lock.c, frame-gtk.c, frame-x.c, frame.c, general-slots.h, glade.c, glyphs-gtk.c, glyphs-msw.c, glyphs-widget.c, glyphs-x.c, glyphs.c, glyphs.h, gpmevent.c, gui-gtk.c, gui-x.c, gui.c, gutter.c, hpplay.c, indent.c, input-method-xlib.c, insdel.c, intl.c, keymap.c, libsst.c, libsst.h, linuxplay.c, lisp.h, lread.c, lstream.c, lstream.h, macros.c, marker.c, md5.c, menubar-gtk.c, menubar-msw.c, menubar-x.c, menubar.c, minibuf.c, miscplay.c, miscplay.h, mule-ccl.c, mule-charset.c, mule-wnnfns.c, mule.c, nas.c, ntplay.c, ntproc.c, objects-gtk.c, objects-msw.c, objects-x.c, objects.c, postgresql.c, print.c, process-nt.c, process-unix.c, process.c, ralloc.c, rangetab.c, redisplay.c, scrollbar.c, search.c, select-gtk.c, select-x.c, select.c, sgiplay.c, sheap.c, sound.c, specifier.c, sunplay.c, symbols.c, symeval.h, symsinit.h, syntax.c, sysdep.c, toolbar-msw.c, toolbar.c, tooltalk.c, ui-byhand.c, ui-gtk.c, undo.c, unexaix.c, unexapollo.c, unexconvex.c, unexec.c, widget.c, win32.c, window.c: -- defsymbol -> DEFSYMBOL. -- add an error type to all errors. -- eliminate the error functions in eval.c that let you just use Qerror as the type. -- redo the error API to be more consistent, sensibly named, and easier to use. -- redo the error hierarchy somewhat. create new errors: structure-formation-error, gui-error, invalid-constant, stack-overflow, out-of-memory, process-error, network-error, sound-error, printing-unreadable-object, base64-conversion- error; coding-system-error renamed to text-conversion error; some others. -- fix Mule problems in error strings in emodules.c, tooltalk.c. -- fix error handling in mswin open-network-stream. -- Mule-ize all sound files and clean up the headers. -- nativesound.h -> sound.h and used for all sound files. -- move some shared stuff into glyphs-shared.c: first attempt at eliminating some of the massive GTK code duplication. xemacs.mak: add glyphs-shared.c. xemacs-faq.texi: document how to debug X errors subr.el: fix doc string to reflect reality
author ben
date Thu, 24 May 2001 07:51:33 +0000
parents c69610198c35
children 5fd7ba8b56e7
comparison
equal deleted inserted replaced
562:c775bd016b32 563:183866b06e0b
100 100
101 /* The number of keystrokes between auto-saves. */ 101 /* The number of keystrokes between auto-saves. */
102 static Fixnum auto_save_interval; 102 static Fixnum auto_save_interval;
103 103
104 Lisp_Object Qundefined_keystroke_sequence; 104 Lisp_Object Qundefined_keystroke_sequence;
105 Lisp_Object Qinvalid_key_binding;
105 106
106 Lisp_Object Qcommand_event_p; 107 Lisp_Object Qcommand_event_p;
107 108
108 /* Hooks to run before and after each command. */ 109 /* Hooks to run before and after each command. */
109 Lisp_Object Vpre_command_hook, Vpost_command_hook; 110 Lisp_Object Vpre_command_hook, Vpost_command_hook;
412 if (!event_stream && noninteractive) 413 if (!event_stream && noninteractive)
413 { 414 {
414 switch (op) 415 switch (op)
415 { 416 {
416 case EVENT_STREAM_PROCESS: 417 case EVENT_STREAM_PROCESS:
417 error ("Can't start subprocesses in -batch mode"); 418 invalid_operation ("Can't start subprocesses in -batch mode",
419 Qunbound);
418 case EVENT_STREAM_TIMEOUT: 420 case EVENT_STREAM_TIMEOUT:
419 error ("Can't add timeouts in -batch mode"); 421 invalid_operation ("Can't add timeouts in -batch mode", Qunbound);
420 case EVENT_STREAM_CONSOLE: 422 case EVENT_STREAM_CONSOLE:
421 error ("Can't add consoles in -batch mode"); 423 invalid_operation ("Can't add consoles in -batch mode", Qunbound);
422 case EVENT_STREAM_READ: 424 case EVENT_STREAM_READ:
423 error ("Can't read events in -batch mode"); 425 invalid_operation ("Can't read events in -batch mode", Qunbound);
424 default: 426 default:
425 abort (); 427 abort ();
426 } 428 }
427 } 429 }
428 else if (!event_stream) 430 else if (!event_stream)
429 { 431 {
430 error ("event-stream callbacks not initialized (internal error?)"); 432 invalid_operation
433 ("event-stream callbacks not initialized (internal error?)",
434 Qunbound);
431 } 435 }
432 } 436 }
433 437
434 static int 438 static int
435 event_stream_event_pending_p (int user) 439 event_stream_event_pending_p (int user)
1330 long fsecs; 1334 long fsecs;
1331 CHECK_INT (secs); 1335 CHECK_INT (secs);
1332 fsecs = XINT (secs); 1336 fsecs = XINT (secs);
1333 #endif 1337 #endif
1334 if (fsecs < 0) 1338 if (fsecs < 0)
1335 signal_simple_error ("timeout is negative", secs); 1339 invalid_argument ("timeout is negative", secs);
1336 if (!allow_0 && fsecs == 0) 1340 if (!allow_0 && fsecs == 0)
1337 signal_simple_error ("timeout is non-positive", secs); 1341 invalid_argument ("timeout is non-positive", secs);
1338 if (fsecs >= (((unsigned int) 0xFFFFFFFF) / 1000)) 1342 if (fsecs >= (((unsigned int) 0xFFFFFFFF) / 1000))
1339 signal_simple_error 1343 invalid_argument
1340 ("timeout would exceed 32 bits when represented in milliseconds", secs); 1344 ("timeout would exceed 32 bits when represented in milliseconds", secs);
1341 1345
1342 return (unsigned long) (1000 * fsecs); 1346 return (unsigned long) (1000 * fsecs);
1343 } 1347 }
1344 1348
2079 * paths from the menu callbacks back into the menu code have to 2083 * paths from the menu callbacks back into the menu code have to
2080 * be blocked. Fnext_event is the normal path into the menu code, 2084 * be blocked. Fnext_event is the normal path into the menu code,
2081 * so we signal an error here. 2085 * so we signal an error here.
2082 */ 2086 */
2083 if (in_menu_callback) 2087 if (in_menu_callback)
2084 error ("Attempt to call next-event inside menu callback"); 2088 invalid_operation ("Attempt to call next-event inside menu callback",
2089 Qunbound);
2085 #endif /* LWLIB_MENUBARS_LUCID */ 2090 #endif /* LWLIB_MENUBARS_LUCID */
2086 2091
2087 if (NILP (event)) 2092 if (NILP (event))
2088 event = Fmake_event (Qnil, Qnil); 2093 event = Fmake_event (Qnil, Qnil);
2089 else 2094 else
2117 if (!NILP (Vunread_command_events)) 2122 if (!NILP (Vunread_command_events))
2118 { 2123 {
2119 if (!CONSP (Vunread_command_events)) 2124 if (!CONSP (Vunread_command_events))
2120 { 2125 {
2121 Vunread_command_events = Qnil; 2126 Vunread_command_events = Qnil;
2122 signal_error (Qwrong_type_argument, 2127 signal_error_1 (Qwrong_type_argument,
2123 list3 (Qconsp, Vunread_command_events, 2128 list3 (Qconsp, Vunread_command_events,
2124 Qunread_command_events)); 2129 Qunread_command_events));
2125 } 2130 }
2126 else 2131 else
2127 { 2132 {
2128 Lisp_Object e = XCAR (Vunread_command_events); 2133 Lisp_Object e = XCAR (Vunread_command_events);
2129 Vunread_command_events = XCDR (Vunread_command_events); 2134 Vunread_command_events = XCDR (Vunread_command_events);
2130 if (!EVENTP (e) || !command_event_p (e)) 2135 if (!EVENTP (e) || !command_event_p (e))
2131 signal_error (Qwrong_type_argument, 2136 signal_error_1 (Qwrong_type_argument,
2132 list3 (Qcommand_event_p, e, Qunread_command_events)); 2137 list3 (Qcommand_event_p, e, Qunread_command_events));
2133 redisplay (); 2138 redisplay ();
2134 if (!EQ (e, event)) 2139 if (!EQ (e, event))
2135 Fcopy_event (e, event); 2140 Fcopy_event (e, event);
2136 DEBUG_PRINT_EMACS_EVENT ("unread-command-events", event); 2141 DEBUG_PRINT_EMACS_EVENT ("unread-command-events", event);
2143 Lisp_Object e = Vunread_command_event; 2148 Lisp_Object e = Vunread_command_event;
2144 Vunread_command_event = Qnil; 2149 Vunread_command_event = Qnil;
2145 2150
2146 if (!EVENTP (e) || !command_event_p (e)) 2151 if (!EVENTP (e) || !command_event_p (e))
2147 { 2152 {
2148 signal_error (Qwrong_type_argument, 2153 signal_error_1 (Qwrong_type_argument,
2149 list3 (Qeventp, e, Qunread_command_event)); 2154 list3 (Qeventp, e, Qunread_command_event));
2150 } 2155 }
2151 if (!EQ (e, event)) 2156 if (!EQ (e, event))
2152 Fcopy_event (e, event); 2157 Fcopy_event (e, event);
2153 redisplay (); 2158 redisplay ();
2233 if (!EVENTP (Vlast_input_event)) 2238 if (!EVENTP (Vlast_input_event))
2234 Vlast_input_event = Fmake_event (Qnil, Qnil); 2239 Vlast_input_event = Fmake_event (Qnil, Qnil);
2235 if (XEVENT_TYPE (Vlast_input_event) == dead_event) 2240 if (XEVENT_TYPE (Vlast_input_event) == dead_event)
2236 { 2241 {
2237 Vlast_input_event = Fmake_event (Qnil, Qnil); 2242 Vlast_input_event = Fmake_event (Qnil, Qnil);
2238 error ("Someone deallocated last-input-event!"); 2243 invalid_state ("Someone deallocated last-input-event!", Qunbound);
2239 } 2244 }
2240 if (! EQ (event, Vlast_input_event)) 2245 if (! EQ (event, Vlast_input_event))
2241 Fcopy_event (event, Vlast_input_event); 2246 Fcopy_event (event, Vlast_input_event);
2242 2247
2243 /* last-input-char and last-input-time are derived from 2248 /* last-input-char and last-input-time are derived from
3171 3176
3172 result = command_builder_find_leaf_1 (builder); 3177 result = command_builder_find_leaf_1 (builder);
3173 return result; 3178 return result;
3174 } 3179 }
3175 3180
3176 signal_simple_error ((munge == MUNGE_ME_FUNCTION_KEY ? 3181 signal_error (Qinvalid_key_binding,
3177 "Invalid binding in function-key-map" : 3182 (munge == MUNGE_ME_FUNCTION_KEY ?
3178 "Invalid binding in key-translation-map"), 3183 "Invalid binding in function-key-map" :
3179 result); 3184 "Invalid binding in key-translation-map"),
3185 result);
3180 } 3186 }
3181 3187
3182 return Qnil; 3188 return Qnil;
3183 } 3189 }
3184 3190
3436 int i, j, nkeys, start, min; 3442 int i, j, nkeys, start, min;
3437 struct gcpro gcpro1; 3443 struct gcpro gcpro1;
3438 3444
3439 CHECK_INT (size); 3445 CHECK_INT (size);
3440 if (XINT (size) <= 0) 3446 if (XINT (size) <= 0)
3441 error ("Recent keys ring size must be positive"); 3447 invalid_argument ("Recent keys ring size must be positive", size);
3442 if (XINT (size) == recent_keys_ring_size) 3448 if (XINT (size) == recent_keys_ring_size)
3443 return size; 3449 return size;
3444 3450
3445 GCPRO1 (new_vector); 3451 GCPRO1 (new_vector);
3446 new_vector = make_vector (XINT (size), Qnil); 3452 new_vector = make_vector (XINT (size), Qnil);
3871 if (!EVENTP (Vlast_command_event)) 3877 if (!EVENTP (Vlast_command_event))
3872 Vlast_command_event = Fmake_event (Qnil, Qnil); 3878 Vlast_command_event = Fmake_event (Qnil, Qnil);
3873 if (XEVENT (Vlast_command_event)->event_type == dead_event) 3879 if (XEVENT (Vlast_command_event)->event_type == dead_event)
3874 { 3880 {
3875 Vlast_command_event = Fmake_event (Qnil, Qnil); 3881 Vlast_command_event = Fmake_event (Qnil, Qnil);
3876 error ("Someone deallocated the last-command-event!"); 3882 invalid_state ("Someone deallocated the last-command-event!", Qunbound);
3877 } 3883 }
3878 3884
3879 if (! EQ (event, Vlast_command_event)) 3885 if (! EQ (event, Vlast_command_event))
3880 Fcopy_event (event, Vlast_command_event); 3886 Fcopy_event (event, Vlast_command_event);
3881 3887
4443 filename = Fexpand_file_name (filename, Qnil); 4449 filename = Fexpand_file_name (filename, Qnil);
4444 fd = open ((char*) XSTRING_DATA (filename), 4450 fd = open ((char*) XSTRING_DATA (filename),
4445 O_WRONLY | O_TRUNC | O_CREAT | OPEN_BINARY, 4451 O_WRONLY | O_TRUNC | O_CREAT | OPEN_BINARY,
4446 CREAT_MODE); 4452 CREAT_MODE);
4447 if (fd < 0) 4453 if (fd < 0)
4448 error ("Unable to create dribble file"); 4454 report_file_error ("Unable to create dribble file", filename);
4449 Vdribble_file = make_filedesc_output_stream (fd, 0, 0, LSTR_CLOSING); 4455 Vdribble_file = make_filedesc_output_stream (fd, 0, 0, LSTR_CLOSING);
4450 #ifdef MULE 4456 #ifdef MULE
4451 Vdribble_file = 4457 Vdribble_file =
4452 make_encoding_output_stream (XLSTREAM (Vdribble_file), 4458 make_encoding_output_stream (XLSTREAM (Vdribble_file),
4453 Fget_coding_system (Qescape_quoted)); 4459 Fget_coding_system (Qescape_quoted));
4482 syms_of_event_stream (void) 4488 syms_of_event_stream (void)
4483 { 4489 {
4484 INIT_LRECORD_IMPLEMENTATION (command_builder); 4490 INIT_LRECORD_IMPLEMENTATION (command_builder);
4485 INIT_LRECORD_IMPLEMENTATION (timeout); 4491 INIT_LRECORD_IMPLEMENTATION (timeout);
4486 4492
4487 defsymbol (&Qdisabled, "disabled"); 4493 DEFSYMBOL (Qdisabled);
4488 defsymbol (&Qcommand_event_p, "command-event-p"); 4494 DEFSYMBOL (Qcommand_event_p);
4489 4495
4490 DEFERROR_STANDARD (Qundefined_keystroke_sequence, Qinvalid_argument); 4496 DEFERROR_STANDARD (Qundefined_keystroke_sequence, Qsyntax_error);
4497 DEFERROR_STANDARD (Qinvalid_key_binding, Qinvalid_state);
4491 4498
4492 DEFSUBR (Frecent_keys); 4499 DEFSUBR (Frecent_keys);
4493 DEFSUBR (Frecent_keys_ring_size); 4500 DEFSUBR (Frecent_keys_ring_size);
4494 DEFSUBR (Fset_recent_keys_ring_size); 4501 DEFSUBR (Fset_recent_keys_ring_size);
4495 DEFSUBR (Finput_pending_p); 4502 DEFSUBR (Finput_pending_p);
4510 DEFSUBR (Fthis_command_keys); 4517 DEFSUBR (Fthis_command_keys);
4511 DEFSUBR (Freset_this_command_lengths); 4518 DEFSUBR (Freset_this_command_lengths);
4512 DEFSUBR (Fopen_dribble_file); 4519 DEFSUBR (Fopen_dribble_file);
4513 DEFSUBR (Fcurrent_event_timestamp); 4520 DEFSUBR (Fcurrent_event_timestamp);
4514 4521
4515 defsymbol (&Qpre_command_hook, "pre-command-hook"); 4522 DEFSYMBOL (Qpre_command_hook);
4516 defsymbol (&Qpost_command_hook, "post-command-hook"); 4523 DEFSYMBOL (Qpost_command_hook);
4517 defsymbol (&Qunread_command_events, "unread-command-events"); 4524 DEFSYMBOL (Qunread_command_events);
4518 defsymbol (&Qunread_command_event, "unread-command-event"); 4525 DEFSYMBOL (Qunread_command_event);
4519 defsymbol (&Qpre_idle_hook, "pre-idle-hook"); 4526 DEFSYMBOL (Qpre_idle_hook);
4520 defsymbol (&Qhandle_pre_motion_command, "handle-pre-motion-command"); 4527 DEFSYMBOL (Qhandle_pre_motion_command);
4521 defsymbol (&Qhandle_post_motion_command, "handle-post-motion-command"); 4528 DEFSYMBOL (Qhandle_post_motion_command);
4522 defsymbol (&Qretry_undefined_key_binding_unshifted, 4529 DEFSYMBOL (Qretry_undefined_key_binding_unshifted);
4523 "retry-undefined-key-binding-unshifted"); 4530 DEFSYMBOL (Qauto_show_make_point_visible);
4524 defsymbol (&Qauto_show_make_point_visible, 4531
4525 "auto-show-make-point-visible"); 4532 DEFSYMBOL (Qself_insert_defer_undo);
4526 4533 DEFSYMBOL (Qcancel_mode_internal);
4527 defsymbol (&Qself_insert_defer_undo, "self-insert-defer-undo");
4528 defsymbol (&Qcancel_mode_internal, "cancel-mode-internal");
4529 } 4534 }
4530 4535
4531 void 4536 void
4532 reinit_vars_of_event_stream (void) 4537 reinit_vars_of_event_stream (void)
4533 { 4538 {