static void record_menu_key ();
+void swallow_events ();
+
Lisp_Object Qpolling_period;
/* List of absolute timers. Appears in order of next scheduled event. */
Fsit_for (make_number (2), Qnil, Qnil);
/* Clear the echo area. */
- message2 (0);
+ message2 (0, 0);
safe_run_hooks (Qecho_area_clear_hook);
unbind_to (count, Qnil);
Lisp_Object prev_event;
int *used_mouse_menu;
{
- register Lisp_Object c;
+ Lisp_Object c;
int count;
jmp_buf local_getcjmp;
jmp_buf save_jump;
int key_already_recorded = 0;
Lisp_Object tem, save;
Lisp_Object also_record;
+ struct gcpro gcpro1;
+
also_record = Qnil;
before_command_key_count = this_command_key_count;
before_command_echo_length = echo_length ();
+ c = Qnil;
+
+ GCPRO1 (c);
retry:
|| executing_macro_index >= XFASTINT (Flength (Vexecuting_macro)))
{
XSETINT (c, -1);
- return c;
+ RETURN_UNGCPRO (c);
}
c = Faref (Vexecuting_macro, make_number (executing_macro_index));
goto reread_first;
}
- if (commandflag >= 0 && !input_pending
- && !detect_input_pending_run_timers (0))
- redisplay ();
+ if (commandflag >= 0)
+ {
+ if (input_pending
+ || detect_input_pending_run_timers (0))
+ swallow_events (0);
+
+ if (!input_pending)
+ redisplay ();
+ }
/* Message turns off echoing unless more keystrokes turn it on again. */
if (echo_area_glyphs && *echo_area_glyphs
*tailp = Fcons (c, Qnil);
kb->kbd_queue_has_data = 1;
current_kboard = kb;
+ /* This is going to exit from read_char
+ so we had better get rid of this frame's stuff. */
+ UNGCPRO;
longjmp (wrong_kboard_jmpbuf, 1);
}
}
restore_getcjmp (local_getcjmp);
tem0 = sit_for (echo_keystrokes, 0, 1, 1, 0);
restore_getcjmp (save_jump);
- if (EQ (tem0, Qt))
+ if (EQ (tem0, Qt)
+ && ! CONSP (Vunread_command_events))
echo_now ();
}
}
/* Now that we have read an event, Emacs is not idle. */
timer_stop_idle ();
- return c;
+ RETURN_UNGCPRO (c);
}
/* Maybe autosave and/or garbage collect due to idleness. */
0, 1, 1, 0);
restore_getcjmp (save_jump);
- if (EQ (tem0, Qt))
+ if (EQ (tem0, Qt)
+ && ! CONSP (Vunread_command_events))
{
Fdo_auto_save (Qnil, Qnil);
}
}
+ /* If this has become non-nil here, it has been set by a timer
+ or sentinel or filter. */
+ if (CONSP (Vunread_command_events))
+ {
+ c = XCONS (Vunread_command_events)->car;
+ Vunread_command_events = XCONS (Vunread_command_events)->cdr;
+ }
+
/* Read something from current KBOARD's side queue, if possible. */
if (NILP (c))
if (kb->kbd_queue_has_data)
{
current_kboard = kb;
+ /* This is going to exit from read_char
+ so we had better get rid of this frame's stuff. */
+ UNGCPRO;
longjmp (wrong_kboard_jmpbuf, 1);
}
}
if (single_kboard)
goto wrong_kboard;
current_kboard = kb;
+ /* This is going to exit from read_char
+ so we had better get rid of this frame's stuff. */
+ UNGCPRO;
longjmp (wrong_kboard_jmpbuf, 1);
}
#endif
non_reread:
- /* Now that we have read an event, Emacs is not idle--
- unless the event was a timer event (not used now). */
- if (! CONSP (c))
- timer_stop_idle ();
+ timer_stop_idle ();
start_polling ();
non_reread_1:
/* Buffer switch events are only for internal wakeups
- so don't show them to the user. */
- if (BUFFERP (c))
- return c;
-
- if (key_already_recorded)
- return c;
+ so don't show them to the user.
+ Also, don't record a key if we already did. */
+ if (BUFFERP (c) || key_already_recorded)
+ RETURN_UNGCPRO (c);
/* Process special events within read_char
and loop around to read another event. */
{
/* If kbd_buffer_get_event gave us an EOF, return that. */
if (XINT (c) == -1)
- return c;
+ RETURN_UNGCPRO (c);
if (STRINGP (Vkeyboard_translate_table)
&& XSTRING (Vkeyboard_translate_table)->size > (unsigned) XFASTINT (c))
from_macro:
reread_first:
+
before_command_key_count = this_command_key_count;
before_command_echo_length = echo_length ();
}
}
- return c;
+ RETURN_UNGCPRO (c);
}
/* Record a key that came from a mouse menu.
#endif /* not VMS */
}
+ if (CONSP (Vunread_command_events))
+ {
+ Lisp_Object first;
+ first = XCONS (Vunread_command_events)->car;
+ Vunread_command_events = XCONS (Vunread_command_events)->cdr;
+ *kbp = current_kboard;
+ return first;
+ }
+
/* At this point, we know that there is a readable event available
somewhere. If the event queue is empty, then there must be a
mouse movement enabled and available. */
c |= (event->modifiers
& (meta_modifier | alt_modifier
| hyper_modifier | super_modifier));
+ /* Distinguish Shift-SPC from SPC. */
+ if ((event->code & 0377) == 040
+ && event->modifiers & shift_modifier)
+ c |= shift_modifier;
button_down_time = 0;
XSETFASTINT (lispy_c, c);
return lispy_c;
/ sizeof (lispy_kana_keys[0])));
#endif /* XK_kana_A */
+#ifdef ISO_FUNCTION_KEY_OFFSET
if (event->code < FUNCTION_KEY_OFFSET
&& event->code >= ISO_FUNCTION_KEY_OFFSET)
return modify_event_symbol (event->code - ISO_FUNCTION_KEY_OFFSET,
(sizeof (iso_lispy_function_keys)
/ sizeof (iso_lispy_function_keys[0])));
else
+#endif
return modify_event_symbol (event->code - FUNCTION_KEY_OFFSET,
event->modifiers,
Qfunction_key, Qnil,
#else
nread = read (input_fd, cbuf, n_to_read);
#endif
+ /* POSIX infers that processes which are not in the session leader's
+ process group won't get SIGHUP's at logout time. BSDI adheres to
+ this part standard and returns -1 from read(0) with errno==EIO
+ when the control tty is taken away.
+ Jeffrey Honig <jch@bsdi.com> says this is generally safe. */
+ if (nread == -1 && errno == EIO)
+ kill (0, SIGHUP);
#if defined (AIX) && (! defined (aix386) && defined (_BSD))
/* The kernel sometimes fails to deliver SIGHUP for ptys.
This looks incorrect, but it isn't, because _BSD causes
for (mapno = nmaps - 1; mapno >= 0; mapno--)
{
if (! NILP (maps[mapno]))
- def = get_keyelt (access_keymap (maps[mapno], Qmenu_bar, 1, 0));
+ def = get_keyelt (access_keymap (maps[mapno], Qmenu_bar, 1, 0), 0);
else
def = Qnil;
{
Lisp_Object def;
def = get_keyelt (access_keymap (current[i],
- meta_prefix_char, 1, 0));
+ meta_prefix_char, 1, 0), 0);
/* Note that since we pass the resulting bindings through
get_keymap_1, non-prefix bindings for meta-prefix-char
else
map = current[i];
- defs[i] = get_keyelt (access_keymap (map, key, 1, 0));
+ defs[i] = get_keyelt (access_keymap (map, key, 1, 0), 0);
if (! NILP (defs[i]))
first_binding = i;
}
fkey_next
= get_keymap_1
(get_keyelt
- (access_keymap (fkey_map, meta_prefix_char, 1, 0)),
+ (access_keymap (fkey_map, meta_prefix_char, 1, 0), 0),
0, 1);
XSETFASTINT (key, XFASTINT (key) & ~meta_modifier);
}
fkey_next = fkey_map;
fkey_next
- = get_keyelt (access_keymap (fkey_next, key, 1, 0));
+ = get_keyelt (access_keymap (fkey_next, key, 1, 0), 0);
#if 0 /* I didn't turn this on, because it might cause trouble
for the mapping of return into C-m and tab into C-i. */
keytran_next
= get_keymap_1
(get_keyelt
- (access_keymap (keytran_map, meta_prefix_char, 1, 0)),
+ (access_keymap (keytran_map, meta_prefix_char, 1, 0), 0),
0, 1);
XSETFASTINT (key, XFASTINT (key) & ~meta_modifier);
}
keytran_next = keytran_map;
keytran_next
- = get_keyelt (access_keymap (keytran_next, key, 1, 0));
+ = get_keyelt (access_keymap (keytran_next, key, 1, 0), 0);
/* If the key translation map gives a function, not an
array, then call the function with no args and use
/* 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)))
+ Qnil, Qnil))
+ && ! CONSP (Vunread_command_events))
{
Lisp_Object binding;
char *newmessage;
DEFVAR_KBOARD ("overriding-terminal-local-map",
Voverriding_terminal_local_map,
- "Keymap that overrides all other local keymaps.\n\
+ "Per-terminal keymap that overrides all other local keymaps.\n\
If this variable is non-nil, it is used as a keymap instead of the\n\
-buffer's local map, and the minor mode keymaps and text property keymaps.");
+buffer's local map, and the minor mode keymaps and text property keymaps.\n\
+This variable is intended to let commands such as `universal-argumemnt'\n\
+set up a different keymap for reading the next command.");
DEFVAR_LISP ("overriding-local-map", &Voverriding_local_map,
"Keymap that overrides all other local keymaps.\n\