static Lisp_Object Vauto_save_timeout;
/* Total number of times read_char has returned. */
-int num_input_chars;
+int num_input_events;
/* Total number of times read_char has returned, outside of macros. */
-int num_nonmacro_input_chars;
+int num_nonmacro_input_events;
/* Auto-save automatically when this many characters have been typed
since the last time. */
static int auto_save_interval;
-/* Value of num_nonmacro_input_chars as of last auto save. */
+/* Value of num_nonmacro_input_events as of last auto save. */
int last_auto_save;
static void record_menu_key ();
+void swallow_events ();
+
Lisp_Object Qpolling_period;
/* List of absolute timers. Appears in order of next scheduled event. */
record_auto_save ()
{
- last_auto_save = num_nonmacro_input_chars;
+ last_auto_save = num_nonmacro_input_events;
}
/* Make an auto save happen as soon as possible at command level. */
{
if (NILP (Vunread_command_events)
&& NILP (Vexecuting_macro)
- && !NILP (sit_for (0, post_command_idle_delay, 0, 1)))
+ && !NILP (sit_for (0, post_command_idle_delay, 0, 1, 1)))
safe_run_hooks (Qpost_command_idle_hook);
}
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);
{
if (NILP (Vunread_command_events)
&& NILP (Vexecuting_macro)
- && !NILP (sit_for (0, post_command_idle_delay, 0, 1)))
+ && !NILP (sit_for (0, post_command_idle_delay, 0, 1, 1)))
safe_run_hooks (Qpost_command_idle_hook);
}
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
{
save_getcjmp (save_jump);
restore_getcjmp (local_getcjmp);
- tem0 = sit_for (echo_keystrokes, 0, 1, 1);
+ 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 ();
}
}
if (commandflag != 0
&& auto_save_interval > 0
- && num_nonmacro_input_chars - last_auto_save > max (auto_save_interval, 20)
+ && num_nonmacro_input_events - last_auto_save > max (auto_save_interval, 20)
&& !detect_input_pending_run_timers (0))
{
Fdo_auto_save (Qnil, Qnil);
/* Auto save if enough time goes by without input. */
if (commandflag != 0
- && num_nonmacro_input_chars > last_auto_save
+ && num_nonmacro_input_events > last_auto_save
&& INTEGERP (Vauto_save_timeout)
&& XINT (Vauto_save_timeout) > 0)
{
save_getcjmp (save_jump);
restore_getcjmp (local_getcjmp);
tem0 = sit_for (delay_level * XFASTINT (Vauto_save_timeout) / 4,
- 0, 1, 1);
+ 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))
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 ();
/* Re-reading in the middle of a command */
reread:
last_input_char = c;
- num_input_chars++;
+ num_input_events++;
/* Process the help character specially if enabled */
if (!NILP (Vhelp_form) && help_char_p (c))
/* Re-reading in the middle of a command */
last_input_char = c;
- num_input_chars++;
+ num_input_events++;
}
/* Return 1 if should recognize C as "the help character". */
store_kbd_macro_char (c);
- num_nonmacro_input_chars++;
+ num_nonmacro_input_events++;
}
Lisp_Object
#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;
}
/* Save the status of key translation before each step,
so that we can restore this after downcasing. */
Lisp_Object prev_fkey_map;
- Lisp_Object prev_fkey_start;
- Lisp_Object prev_fkey_end;
+ int prev_fkey_start;
+ int prev_fkey_end;
Lisp_Object prev_keytran_map;
- Lisp_Object prev_keytran_start;
- Lisp_Object prev_keytran_end;
+ int prev_keytran_start;
+ int prev_keytran_end;
int junk;
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;
inhibit_local_menu_bar_menus = 0;
DEFVAR_INT ("num-input-keys", &num_input_keys,
- "Number of complete key sequences read from the keyboard so far.\n\
+ "Number of complete key sequences read as input 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_INT ("num-nonmacro-input-chars", &num_nonmacro_input_chars,
- "Number of characters read from the keyboard so far.\n\
-Does not include characters read from keyboard macros.");
- num_nonmacro_input_chars = 0;
+ DEFVAR_INT ("num-nonmacro-input-events", &num_nonmacro_input_events,
+ "Number of input events read from the keyboard so far.\n\
+This does not include events generated by keyboard macros.");
+ num_nonmacro_input_events = 0;
DEFVAR_LISP ("last-event-frame", &Vlast_event_frame,
"The frame in which the most recently read event occurred.\n\
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\