/* The buffer that was current when the last command was started. */
Lisp_Object last_point_position_buffer;
-#ifdef MULTI_FRAME
/* The frame in which the last input event occurred, or Qmacro if the
last event came from a macro. We use this to determine when to
generate switch-frame events. This may be cleared by functions
like Fselect_frame, to make sure that a switch-frame event is
generated by the next character. */
Lisp_Object internal_last_event_frame;
-#endif
/* A user-visible version of the above, intended to allow users to
figure out where the last event came from, if the event doesn't
#ifdef HAVE_WINDOW_SYSTEM
#define POLL_FOR_INPUT
#endif
-
-/* Non-nil enables Column Number mode. */
-Lisp_Object Vcolumn_number_mode;
\f
/* Global variable declarations. */
val = command_loop ();
if (EQ (val, Qt))
Fsignal (Qquit, Qnil);
+ /* Handle throw from read_minibuf when using minibuffer
+ while it's active but we're in another window. */
+ if (STRINGP (val))
+ Fsignal (Qerror, Fcons (val, Qnil));
return unbind_to (count, Qnil);
}
Lisp_Object data;
{
Lisp_Object old_level, old_length;
+ char macroerror[50];
+
+ if (!NILP (executing_macro))
+ {
+ if (executing_macro_iterations == 1)
+ sprintf (macroerror, "After 1 kbd macro iteration: ");
+ else
+ sprintf (macroerror, "After %d kbd macro iterations: ",
+ executing_macro_iterations);
+ }
+ else
+ *macroerror = 0;
Vstandard_output = Qt;
Vstandard_input = Qt;
Vexecuting_macro = Qnil;
+ executing_macro = Qnil;
current_kboard->Vprefix_arg = Qnil;
cancel_echoing ();
old_length = Vprint_length;
XSETFASTINT (Vprint_level, 10);
XSETFASTINT (Vprint_length, 10);
- cmd_error_internal (data, NULL);
+ cmd_error_internal (data, macroerror);
Vprint_level = old_level;
Vprint_length = old_length;
#endif /* C_ALLOCA */
#if 0
-#ifdef MULTI_FRAME
/* Select the frame that the last event came from. Usually,
switch-frame events will take care of this, but if some lisp
code swallows a switch-frame event, we'll fix things up here.
if (FRAMEP (internal_last_event_frame)
&& XFRAME (internal_last_event_frame) != selected_frame)
Fselect_frame (internal_last_event_frame, Qnil);
-#endif
#endif
/* If it has changed current-menubar from previous value,
really recompute the menubar from the value. */
i = read_key_sequence (keybuf, sizeof keybuf / sizeof keybuf[0],
Qnil, 0, 1);
+ /* A filter may have run while we were reading the input. */
+ if (XBUFFER (XWINDOW (selected_window)->buffer) != current_buffer)
+ set_buffer_internal (XBUFFER (XWINDOW (selected_window)->buffer));
+
++num_input_keys;
/* Now we have read a key sequence of length I,
: (lose >= 0x20 && lose < 0x7f))
&& (XFASTINT (XWINDOW (selected_window)->last_modified)
>= MODIFF)
+ && (XFASTINT (XWINDOW (selected_window)->last_overlay_modified)
+ >= OVERLAY_MODIFF)
&& (XFASTINT (XWINDOW (selected_window)->last_point)
== PT - 1)
&& !windows_or_buffers_changed
&& EQ (current_buffer->selective_display, Qnil)
&& !detect_input_pending ()
- && NILP (Vcolumn_number_mode)
+ && NILP (XWINDOW (selected_window)->column_number_displayed)
&& NILP (Vexecuting_macro))
no_redisplay = direct_output_forward_char (1);
goto directly_done;
: (lose >= 0x20 && lose < 0x7f))
&& (XFASTINT (XWINDOW (selected_window)->last_modified)
>= MODIFF)
+ && (XFASTINT (XWINDOW (selected_window)->last_overlay_modified)
+ >= OVERLAY_MODIFF)
&& (XFASTINT (XWINDOW (selected_window)->last_point)
== PT + 1)
&& !windows_or_buffers_changed
&& EQ (current_buffer->selective_display, Qnil)
&& !detect_input_pending ()
- && NILP (Vcolumn_number_mode)
+ && NILP (XWINDOW (selected_window)->column_number_displayed)
&& NILP (Vexecuting_macro))
no_redisplay = direct_output_forward_char (-1);
goto directly_done;
}
lose = ((XFASTINT (XWINDOW (selected_window)->last_modified)
< MODIFF)
+ || (XFASTINT (XWINDOW (selected_window)->last_overlay_modified)
+ < OVERLAY_MODIFF)
|| (XFASTINT (XWINDOW (selected_window)->last_point)
!= PT)
|| MODIFF <= SAVE_MODIFF
|| windows_or_buffers_changed
|| !EQ (current_buffer->selective_display, Qnil)
|| detect_input_pending ()
- || !NILP (Vcolumn_number_mode)
+ || !NILP (XWINDOW (selected_window)->column_number_displayed)
|| !NILP (Vexecuting_macro));
value = internal_self_insert (c, 0);
if (value)
}
directly_done: ;
- /* Note that the value cell will never directly contain nil
- if the symbol is a local variable. */
- if (!NILP (Vpost_command_hook) && !NILP (Vrun_hooks))
- safe_run_hooks (Qpost_command_hook);
-
- if (!NILP (Vdeferred_action_list))
- safe_run_hooks (Qdeferred_action_function);
-
- if (!NILP (Vpost_command_idle_hook) && !NILP (Vrun_hooks))
- {
- if (NILP (Vunread_command_events)
- && NILP (Vexecuting_macro)
- && !NILP (sit_for (0, post_command_idle_delay, 0, 1)))
- safe_run_hooks (Qpost_command_idle_hook);
- }
-
/* If there is a prefix argument,
1) We don't want Vlast_command to be ``universal-argument''
(that would be dumb), so don't set Vlast_command,
this_single_command_key_start = 0;
}
+ /* Note that the value cell will never directly contain nil
+ if the symbol is a local variable. */
+ if (!NILP (Vpost_command_hook) && !NILP (Vrun_hooks))
+ safe_run_hooks (Qpost_command_hook);
+
+ if (!NILP (Vdeferred_action_list))
+ safe_run_hooks (Qdeferred_action_function);
+
+ if (!NILP (Vpost_command_idle_hook) && !NILP (Vrun_hooks))
+ {
+ if (NILP (Vunread_command_events)
+ && NILP (Vexecuting_macro)
+ && !NILP (sit_for (0, post_command_idle_delay, 0, 1)))
+ safe_run_hooks (Qpost_command_idle_hook);
+ }
+
if (!NILP (current_buffer->mark_active) && !NILP (Vrun_hooks))
{
if (!NILP (Vdeactivate_mark) && !NILP (Vtransient_mark_mode))
if (!NILP (Vexecuting_macro))
{
-#ifdef MULTI_FRAME
/* We set this to Qmacro; since that's not a frame, nobody will
try to switch frames on us, and the selected window will
remain unchanged.
events read from a macro should never cause a new frame to be
selected. */
Vlast_event_frame = internal_last_event_frame = Qmacro;
-#endif
/* Exit the macro if we are at the end.
Also, some things replace the macro with t
if (_setjmp (local_getcjmp))
{
XSETINT (c, quit_char);
-#ifdef MULTI_FRAME
XSETFRAME (internal_last_event_frame, selected_frame);
Vlast_event_frame = internal_last_event_frame;
-#endif
/* If we report the quit char as an event,
don't do so more than once. */
if (!NILP (Vinhibit_quit))
if (NILP (current_kboard->kbd_queue))
current_kboard->kbd_queue_has_data = 0;
input_pending = readable_events (0);
-#ifdef MULTI_FRAME
if (EVENT_HAS_PARAMETERS (c)
&& EQ (EVENT_HEAD_KIND (EVENT_HEAD (c)), Qswitch_frame))
internal_last_event_frame = XCONS (XCONS (c)->cdr)->car;
Vlast_event_frame = internal_last_event_frame;
-#endif
}
}
}
#endif
-#ifdef MULTI_FRAME
/* If this results in a quit_char being returned to Emacs as
input, set Vlast_event_frame properly. If this doesn't
get returned to Emacs as an event, the next event read
internal_last_event_frame = focus;
Vlast_event_frame = focus;
}
-#endif
last_event_timestamp = event->timestamp;
interrupt_signal ();
{
kbd_fetch_ptr = event + 1;
input_pending = readable_events (0);
- x_activate_menubar (XFRAME (event->frame_or_window));
+ if (FRAME_LIVE_P (XFRAME (event->frame_or_window)))
+ x_activate_menubar (XFRAME (event->frame_or_window));
}
#endif
/* Just discard these, by returning nil.
time, and leave the event in the queue for next time. */
else
{
-#ifdef MULTI_FRAME
Lisp_Object frame;
Lisp_Object focus;
&& XFRAME (frame) != selected_frame)
obj = make_lispy_switch_frame (frame);
internal_last_event_frame = frame;
-#endif /* MULTI_FRAME */
/* If we didn't decide to make a switch-frame event, go ahead
and build a real event from the queue entry. */
obj = Qnil;
-#ifdef MULTI_FRAME
/* Decide if we should generate a switch-frame event. Don't
generate switch-frame events for motion outside of all Emacs
frames. */
obj = make_lispy_switch_frame (frame);
internal_last_event_frame = frame;
}
-#endif
/* If we didn't decide to make a switch-frame event, go ahead and
return a mouse-motion event. */
input_pending = readable_events (0);
-#ifdef MULTI_FRAME
Vlast_event_frame = internal_last_event_frame;
-#endif
return (obj);
}
else
{
int pixcolumn, pixrow;
- column -= XINT (XWINDOW (window)->left);
+ column -= WINDOW_LEFT_MARGIN (XWINDOW (window));
row -= XINT (XWINDOW (window)->top);
glyph_to_pixel_coords (f, column, row, &pixcolumn, &pixrow);
XSETINT (event->x, pixcolumn);
}
#ifdef WINDOWSNT
- case win32_scroll_bar_click:
+ case w32_scroll_bar_click:
{
int button = event->code;
int is_double;
Fcons (part, Qnil)))));
}
- /* Always treat Win32 scroll bar events as clicks. */
+ /* Always treat W32 scroll bar events as clicks. */
event->modifiers |= click_modifier;
{
Lisp_Object x, y;
unsigned long time;
{
-#ifdef MULTI_FRAME
/* Is it a scroll bar movement? */
if (frame && ! NILP (bar_window))
{
/* Or is it an ordinary mouse movement? */
else
-#endif /* MULTI_FRAME */
{
int area;
Lisp_Object window;
Lisp_Object posn;
int column, row;
-#ifdef MULTI_FRAME
if (frame)
-#else
- if (1)
-#endif
{
/* It's in a frame; which window on that frame? */
pixel_to_glyph_coords (frame, XINT (x), XINT (y), &column, &row,
if (WINDOWP (window))
{
int pixcolumn, pixrow;
- column -= XINT (XWINDOW (window)->left);
+ column -= WINDOW_LEFT_MARGIN (XWINDOW (window));
row -= XINT (XWINDOW (window)->top);
glyph_to_pixel_coords (frame, column, row, &pixcolumn, &pixrow);
XSETINT (x, pixcolumn);
XSETINT (posn,
buffer_posn_from_coords (XWINDOW (window), column, row));
}
-#ifdef MULTI_FRAME
else if (frame != 0)
{
XSETFRAME (window, frame);
posn = Qnil;
}
-#endif
else
{
window = Qnil;
}
if (CONSP (*symbol_table))
- *symbol_table = Fcons (value, *symbol_table);
+ *symbol_table = Fcons (Fcons (symbol_int, value), *symbol_table);
else
XVECTOR (*symbol_table)->contents[symbol_num] = value;
if (interrupt_input)
{
SIGMASKTYPE mask;
- mask = sigblockx (SIGIO);
+ mask = sigblock (sigmask (SIGIO));
read_avail_input (expected);
sigsetmask (mask);
}
if (read_socket_hook && !interrupt_input && poll_suppress_count == 0)
{
SIGMASKTYPE mask;
- mask = sigblockx (SIGALRM);
+ mask = sigblock (sigmask (SIGALRM));
read_avail_input (expected);
sigsetmask (mask);
}
if (interrupt_input)
{
SIGMASKTYPE mask;
- mask = sigblockx (SIGIO);
+ mask = sigblock (sigmask (SIGIO));
kbd_buffer_store_event (&event);
sigsetmask (mask);
}
if (read_socket_hook)
/* No need for FIONREAD or fcntl; just say don't wait. */
- nread = (*read_socket_hook) (input_fd, buf, KBD_BUFFER_SIZE,
- expected, expected);
+ nread = (*read_socket_hook) (input_fd, buf, KBD_BUFFER_SIZE, expected);
else
{
/* Using KBD_BUFFER_SIZE - 1 here avoids reading more than
cbuf[i] &= ~0x80;
buf[i].code = cbuf[i];
-#ifdef MULTI_FRAME
XSETFRAME (buf[i].frame_or_window, selected_frame);
-#else
- buf[i].frame_or_window = Qnil;
-#endif
}
}
extern int select_alarmed;
#endif
-#ifdef USG
+#if defined (USG) && !defined (POSIX_SIGNALS)
/* USG systems forget handlers when they are used;
must reestablish each time */
signal (signo, input_available_signal);
Lisp_Object enabled;
int i;
+ /* Skip menu-bar equiv keys data. */
+ if (CONSP (def) && CONSP (XCONS (def)->car))
+ def = XCONS (def)->cdr;
+
if (EQ (def, Qundefined))
{
/* If a map has an explicit `undefined' as definition,
final = Findirect_function (cmd);
if (CONSP (final) && (tem = Fcar (final), EQ (tem, Qautoload)))
- do_autoload (final, cmd);
+ {
+ struct gcpro gcpro1, gcpro2;
+
+ GCPRO2 (cmd, prefixarg);
+ do_autoload (final, cmd);
+ UNGCPRO;
+ }
else
break;
}
Lisp_Object function;
char buf[40];
Lisp_Object saved_keys;
- struct gcpro gcpro1;
+ Lisp_Object bindings, value;
+ struct gcpro gcpro1, gcpro2;
saved_keys = Fvector (this_command_key_count,
XVECTOR (this_command_keys)->contents);
buf[0] = 0;
- GCPRO1 (saved_keys);
+ GCPRO2 (saved_keys, prefixarg);
if (EQ (prefixarg, Qminus))
strcpy (buf, "- ");
if (!NILP (Vsuggest_key_bindings)
&& NILP (Vexecuting_macro)
&& SYMBOLP (function))
- {
- Lisp_Object bindings;
+ bindings = Fwhere_is_internal (function, Voverriding_local_map,
+ Qt, Qnil);
+ else
+ bindings = Qnil;
- bindings = Fwhere_is_internal (function, Voverriding_local_map,
- Qt, Qnil);
+ value = Qnil;
+ GCPRO2 (bindings, value);
+ value = Fcommand_execute (function, Qt, Qnil, Qnil);
- if (!NILP (bindings))
+ /* If the command has a key binding, print it now. */
+ if (!NILP (bindings))
+ {
+ /* But first wait, and skip the message if there is input. */
+ if (!NILP (Fsit_for ((NUMBERP (Vsuggest_key_bindings)
+ ? Vsuggest_key_bindings : make_number (2)),
+ Qnil, Qnil)))
{
- message ("You can run the command `%s' by typing %s",
+ Lisp_Object binding;
+ char *newmessage;
+ char *oldmessage = echo_area_glyphs;
+ int oldmessage_len = echo_area_glyphs_length;
+
+ binding = Fkey_description (bindings);
+
+ newmessage
+ = (char *) alloca (XSYMBOL (function)->name->size
+ + XSTRING (binding)->size
+ + 100);
+ sprintf (newmessage, "You can run the command `%s' by typing %s",
XSYMBOL (function)->name->data,
- XSTRING (Fkey_description (bindings))->data);
- Fsit_for ((NUMBERP (Vsuggest_key_bindings)
- ? Vsuggest_key_bindings : make_number (2)),
- Qnil, Qnil);
+ XSTRING (binding)->data);
+ message1_nolog (newmessage);
+ if (!NILP (Fsit_for ((NUMBERP (Vsuggest_key_bindings)
+ ? Vsuggest_key_bindings : make_number (2)),
+ Qnil, Qnil)))
+ message2_nolog (oldmessage, oldmessage_len);
}
}
- return Fcommand_execute (function, Qt, Qnil, Qnil);
+ RETURN_UNGCPRO (value);
}
/* Find the set of keymaps now active.
return input_pending;
}
-/* Return nonzero if input events are pending.
- Execute timers immediately; don't make events for them. */
+/* Return nonzero if input events are pending, and run any pending timers. */
detect_input_pending_run_timers (do_display)
int do_display;
input_pending = 0;
}
+/* Return nonzero if there are pending requeued events.
+ This isn't used yet. The hope is to make wait_reading_process_input
+ call it, and return return if it runs Lisp code that unreads something.
+ The problem is, kbd_buffer_get_event needs to be fixed to know what
+ to do in that case. It isn't trivial. */
+
+requeued_events_pending_p ()
+{
+ return (!NILP (Vunread_command_events) || unread_command_char != -1);
+}
+
+
DEFUN ("input-pending-p", Finput_pending_p, Sinput_pending_p, 0, 0, 0,
"T if command input is currently available with no waiting.\n\
Actually, the value is nil only if we can be sure that no input is available.")
Lisp_Object stuffstring;
{
/* stuff_char works only in BSD, versions 4.2 and up. */
-#ifdef BSD
+#ifdef BSD_SYSTEM
#ifndef BSD4_1
register unsigned char *p;
}
input_pending = 0;
#endif
-#endif /* BSD and not BSD4_1 */
+#endif /* BSD_SYSTEM and not BSD4_1 */
}
\f
set_waiting_for_input (time_to_clear)
/* Must preserve main program's value of errno. */
int old_errno = errno;
-#ifdef USG
+#if defined (USG) && !defined (POSIX_SIGNALS)
if (!read_socket_hook && NILP (Vwindow_system))
{
/* USG systems forget handlers when they are used;
abort ();
#endif
#endif
-#ifdef MULTI_FRAME
if (FRAMEP (internal_last_event_frame)
&& XFRAME (internal_last_event_frame) != selected_frame)
do_switch_frame (make_lispy_switch_frame (internal_last_event_frame),
Qnil, 0);
-#endif
_longjmp (getcjmp, 1);
}
#endif
input_pending = 0;
-#ifdef MULTI_FRAME
/* This means that command_loop_1 won't try to select anything the first
time through. */
internal_last_event_frame = Qnil;
Vlast_event_frame = internal_last_event_frame;
-#endif
#ifdef MULTI_KBOARD
current_kboard = initial_kboard;
unread_switch_frame = Qnil;
staticpro (&unread_switch_frame);
+ internal_last_event_frame = Qnil;
+ staticpro (&internal_last_event_frame);
+
+ read_key_sequence_cmd = Qnil;
+ staticpro (&read_key_sequence_cmd);
+
defsubr (&Sevent_convert_list);
defsubr (&Sread_key_sequence);
defsubr (&Srecursive_edit);
inhibit_local_menu_bar_menus = 0;
DEFVAR_INT ("num-input-keys", &num_input_keys,
- "Number of complete keys read from the keyboard so far.");
+ "Number of complete key sequences read from the keyboard so far.\n\
+This includes key sequences read from keyboard macros.\n\
+The number is effectively the number of interactive command invocations.");
num_input_keys = 0;
DEFVAR_LISP ("last-event-frame", &Vlast_event_frame,
If the value is non-nil and not a number, we wait 2 seconds.");
Vsuggest_key_bindings = Qt;
- DEFVAR_LISP ("column-number-mode", &Vcolumn_number_mode,
- "Non-nil enables display of the current column number in the mode line.");
- Vcolumn_number_mode = Qnil;
-
DEFVAR_LISP ("timer-list", &Vtimer_list,
"List of active absolute time timers in order of increasing time");
Vtimer_list = Qnil;