summaryrefslogtreecommitdiff
path: root/src/keyboard.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/keyboard.c')
-rw-r--r--src/keyboard.c1164
1 files changed, 554 insertions, 610 deletions
diff --git a/src/keyboard.c b/src/keyboard.c
index 49c687f69a8..9e38bb21f6e 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -43,6 +43,7 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
#include "systime.h"
#include "atimer.h"
#include "process.h"
+#include "menu.h"
#include <errno.h>
#ifdef HAVE_PTHREAD
@@ -91,7 +92,7 @@ volatile int interrupt_input_blocked;
The maybe_quit function checks this. */
volatile bool pending_signals;
-#define KBD_BUFFER_SIZE 4096
+enum { KBD_BUFFER_SIZE = 4096 };
KBOARD *initial_kboard;
KBOARD *current_kboard;
@@ -285,15 +286,11 @@ static bool input_was_pending;
static union buffered_input_event kbd_buffer[KBD_BUFFER_SIZE];
/* Pointer to next available character in kbd_buffer.
- If kbd_fetch_ptr == kbd_store_ptr, the buffer is empty.
- This may be kbd_buffer + KBD_BUFFER_SIZE, meaning that the
- next available char is in kbd_buffer[0]. */
+ If kbd_fetch_ptr == kbd_store_ptr, the buffer is empty. */
static union buffered_input_event *kbd_fetch_ptr;
-/* Pointer to next place to store character in kbd_buffer. This
- may be kbd_buffer + KBD_BUFFER_SIZE, meaning that the next
- character should go in kbd_buffer[0]. */
-static union buffered_input_event *volatile kbd_store_ptr;
+/* Pointer to next place to store character in kbd_buffer. */
+static union buffered_input_event *kbd_store_ptr;
/* The above pair of variables forms a "queue empty" flag. When we
enqueue a non-hook event, we increment kbd_store_ptr. When we
@@ -301,8 +298,7 @@ static union buffered_input_event *volatile kbd_store_ptr;
there is input available if the two pointers are not equal.
Why not just have a flag set and cleared by the enqueuing and
- dequeuing functions? Such a flag could be screwed up by interrupts
- at inopportune times. */
+ dequeuing functions? The code is a bit simpler this way. */
static void recursive_edit_unwind (Lisp_Object buffer);
static Lisp_Object command_loop (void);
@@ -359,9 +355,7 @@ static Lisp_Object modify_event_symbol (ptrdiff_t, int, Lisp_Object,
Lisp_Object *, ptrdiff_t);
static Lisp_Object make_lispy_switch_frame (Lisp_Object);
static Lisp_Object make_lispy_focus_in (Lisp_Object);
-#ifdef HAVE_WINDOW_SYSTEM
static Lisp_Object make_lispy_focus_out (Lisp_Object);
-#endif /* HAVE_WINDOW_SYSTEM */
static bool help_char_p (Lisp_Object);
static void save_getcjmp (sys_jmp_buf);
static void restore_getcjmp (sys_jmp_buf);
@@ -376,6 +370,29 @@ static void deliver_user_signal (int);
static char *find_user_signal_name (int);
static void store_user_signal_events (void);
+/* Advance or retreat a buffered input event pointer. */
+
+static union buffered_input_event *
+next_kbd_event (union buffered_input_event *ptr)
+{
+ return ptr == kbd_buffer + KBD_BUFFER_SIZE - 1 ? kbd_buffer : ptr + 1;
+}
+
+static union buffered_input_event *
+prev_kbd_event (union buffered_input_event *ptr)
+{
+ return ptr == kbd_buffer ? kbd_buffer + KBD_BUFFER_SIZE - 1 : ptr - 1;
+}
+
+/* Like EVENT_START, but assume EVENT is an event.
+ This pacifies gcc -Wnull-dereference, which might otherwise
+ complain about earlier checks that EVENT is indeed an event. */
+static Lisp_Object
+xevent_start (Lisp_Object event)
+{
+ return XCAR (XCDR (event));
+}
+
/* These setters are used only in this file, so they can be private. */
static void
kset_echo_string (struct kboard *kb, Lisp_Object val)
@@ -433,7 +450,7 @@ static bool
echo_keystrokes_p (void)
{
return (FLOATP (Vecho_keystrokes) ? XFLOAT_DATA (Vecho_keystrokes) > 0.0
- : INTEGERP (Vecho_keystrokes) ? XINT (Vecho_keystrokes) > 0
+ : FIXNUMP (Vecho_keystrokes) ? XFIXNUM (Vecho_keystrokes) > 0
: false);
}
@@ -458,8 +475,8 @@ echo_add_key (Lisp_Object c)
/* If someone has passed us a composite event, use its head symbol. */
c = EVENT_HEAD (c);
- if (INTEGERP (c))
- ptr = push_key_description (XINT (c), ptr);
+ if (FIXNUMP (c))
+ ptr = push_key_description (XFIXNUM (c), ptr);
else if (SYMBOLP (c))
{
Lisp_Object name = SYMBOL_NAME (c);
@@ -527,13 +544,13 @@ echo_dash (void)
{
Lisp_Object last_char, prev_char, idx;
- idx = make_number (SCHARS (KVAR (current_kboard, echo_string)) - 2);
+ idx = make_fixnum (SCHARS (KVAR (current_kboard, echo_string)) - 2);
prev_char = Faref (KVAR (current_kboard, echo_string), idx);
- idx = make_number (SCHARS (KVAR (current_kboard, echo_string)) - 1);
+ idx = make_fixnum (SCHARS (KVAR (current_kboard, echo_string)) - 1);
last_char = Faref (KVAR (current_kboard, echo_string), idx);
- if (XINT (last_char) == '-' && XINT (prev_char) != ' ')
+ if (XFIXNUM (last_char) == '-' && XFIXNUM (prev_char) != ' ')
return;
}
@@ -635,7 +652,7 @@ echo_truncate (ptrdiff_t nchars)
if (STRINGP (es) && SCHARS (es) > nchars)
kset_echo_string (current_kboard,
Fsubstring (KVAR (current_kboard, echo_string),
- make_number (0), make_number (nchars)));
+ make_fixnum (0), make_fixnum (nchars)));
truncate_echo_area (nchars);
}
@@ -778,35 +795,6 @@ recursive_edit_unwind (Lisp_Object buffer)
}
-#if 0 /* These two functions are now replaced with
- temporarily_switch_to_single_kboard. */
-static void
-any_kboard_state ()
-{
-#if 0 /* Theory: if there's anything in Vunread_command_events,
- it will right away be read by read_key_sequence,
- and then if we do switch KBOARDS, it will go into the side
- queue then. So we don't need to do anything special here -- rms. */
- if (CONSP (Vunread_command_events))
- {
- current_kboard->kbd_queue
- = nconc2 (Vunread_command_events, current_kboard->kbd_queue);
- current_kboard->kbd_queue_has_data = true;
- }
- Vunread_command_events = Qnil;
-#endif
- single_kboard = false;
-}
-
-/* Switch to the single-kboard state, making current_kboard
- the only KBOARD from which further input is accepted. */
-
-void
-single_kboard_state ()
-{
- single_kboard = true;
-}
-#endif
/* If we're in single_kboard state for kboard KBOARD,
get out of it. */
@@ -905,16 +893,6 @@ temporarily_switch_to_single_kboard (struct frame *f)
record_unwind_protect_int (restore_kboard_configuration, was_locked);
}
-#if 0 /* This function is not needed anymore. */
-void
-record_single_kboard_state ()
-{
- if (single_kboard)
- push_kboard (current_kboard);
- record_unwind_protect_int (restore_kboard_configuration, single_kboard);
-}
-#endif
-
static void
restore_kboard_configuration (int was_locked)
{
@@ -976,7 +954,7 @@ cmd_error (Lisp_Object data)
Vquit_flag = Qnil;
Vinhibit_quit = Qnil;
- return make_number (0);
+ return make_fixnum (0);
}
/* Take actions on handling an error. DATA is the data that describes
@@ -1036,7 +1014,7 @@ Default value of `command-error-function'. */)
print_error_message (data, Qexternal_debugging_output,
SSDATA (context), signal);
Fterpri (Qexternal_debugging_output, Qnil);
- Fkill_emacs (make_number (-1));
+ Fkill_emacs (make_fixnum (-1));
}
else
{
@@ -1250,7 +1228,8 @@ some_mouse_moved (void)
/* This is the actual command reading loop,
sans error-handling encapsulation. */
-static int read_key_sequence (Lisp_Object *, int, Lisp_Object,
+enum { READ_KEY_ELTS = 30 };
+static int read_key_sequence (Lisp_Object *, Lisp_Object,
bool, bool, bool, bool);
static void adjust_point_for_property (ptrdiff_t, bool);
@@ -1298,11 +1277,9 @@ command_loop_1 (void)
if (!CONSP (last_command_event))
kset_last_repeatable_command (current_kboard, Vreal_this_command);
- while (1)
+ while (true)
{
Lisp_Object cmd;
- Lisp_Object keybuf[30];
- int i;
if (! FRAME_LIVE_P (XFRAME (selected_frame)))
Fkill_emacs (Qnil);
@@ -1349,7 +1326,7 @@ command_loop_1 (void)
if (!NILP (Vquit_flag))
{
Vquit_flag = Qnil;
- Vunread_command_events = list1 (make_number (quit_char));
+ Vunread_command_events = list1 (make_fixnum (quit_char));
}
}
@@ -1365,8 +1342,9 @@ command_loop_1 (void)
Vthis_command_keys_shift_translated = Qnil;
/* Read next key sequence; i gets its length. */
- i = read_key_sequence (keybuf, ARRAYELTS (keybuf),
- Qnil, 0, 1, 1, 0);
+ raw_keybuf_count = 0;
+ Lisp_Object keybuf[READ_KEY_ELTS];
+ int i = read_key_sequence (keybuf, Qnil, false, true, true, false);
/* A filter may have run while we were reading the input. */
if (! FRAME_LIVE_P (XFRAME (selected_frame)))
@@ -1556,7 +1534,7 @@ command_loop_1 (void)
{
Lisp_Object txt
= call1 (Fsymbol_value (Qregion_extract_function), Qnil);
- if (XINT (Flength (txt)) > 0)
+ if (XFIXNUM (Flength (txt)) > 0)
/* Don't set empty selections. */
call2 (Qgui_set_selection, QPRIMARY, txt);
}
@@ -1602,16 +1580,14 @@ command_loop_1 (void)
Lisp_Object
read_menu_command (void)
{
- Lisp_Object keybuf[30];
ptrdiff_t count = SPECPDL_INDEX ();
- int i;
/* We don't want to echo the keystrokes while navigating the
menus. */
- specbind (Qecho_keystrokes, make_number (0));
+ specbind (Qecho_keystrokes, make_fixnum (0));
- i = read_key_sequence (keybuf, ARRAYELTS (keybuf),
- Qnil, 0, 1, 1, 1);
+ Lisp_Object keybuf[READ_KEY_ELTS];
+ int i = read_key_sequence (keybuf, Qnil, false, true, true, true);
unbind_to (count, Qnil);
@@ -1659,7 +1635,7 @@ adjust_point_for_property (ptrdiff_t last_pt, bool modified)
if (check_display
&& PT > BEGV && PT < ZV
&& !NILP (val = get_char_property_and_overlay
- (make_number (PT), Qdisplay, selected_window,
+ (make_fixnum (PT), Qdisplay, selected_window,
&overlay))
&& display_prop_intangible_p (val, overlay, PT, PT_BYTE)
&& (!OVERLAYP (overlay)
@@ -1696,12 +1672,12 @@ adjust_point_for_property (ptrdiff_t last_pt, bool modified)
than skip both boundaries. However, this code
also stops anywhere in a non-sticky text-property,
which breaks (e.g.) Org mode. */
- && (val = Fget_pos_property (make_number (end),
+ && (val = Fget_pos_property (make_fixnum (end),
Qinvisible, Qnil),
TEXT_PROP_MEANS_INVISIBLE (val))
#endif
&& !NILP (val = get_char_property_and_overlay
- (make_number (end), Qinvisible, Qnil, &overlay))
+ (make_fixnum (end), Qinvisible, Qnil, &overlay))
&& (inv = TEXT_PROP_MEANS_INVISIBLE (val)))
{
ellipsis = ellipsis || inv > 1
@@ -1709,17 +1685,17 @@ adjust_point_for_property (ptrdiff_t last_pt, bool modified)
&& (!NILP (Foverlay_get (overlay, Qafter_string))
|| !NILP (Foverlay_get (overlay, Qbefore_string))));
tmp = Fnext_single_char_property_change
- (make_number (end), Qinvisible, Qnil, Qnil);
- end = NATNUMP (tmp) ? XFASTINT (tmp) : ZV;
+ (make_fixnum (end), Qinvisible, Qnil, Qnil);
+ end = FIXNATP (tmp) ? XFIXNAT (tmp) : ZV;
}
while (beg > BEGV
#if 0
- && (val = Fget_pos_property (make_number (beg),
+ && (val = Fget_pos_property (make_fixnum (beg),
Qinvisible, Qnil),
TEXT_PROP_MEANS_INVISIBLE (val))
#endif
&& !NILP (val = get_char_property_and_overlay
- (make_number (beg - 1), Qinvisible, Qnil, &overlay))
+ (make_fixnum (beg - 1), Qinvisible, Qnil, &overlay))
&& (inv = TEXT_PROP_MEANS_INVISIBLE (val)))
{
ellipsis = ellipsis || inv > 1
@@ -1727,8 +1703,8 @@ adjust_point_for_property (ptrdiff_t last_pt, bool modified)
&& (!NILP (Foverlay_get (overlay, Qafter_string))
|| !NILP (Foverlay_get (overlay, Qbefore_string))));
tmp = Fprevious_single_char_property_change
- (make_number (beg), Qinvisible, Qnil, Qnil);
- beg = NATNUMP (tmp) ? XFASTINT (tmp) : BEGV;
+ (make_fixnum (beg), Qinvisible, Qnil, Qnil);
+ beg = FIXNATP (tmp) ? XFIXNAT (tmp) : BEGV;
}
/* Move away from the inside area. */
@@ -1768,11 +1744,11 @@ adjust_point_for_property (ptrdiff_t last_pt, bool modified)
to the other end would mean moving backwards and thus
could lead to an infinite loop. */
;
- else if (val = Fget_pos_property (make_number (PT),
+ else if (val = Fget_pos_property (make_fixnum (PT),
Qinvisible, Qnil),
TEXT_PROP_MEANS_INVISIBLE (val)
&& (val = (Fget_pos_property
- (make_number (PT == beg ? end : beg),
+ (make_fixnum (PT == beg ? end : beg),
Qinvisible, Qnil)),
!TEXT_PROP_MEANS_INVISIBLE (val)))
(check_composition = check_display = true,
@@ -1869,6 +1845,7 @@ int poll_suppress_count;
static struct atimer *poll_timer;
+#if defined CYGWIN || defined DOS_NT
/* Poll for input, so that we catch a C-g if it comes in. */
void
poll_for_input_1 (void)
@@ -1877,6 +1854,7 @@ poll_for_input_1 (void)
&& !waiting_for_input)
gobble_input ();
}
+#endif
/* Timer callback function for poll_timer. TIMER is equal to
poll_timer. */
@@ -1928,20 +1906,22 @@ start_polling (void)
#endif
}
+#if defined CYGWIN || defined DOS_NT
/* True if we are using polling to handle input asynchronously. */
bool
input_polling_used (void)
{
-#ifdef POLL_FOR_INPUT
+# ifdef POLL_FOR_INPUT
/* XXX This condition was (read_socket_hook && !interrupt_input),
but read_socket_hook is not global anymore. Let's pretend that
it's always set. */
return !interrupt_input;
-#else
- return 0;
-#endif
+# else
+ return false;
+# endif
}
+#endif
/* Turn off polling. */
@@ -1991,7 +1971,7 @@ bind_polling_period (int n)
stop_other_atimers (poll_timer);
stop_polling ();
- specbind (Qpolling_period, make_number (new));
+ specbind (Qpolling_period, make_fixnum (new));
/* Start a new alarm with the new period. */
start_polling ();
#endif
@@ -2170,25 +2150,25 @@ read_event_from_main_queue (struct timespec *end_time,
if (single_kboard)
goto start;
current_kboard = kb;
- return make_number (-2);
+ return make_fixnum (-2);
}
/* Terminate Emacs in batch mode if at eof. */
- if (noninteractive && INTEGERP (c) && XINT (c) < 0)
- Fkill_emacs (make_number (1));
+ if (noninteractive && FIXNUMP (c) && XFIXNUM (c) < 0)
+ Fkill_emacs (make_fixnum (1));
- if (INTEGERP (c))
+ if (FIXNUMP (c))
{
/* Add in any extra modifiers, where appropriate. */
if ((extra_keyboard_modifiers & CHAR_CTL)
|| ((extra_keyboard_modifiers & 0177) < ' '
&& (extra_keyboard_modifiers & 0177) != 0))
- XSETINT (c, make_ctrl_char (XINT (c)));
+ XSETINT (c, make_ctrl_char (XFIXNUM (c)));
/* Transfer any other modifier bits directly from
extra_keyboard_modifiers to c. Ignore the actual character code
in the low 16 bits of extra_keyboard_modifiers. */
- XSETINT (c, XINT (c) | (extra_keyboard_modifiers & ~0xff7f & ~CHAR_CTL));
+ XSETINT (c, XFIXNUM (c) | (extra_keyboard_modifiers & ~0xff7f & ~CHAR_CTL));
}
return c;
@@ -2236,8 +2216,8 @@ read_decoded_event_from_main_queue (struct timespec *end_time,
int meta_key = terminal->display_info.tty->meta_key;
eassert (n < MAX_ENCODED_BYTES);
events[n++] = nextevt;
- if (NATNUMP (nextevt)
- && XINT (nextevt) < (meta_key == 1 ? 0x80 : 0x100))
+ if (FIXNATP (nextevt)
+ && XFIXNUM (nextevt) < (meta_key == 1 ? 0x80 : 0x100))
{ /* An encoded byte sequence, let's try to decode it. */
struct coding_system *coding
= TERMINAL_KEYBOARD_CODING (terminal);
@@ -2247,7 +2227,7 @@ read_decoded_event_from_main_queue (struct timespec *end_time,
int i;
if (meta_key != 2)
for (i = 0; i < n; i++)
- events[i] = make_number (XINT (events[i]) & ~0x80);
+ events[i] = make_fixnum (XFIXNUM (events[i]) & ~0x80);
}
else
{
@@ -2255,7 +2235,7 @@ read_decoded_event_from_main_queue (struct timespec *end_time,
unsigned char dest[MAX_ENCODED_BYTES * MAX_MULTIBYTE_LENGTH];
int i;
for (i = 0; i < n; i++)
- src[i] = XINT (events[i]);
+ src[i] = XFIXNUM (events[i]);
if (meta_key != 2)
for (i = 0; i < n; i++)
src[i] &= ~0x80;
@@ -2274,7 +2254,7 @@ read_decoded_event_from_main_queue (struct timespec *end_time,
eassert (coding->carryover_bytes == 0);
n = 0;
while (n < coding->produced_char)
- events[n++] = make_number (STRING_CHAR_ADVANCE (p));
+ events[n++] = make_fixnum (STRING_CHAR_ADVANCE (p));
}
}
}
@@ -2352,7 +2332,7 @@ read_char (int commandflag, Lisp_Object map,
/* Undo what read_char_x_menu_prompt did when it unread
additional keys returned by Fx_popup_menu. */
if (CONSP (c)
- && (SYMBOLP (XCAR (c)) || INTEGERP (XCAR (c)))
+ && (SYMBOLP (XCAR (c)) || FIXNUMP (XCAR (c)))
&& NILP (XCDR (c)))
c = XCAR (c);
@@ -2382,7 +2362,7 @@ read_char (int commandflag, Lisp_Object map,
additional keys returned by Fx_popup_menu. */
if (CONSP (c)
&& EQ (XCDR (c), Qdisabled)
- && (SYMBOLP (XCAR (c)) || INTEGERP (XCAR (c))))
+ && (SYMBOLP (XCAR (c)) || FIXNUMP (XCAR (c))))
{
was_disabled = true;
c = XCAR (c);
@@ -2407,7 +2387,7 @@ read_char (int commandflag, Lisp_Object map,
/* Undo what read_char_x_menu_prompt did when it unread
additional keys returned by Fx_popup_menu. */
if (CONSP (c)
- && (SYMBOLP (XCAR (c)) || INTEGERP (XCAR (c)))
+ && (SYMBOLP (XCAR (c)) || FIXNUMP (XCAR (c)))
&& NILP (XCDR (c)))
c = XCAR (c);
reread = true;
@@ -2432,16 +2412,16 @@ read_char (int commandflag, Lisp_Object map,
Also, some things replace the macro with t
to force an early exit. */
if (EQ (Vexecuting_kbd_macro, Qt)
- || executing_kbd_macro_index >= XFASTINT (Flength (Vexecuting_kbd_macro)))
+ || executing_kbd_macro_index >= XFIXNAT (Flength (Vexecuting_kbd_macro)))
{
XSETINT (c, -1);
goto exit;
}
- c = Faref (Vexecuting_kbd_macro, make_number (executing_kbd_macro_index));
+ c = Faref (Vexecuting_kbd_macro, make_fixnum (executing_kbd_macro_index));
if (STRINGP (Vexecuting_kbd_macro)
- && (XFASTINT (c) & 0x80) && (XFASTINT (c) <= 0xff))
- XSETFASTINT (c, CHAR_META | (XFASTINT (c) & ~0x80));
+ && (XFIXNAT (c) & 0x80) && (XFIXNAT (c) <= 0xff))
+ XSETFASTINT (c, CHAR_META | (XFIXNAT (c) & ~0x80));
executing_kbd_macro_index++;
@@ -2545,7 +2525,7 @@ read_char (int commandflag, Lisp_Object map,
{
c = read_char_minibuf_menu_prompt (commandflag, map);
- if (INTEGERP (c) && XINT (c) == -2)
+ if (FIXNUMP (c) && XFIXNUM (c) == -2)
return c; /* wrong_kboard_jmpbuf */
if (! NILP (c))
@@ -2596,7 +2576,7 @@ read_char (int commandflag, Lisp_Object map,
XSETCDR (last, list1 (c));
kb->kbd_queue_has_data = true;
current_kboard = kb;
- return make_number (-2); /* wrong_kboard_jmpbuf */
+ return make_fixnum (-2); /* wrong_kboard_jmpbuf */
}
}
goto non_reread;
@@ -2655,7 +2635,7 @@ read_char (int commandflag, Lisp_Object map,
&& num_nonmacro_input_events - last_auto_save > max (auto_save_interval, 20)
&& !detect_input_pending_run_timers (0))
{
- Fdo_auto_save (Qnil, Qnil);
+ Fdo_auto_save (auto_save_no_message ? Qt : Qnil, Qnil);
/* Hooks can actually change some buffers in auto save. */
redisplay ();
}
@@ -2704,23 +2684,23 @@ read_char (int commandflag, Lisp_Object map,
/* Auto save if enough time goes by without input. */
if (commandflag != 0 && commandflag != -2
&& num_nonmacro_input_events > last_auto_save
- && INTEGERP (Vauto_save_timeout)
- && XINT (Vauto_save_timeout) > 0)
+ && FIXNUMP (Vauto_save_timeout)
+ && XFIXNUM (Vauto_save_timeout) > 0)
{
Lisp_Object tem0;
- EMACS_INT timeout = XFASTINT (Vauto_save_timeout);
+ EMACS_INT timeout = XFIXNAT (Vauto_save_timeout);
timeout = min (timeout, MOST_POSITIVE_FIXNUM / delay_level * 4);
timeout = delay_level * timeout / 4;
save_getcjmp (save_jump);
restore_getcjmp (local_getcjmp);
- tem0 = sit_for (make_number (timeout), 1, 1);
+ tem0 = sit_for (make_fixnum (timeout), 1, 1);
restore_getcjmp (save_jump);
if (EQ (tem0, Qt)
&& ! CONSP (Vunread_command_events))
{
- Fdo_auto_save (Qnil, Qnil);
+ Fdo_auto_save (auto_save_no_message ? Qt : Qnil, Qnil);
redisplay ();
}
}
@@ -2738,7 +2718,7 @@ read_char (int commandflag, Lisp_Object map,
interpret the next key sequence using the wrong translation
tables and function keymaps. */
if (NILP (c) && current_kboard != orig_kboard)
- return make_number (-2); /* wrong_kboard_jmpbuf */
+ return make_fixnum (-2); /* wrong_kboard_jmpbuf */
/* If this has become non-nil here, it has been set by a timer
or sentinel or filter. */
@@ -2789,7 +2769,7 @@ read_char (int commandflag, Lisp_Object map,
if (kb->kbd_queue_has_data)
{
current_kboard = kb;
- return make_number (-2); /* wrong_kboard_jmpbuf */
+ return make_fixnum (-2); /* wrong_kboard_jmpbuf */
}
}
@@ -2807,7 +2787,7 @@ read_char (int commandflag, Lisp_Object map,
goto exit;
}
- if (EQ (c, make_number (-2)))
+ if (EQ (c, make_fixnum (-2)))
return c;
if (CONSP (c) && EQ (XCAR (c), Qt))
@@ -2850,12 +2830,16 @@ read_char (int commandflag, Lisp_Object map,
if (CONSP (c)
&& (EQ (XCAR (c), Qselect_window)
+ || EQ (XCAR (c), Qfocus_out)
#ifdef HAVE_DBUS
|| EQ (XCAR (c), Qdbus_event)
#endif
#ifdef USE_FILE_NOTIFY
|| EQ (XCAR (c), Qfile_notify)
#endif
+#ifdef THREADS_ENABLED
+ || EQ (XCAR (c), Qthread_event)
+#endif
|| EQ (XCAR (c), Qconfig_changed_event))
&& !end_time)
/* We stopped being idle for this event; undo that. This
@@ -2869,7 +2853,7 @@ read_char (int commandflag, Lisp_Object map,
/* The command may have changed the keymaps. Pretend there
is input in another keyboard and return. This will
recalculate keymaps. */
- c = make_number (-2);
+ c = make_fixnum (-2);
goto exit;
}
else
@@ -2877,18 +2861,18 @@ read_char (int commandflag, Lisp_Object map,
}
/* Handle things that only apply to characters. */
- if (INTEGERP (c))
+ if (FIXNUMP (c))
{
/* If kbd_buffer_get_event gave us an EOF, return that. */
- if (XINT (c) == -1)
+ if (XFIXNUM (c) == -1)
goto exit;
if ((STRINGP (KVAR (current_kboard, Vkeyboard_translate_table))
- && UNSIGNED_CMP (XFASTINT (c), <,
+ && UNSIGNED_CMP (XFIXNAT (c), <,
SCHARS (KVAR (current_kboard,
Vkeyboard_translate_table))))
|| (VECTORP (KVAR (current_kboard, Vkeyboard_translate_table))
- && UNSIGNED_CMP (XFASTINT (c), <,
+ && UNSIGNED_CMP (XFIXNAT (c), <,
ASIZE (KVAR (current_kboard,
Vkeyboard_translate_table))))
|| (CHAR_TABLE_P (KVAR (current_kboard, Vkeyboard_translate_table))
@@ -2907,18 +2891,18 @@ read_char (int commandflag, Lisp_Object map,
so we won't do this twice, then queue it up. */
if (EVENT_HAS_PARAMETERS (c)
&& CONSP (XCDR (c))
- && CONSP (EVENT_START (c))
- && CONSP (XCDR (EVENT_START (c))))
+ && CONSP (xevent_start (c))
+ && CONSP (XCDR (xevent_start (c))))
{
Lisp_Object posn;
- posn = POSN_POSN (EVENT_START (c));
+ posn = POSN_POSN (xevent_start (c));
/* Handle menu-bar events:
insert the dummy prefix event `menu-bar'. */
if (EQ (posn, Qmenu_bar) || EQ (posn, Qtool_bar))
{
/* Change menu-bar to (menu-bar) as the event "position". */
- POSN_SET_POSN (EVENT_START (c), list1 (posn));
+ POSN_SET_POSN (xevent_start (c), list1 (posn));
also_record = c;
Vunread_command_events = Fcons (c, Vunread_command_events);
@@ -2936,9 +2920,9 @@ read_char (int commandflag, Lisp_Object map,
/* Wipe the echo area.
But first, if we are about to use an input method,
save the echo area contents for it to refer to. */
- if (INTEGERP (c)
+ if (FIXNUMP (c)
&& ! NILP (Vinput_method_function)
- && ' ' <= XINT (c) && XINT (c) < 256 && XINT (c) != 127)
+ && ' ' <= XFIXNUM (c) && XFIXNUM (c) < 256 && XFIXNUM (c) != 127)
{
previous_echo_area_message = Fcurrent_message ();
Vinput_method_previous_message = previous_echo_area_message;
@@ -2963,12 +2947,12 @@ read_char (int commandflag, Lisp_Object map,
reread_for_input_method:
from_macro:
/* Pass this to the input method, if appropriate. */
- if (INTEGERP (c)
+ if (FIXNUMP (c)
&& ! NILP (Vinput_method_function)
/* Don't run the input method within a key sequence,
after the first event of the key sequence. */
&& NILP (prev_event)
- && ' ' <= XINT (c) && XINT (c) < 256 && XINT (c) != 127)
+ && ' ' <= XFIXNUM (c) && XFIXNUM (c) < 256 && XFIXNUM (c) != 127)
{
Lisp_Object keys;
ptrdiff_t key_count;
@@ -3119,7 +3103,7 @@ read_char (int commandflag, Lisp_Object map,
unbind_to (count, Qnil);
redisplay ();
- if (EQ (c, make_number (040)))
+ if (EQ (c, make_fixnum (040)))
{
cancel_echoing ();
do
@@ -3178,6 +3162,10 @@ help_char_p (Lisp_Object c)
static void
record_char (Lisp_Object c)
{
+ /* quail.el binds this to avoid recording keys twice. */
+ if (inhibit_record_char)
+ return;
+
int recorded = 0;
if (CONSP (c) && (EQ (XCAR (c), Qhelp_echo) || EQ (XCAR (c), Qmouse_movement)))
@@ -3252,7 +3240,10 @@ record_char (Lisp_Object c)
if (!recorded)
{
total_keys += total_keys < NUM_RECENT_KEYS;
- ASET (recent_keys, recent_keys_index, c);
+ ASET (recent_keys, recent_keys_index,
+ /* Copy the event, in case it gets modified by side-effect
+ by some remapping function (bug#30955). */
+ CONSP (c) ? Fcopy_sequence (c) : c);
if (++recent_keys_index >= NUM_RECENT_KEYS)
recent_keys_index = 0;
}
@@ -3281,15 +3272,15 @@ record_char (Lisp_Object c)
/* Write c to the dribble file. If c is a lispy event, write
the event's symbol to the dribble file, in <brackets>. Bleaugh.
If you, dear reader, have a better idea, you've got the source. :-) */
- if (dribble)
+ if (dribble && NILP (Vexecuting_kbd_macro))
{
block_input ();
- if (INTEGERP (c))
+ if (FIXNUMP (c))
{
- if (XUINT (c) < 0x100)
- putc_unlocked (XUINT (c), dribble);
+ if (XUFIXNUM (c) < 0x100)
+ putc_unlocked (XUFIXNUM (c), dribble);
else
- fprintf (dribble, " 0x%"pI"x", XUINT (c));
+ fprintf (dribble, " 0x%"pI"x", XUFIXNUM (c));
}
else
{
@@ -3342,7 +3333,7 @@ readable_events (int flags)
if (flags & READABLE_EVENTS_DO_TIMERS_NOW)
timer_check ();
- /* If the buffer contains only FOCUS_IN_EVENT events, and
+ /* If the buffer contains only FOCUS_IN/OUT_EVENT events, and
READABLE_EVENTS_FILTER_EVENTS is set, report it as empty. */
if (kbd_fetch_ptr != kbd_store_ptr)
{
@@ -3356,13 +3347,12 @@ readable_events (int flags)
do
{
- if (event == kbd_buffer + KBD_BUFFER_SIZE)
- event = kbd_buffer;
if (!(
#ifdef USE_TOOLKIT_SCROLL_BARS
(flags & READABLE_EVENTS_FILTER_EVENTS) &&
#endif
- event->kind == FOCUS_IN_EVENT)
+ (event->kind == FOCUS_IN_EVENT
+ || event->kind == FOCUS_OUT_EVENT))
#ifdef USE_TOOLKIT_SCROLL_BARS
&& !((flags & READABLE_EVENTS_IGNORE_SQUEEZABLES)
&& (event->kind == SCROLL_BAR_CLICK_EVENT
@@ -3373,7 +3363,7 @@ readable_events (int flags)
&& !((flags & READABLE_EVENTS_FILTER_EVENTS)
&& event->kind == BUFFER_SWITCH_EVENT))
return 1;
- event++;
+ event = next_kbd_event (event);
}
while (event != kbd_store_ptr);
}
@@ -3427,12 +3417,8 @@ event_to_kboard (struct input_event *event)
static int
kbd_buffer_nr_stored (void)
{
- return kbd_fetch_ptr == kbd_store_ptr
- ? 0
- : (kbd_fetch_ptr < kbd_store_ptr
- ? kbd_store_ptr - kbd_fetch_ptr
- : ((kbd_buffer + KBD_BUFFER_SIZE) - kbd_fetch_ptr
- + (kbd_store_ptr - kbd_buffer)));
+ int n = kbd_store_ptr - kbd_fetch_ptr;
+ return n + (n < 0 ? KBD_BUFFER_SIZE : 0);
}
#endif /* Store an event obtained at interrupt level into kbd_buffer, fifo */
@@ -3481,14 +3467,12 @@ kbd_buffer_store_buffered_event (union buffered_input_event *event,
{
kset_kbd_queue
(kb, list2 (make_lispy_switch_frame (event->ie.frame_or_window),
- make_number (c)));
+ make_fixnum (c)));
kb->kbd_queue_has_data = true;
- union buffered_input_event *sp;
- for (sp = kbd_fetch_ptr; sp != kbd_store_ptr; sp++)
- {
- if (sp == kbd_buffer + KBD_BUFFER_SIZE)
- sp = kbd_buffer;
+ for (union buffered_input_event *sp = kbd_fetch_ptr;
+ sp != kbd_store_ptr; sp = next_kbd_event (sp))
+ {
if (event_to_kboard (&sp->ie) == kb)
{
sp->ie.kind = NO_EVENT;
@@ -3533,22 +3517,18 @@ kbd_buffer_store_buffered_event (union buffered_input_event *event,
Just ignore the second one. */
else if (event->kind == BUFFER_SWITCH_EVENT
&& kbd_fetch_ptr != kbd_store_ptr
- && ((kbd_store_ptr == kbd_buffer
- ? kbd_buffer + KBD_BUFFER_SIZE - 1
- : kbd_store_ptr - 1)->kind) == BUFFER_SWITCH_EVENT)
+ && prev_kbd_event (kbd_store_ptr)->kind == BUFFER_SWITCH_EVENT)
return;
- if (kbd_store_ptr - kbd_buffer == KBD_BUFFER_SIZE)
- kbd_store_ptr = kbd_buffer;
-
/* Don't let the very last slot in the buffer become full,
since that would make the two pointers equal,
and that is indistinguishable from an empty buffer.
Discard the event if it would fill the last slot. */
- if (kbd_fetch_ptr - 1 != kbd_store_ptr)
+ union buffered_input_event *next_slot = next_kbd_event (kbd_store_ptr);
+ if (kbd_fetch_ptr != next_slot)
{
*kbd_store_ptr = *event;
- ++kbd_store_ptr;
+ kbd_store_ptr = next_slot;
#ifdef subprocesses
if (kbd_buffer_nr_stored () > KBD_BUFFER_SIZE / 2
&& ! kbd_on_hold_p ())
@@ -3591,11 +3571,8 @@ kbd_buffer_store_buffered_event (union buffered_input_event *event,
void
kbd_buffer_unget_event (struct selection_input_event *event)
{
- if (kbd_fetch_ptr == kbd_buffer)
- kbd_fetch_ptr = kbd_buffer + KBD_BUFFER_SIZE;
-
/* Don't let the very last slot in the buffer become full, */
- union buffered_input_event *kp = kbd_fetch_ptr - 1;
+ union buffered_input_event *kp = prev_kbd_event (kbd_fetch_ptr);
if (kp != kbd_store_ptr)
{
kp->sie = *event;
@@ -3683,12 +3660,9 @@ kbd_buffer_store_help_event (Lisp_Object frame, Lisp_Object help)
void
discard_mouse_events (void)
{
- union buffered_input_event *sp;
- for (sp = kbd_fetch_ptr; sp != kbd_store_ptr; sp++)
+ for (union buffered_input_event *sp = kbd_fetch_ptr;
+ sp != kbd_store_ptr; sp = next_kbd_event (sp))
{
- if (sp == kbd_buffer + KBD_BUFFER_SIZE)
- sp = kbd_buffer;
-
if (sp->kind == MOUSE_CLICK_EVENT
|| sp->kind == WHEEL_EVENT
|| sp->kind == HORIZ_WHEEL_EVENT
@@ -3713,25 +3687,20 @@ discard_mouse_events (void)
bool
kbd_buffer_events_waiting (void)
{
- union buffered_input_event *sp;
-
- for (sp = kbd_fetch_ptr;
- sp != kbd_store_ptr && sp->kind == NO_EVENT;
- ++sp)
- {
- if (sp == kbd_buffer + KBD_BUFFER_SIZE)
- sp = kbd_buffer;
- }
-
- kbd_fetch_ptr = sp;
- return sp != kbd_store_ptr && sp->kind != NO_EVENT;
+ for (union buffered_input_event *sp = kbd_fetch_ptr;
+ ; sp = next_kbd_event (sp))
+ if (sp == kbd_store_ptr || sp->kind != NO_EVENT)
+ {
+ kbd_fetch_ptr = sp;
+ return sp != kbd_store_ptr && sp->kind != NO_EVENT;
+ }
}
/* Clear input event EVENT. */
static void
-clear_event (union buffered_input_event *event)
+clear_event (struct input_event *event)
{
event->kind = NO_EVENT;
}
@@ -3761,7 +3730,7 @@ kbd_buffer_get_event (KBOARD **kbp,
}
#endif /* subprocesses */
-#if !defined HAVE_DBUS && !defined USE_FILE_NOTIFY
+#if !defined HAVE_DBUS && !defined USE_FILE_NOTIFY && !defined THREADS_ENABLED
if (noninteractive
/* In case we are running as a daemon, only do this before
detaching from the terminal. */
@@ -3772,7 +3741,7 @@ kbd_buffer_get_event (KBOARD **kbp,
*kbp = current_kboard;
return obj;
}
-#endif /* !defined HAVE_DBUS && !defined USE_FILE_NOTIFY */
+#endif /* !defined HAVE_DBUS && !defined USE_FILE_NOTIFY && !defined THREADS_ENABLED */
/* Wait until there is input available. */
for (;;)
@@ -3853,11 +3822,7 @@ kbd_buffer_get_event (KBOARD **kbp,
mouse movement enabled and available. */
if (kbd_fetch_ptr != kbd_store_ptr)
{
- union buffered_input_event *event;
-
- event = ((kbd_fetch_ptr < kbd_buffer + KBD_BUFFER_SIZE)
- ? kbd_fetch_ptr
- : kbd_buffer);
+ union buffered_input_event *event = kbd_fetch_ptr;
*kbp = event_to_kboard (&event->ie);
if (*kbp == 0)
@@ -3868,15 +3833,17 @@ kbd_buffer_get_event (KBOARD **kbp,
/* These two kinds of events get special handling
and don't actually appear to the command loop.
We return nil for them. */
- if (event->kind == SELECTION_REQUEST_EVENT
- || event->kind == SELECTION_CLEAR_EVENT)
+ switch (event->kind)
+ {
+ case SELECTION_REQUEST_EVENT:
+ case SELECTION_CLEAR_EVENT:
{
#ifdef HAVE_X11
/* Remove it from the buffer before processing it,
since otherwise swallow_events will see it
and process it again. */
struct selection_input_event copy = event->sie;
- kbd_fetch_ptr = event + 1;
+ kbd_fetch_ptr = next_kbd_event (event);
input_pending = readable_events (0);
x_handle_selection_event (&copy);
#else
@@ -3885,202 +3852,61 @@ kbd_buffer_get_event (KBOARD **kbp,
emacs_abort ();
#endif
}
+ break;
-#if defined (HAVE_NS)
- else if (event->kind == NS_TEXT_EVENT)
- {
- if (event->ie.code == KEY_NS_PUT_WORKING_TEXT)
- obj = list1 (intern ("ns-put-working-text"));
- else
- obj = list1 (intern ("ns-unput-working-text"));
- kbd_fetch_ptr = event + 1;
- if (used_mouse_menu)
- *used_mouse_menu = true;
- }
-#endif
-
-#if defined (HAVE_X11) || defined (HAVE_NTGUI) \
- || defined (HAVE_NS)
- else if (event->kind == DELETE_WINDOW_EVENT)
- {
- /* Make an event (delete-frame (FRAME)). */
- obj = list2 (Qdelete_frame, list1 (event->ie.frame_or_window));
- kbd_fetch_ptr = event + 1;
- }
-#endif
-
-#ifdef HAVE_NTGUI
- else if (event->kind == END_SESSION_EVENT)
- {
- /* Make an event (end-session). */
- obj = list1 (Qend_session);
- kbd_fetch_ptr = event + 1;
- }
-#endif
-
-#if defined (HAVE_X11) || defined (HAVE_NTGUI) \
- || defined (HAVE_NS)
- else if (event->kind == ICONIFY_EVENT)
- {
- /* Make an event (iconify-frame (FRAME)). */
- obj = list2 (Qiconify_frame, list1 (event->ie.frame_or_window));
- kbd_fetch_ptr = event + 1;
- }
- else if (event->kind == DEICONIFY_EVENT)
- {
- /* Make an event (make-frame-visible (FRAME)). */
- obj = list2 (Qmake_frame_visible, list1 (event->ie.frame_or_window));
- kbd_fetch_ptr = event + 1;
- }
-#endif
- else if (event->kind == BUFFER_SWITCH_EVENT)
- {
- /* The value doesn't matter here; only the type is tested. */
- XSETBUFFER (obj, current_buffer);
- kbd_fetch_ptr = event + 1;
- }
#if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) \
|| defined (HAVE_NS) || defined (USE_GTK)
- else if (event->kind == MENU_BAR_ACTIVATE_EVENT)
+ case MENU_BAR_ACTIVATE_EVENT:
{
- kbd_fetch_ptr = event + 1;
+ kbd_fetch_ptr = next_kbd_event (event);
input_pending = readable_events (0);
if (FRAME_LIVE_P (XFRAME (event->ie.frame_or_window)))
x_activate_menubar (XFRAME (event->ie.frame_or_window));
}
+ break;
+#endif
+#if defined (HAVE_NS)
+ case NS_TEXT_EVENT:
+ if (used_mouse_menu)
+ *used_mouse_menu = true;
+ FALLTHROUGH;
#endif
#ifdef HAVE_NTGUI
- else if (event->kind == LANGUAGE_CHANGE_EVENT)
- {
- /* Make an event (language-change FRAME CODEPAGE LANGUAGE-ID). */
- obj = list4 (Qlanguage_change,
- event->ie.frame_or_window,
- make_number (event->ie.code),
- make_number (event->ie.modifiers));
- kbd_fetch_ptr = event + 1;
- }
+ case END_SESSION_EVENT:
+ case LANGUAGE_CHANGE_EVENT:
#endif
-#ifdef USE_FILE_NOTIFY
- else if (event->kind == FILE_NOTIFY_EVENT)
- {
-#ifdef HAVE_W32NOTIFY
- /* Make an event (file-notify (DESCRIPTOR ACTION FILE) CALLBACK). */
- obj = list3 (Qfile_notify, event->ie.arg, event->ie.frame_or_window);
-#else
- obj = make_lispy_event (&event->ie);
+#if defined (HAVE_X11) || defined (HAVE_NTGUI) || defined (HAVE_NS)
+ case DELETE_WINDOW_EVENT:
+ case ICONIFY_EVENT:
+ case DEICONIFY_EVENT:
+ case MOVE_FRAME_EVENT:
#endif
- kbd_fetch_ptr = event + 1;
- }
-#endif /* USE_FILE_NOTIFY */
- else if (event->kind == SAVE_SESSION_EVENT)
- {
- obj = list2 (Qsave_session, event->ie.arg);
- kbd_fetch_ptr = event + 1;
- }
- /* Just discard these, by returning nil.
- With MULTI_KBOARD, these events are used as placeholders
- when we need to randomly delete events from the queue.
- (They shouldn't otherwise be found in the buffer,
- but on some machines it appears they do show up
- even without MULTI_KBOARD.) */
- /* On Windows NT/9X, NO_EVENT is used to delete extraneous
- mouse events during a popup-menu call. */
- else if (event->kind == NO_EVENT)
- kbd_fetch_ptr = event + 1;
- else if (event->kind == HELP_EVENT)
- {
- Lisp_Object object, position, help, frame, window;
-
- frame = event->ie.frame_or_window;
- object = event->ie.arg;
- position = make_number (Time_to_position (event->ie.timestamp));
- window = event->ie.x;
- help = event->ie.y;
- clear_event (event);
-
- kbd_fetch_ptr = event + 1;
- if (!WINDOWP (window))
- window = Qnil;
- obj = Fcons (Qhelp_echo,
- list5 (frame, help, window, object, position));
- }
- else if (event->kind == FOCUS_IN_EVENT)
- {
- /* Notification of a FocusIn event. The frame receiving the
- focus is in event->frame_or_window. Generate a
- switch-frame event if necessary. */
- Lisp_Object frame, focus;
-
- frame = event->ie.frame_or_window;
- focus = FRAME_FOCUS_FRAME (XFRAME (frame));
- if (FRAMEP (focus))
- frame = focus;
-
- if (
-#ifdef HAVE_X11
- ! NILP (event->ie.arg)
- &&
+#ifdef USE_FILE_NOTIFY
+ case FILE_NOTIFY_EVENT:
#endif
- !EQ (frame, internal_last_event_frame)
- && !EQ (frame, selected_frame))
- obj = make_lispy_switch_frame (frame);
- else
- obj = make_lispy_focus_in (frame);
-
- internal_last_event_frame = frame;
- kbd_fetch_ptr = event + 1;
- }
- else if (event->kind == FOCUS_OUT_EVENT)
- {
-#ifdef HAVE_WINDOW_SYSTEM
-
- Display_Info *di;
- Lisp_Object frame = event->ie.frame_or_window;
- bool focused = false;
-
- for (di = x_display_list; di && ! focused; di = di->next)
- focused = di->x_highlight_frame != 0;
-
- if (!focused)
- obj = make_lispy_focus_out (frame);
-
-#endif /* HAVE_WINDOW_SYSTEM */
-
- kbd_fetch_ptr = event + 1;
- }
#ifdef HAVE_DBUS
- else if (event->kind == DBUS_EVENT)
- {
- obj = make_lispy_event (&event->ie);
- kbd_fetch_ptr = event + 1;
- }
+ case DBUS_EVENT:
#endif
-#if defined (HAVE_X11) || defined (HAVE_NTGUI) || defined (HAVE_NS)
- else if (event->kind == MOVE_FRAME_EVENT)
- {
- /* Make an event (move-frame (FRAME)). */
- obj = list2 (Qmove_frame, list1 (event->ie.frame_or_window));
- kbd_fetch_ptr = event + 1;
- }
+#ifdef THREADS_ENABLED
+ case THREAD_EVENT:
#endif
#ifdef HAVE_XWIDGETS
- else if (event->kind == XWIDGET_EVENT)
- {
- obj = make_lispy_event (&event->ie);
- kbd_fetch_ptr = event + 1;
- }
+ case XWIDGET_EVENT:
#endif
- else if (event->kind == CONFIG_CHANGED_EVENT)
- {
- obj = make_lispy_event (&event->ie);
- kbd_fetch_ptr = event + 1;
- }
- else if (event->kind == SELECT_WINDOW_EVENT)
- {
- obj = list2 (Qselect_window, list1 (event->ie.frame_or_window));
- kbd_fetch_ptr = event + 1;
- }
- else
+ case BUFFER_SWITCH_EVENT:
+ case SAVE_SESSION_EVENT:
+ case NO_EVENT:
+ case HELP_EVENT:
+ case FOCUS_IN_EVENT:
+ case CONFIG_CHANGED_EVENT:
+ case FOCUS_OUT_EVENT:
+ case SELECT_WINDOW_EVENT:
+ {
+ obj = make_lispy_event (&event->ie);
+ kbd_fetch_ptr = next_kbd_event (event);
+ }
+ break;
+ default:
{
/* If this event is on a different frame, return a switch-frame this
time, and leave the event in the queue for next time. */
@@ -4130,10 +3956,11 @@ kbd_buffer_get_event (KBOARD **kbp,
#endif
/* Wipe out this event, to catch bugs. */
- clear_event (event);
- kbd_fetch_ptr = event + 1;
+ clear_event (&event->ie);
+ kbd_fetch_ptr = next_kbd_event (event);
}
}
+ }
}
/* Try generating a mouse motion event. */
else if (!NILP (do_mouse_tracking) && some_mouse_moved ())
@@ -4197,17 +4024,9 @@ kbd_buffer_get_event (KBOARD **kbp,
static void
process_special_events (void)
{
- union buffered_input_event *event;
-
- for (event = kbd_fetch_ptr; event != kbd_store_ptr; ++event)
+ for (union buffered_input_event *event = kbd_fetch_ptr;
+ event != kbd_store_ptr; event = next_kbd_event (event))
{
- if (event == kbd_buffer + KBD_BUFFER_SIZE)
- {
- event = kbd_buffer;
- if (event == kbd_store_ptr)
- break;
- }
-
/* If we find a stored X selection request, handle it now. */
if (event->kind == SELECTION_REQUEST_EVENT
|| event->kind == SELECTION_CLEAR_EVENT)
@@ -4221,28 +4040,21 @@ process_special_events (void)
cyclically. */
struct selection_input_event copy = event->sie;
- union buffered_input_event *beg
- = (kbd_fetch_ptr == kbd_buffer + KBD_BUFFER_SIZE)
- ? kbd_buffer : kbd_fetch_ptr;
+ int moved_events;
- if (event > beg)
- memmove (beg + 1, beg, (event - beg) * sizeof *beg);
- else if (event < beg)
+ if (event < kbd_fetch_ptr)
{
- if (event > kbd_buffer)
- memmove (kbd_buffer + 1, kbd_buffer,
- (event - kbd_buffer) * sizeof *kbd_buffer);
- *kbd_buffer = *(kbd_buffer + KBD_BUFFER_SIZE - 1);
- if (beg < kbd_buffer + KBD_BUFFER_SIZE - 1)
- memmove (beg + 1, beg,
- (kbd_buffer + KBD_BUFFER_SIZE - 1 - beg) * sizeof *beg);
+ memmove (kbd_buffer + 1, kbd_buffer,
+ (event - kbd_buffer) * sizeof *kbd_buffer);
+ kbd_buffer[0] = kbd_buffer[KBD_BUFFER_SIZE - 1];
+ moved_events = kbd_buffer + KBD_BUFFER_SIZE - 1 - kbd_fetch_ptr;
}
-
- if (kbd_fetch_ptr == kbd_buffer + KBD_BUFFER_SIZE)
- kbd_fetch_ptr = kbd_buffer + 1;
else
- kbd_fetch_ptr++;
+ moved_events = event - kbd_fetch_ptr;
+ memmove (kbd_fetch_ptr + 1, kbd_fetch_ptr,
+ moved_events * sizeof *kbd_fetch_ptr);
+ kbd_fetch_ptr = next_kbd_event (kbd_fetch_ptr);
input_pending = readable_events (0);
x_handle_selection_event (&copy);
#else
@@ -4319,18 +4131,13 @@ decode_timer (Lisp_Object timer, struct timespec *result)
Lisp_Object *vec;
if (! (VECTORP (timer) && ASIZE (timer) == 9))
- return 0;
+ return false;
vec = XVECTOR (timer)->contents;
if (! NILP (vec[0]))
- return 0;
- if (! INTEGERP (vec[2]))
return false;
-
- struct lisp_time t;
- if (decode_time_components (vec[1], vec[2], vec[3], vec[8], &t, 0) <= 0)
+ if (! FIXNUMP (vec[2]))
return false;
- *result = lisp_to_timespec (t);
- return timespec_valid_p (*result);
+ return list4_to_timespec (vec[1], vec[2], vec[3], vec[8], result);
}
@@ -4534,8 +4341,8 @@ timer_check (void)
DEFUN ("current-idle-time", Fcurrent_idle_time, Scurrent_idle_time, 0, 0, 0,
doc: /* Return the current length of Emacs idleness, or nil.
-The value when Emacs is idle is a list of four integers (HIGH LOW USEC PSEC)
-in the same style as (current-time).
+The value when Emacs is idle is a Lisp timestamp in the style of
+`current-time'.
The value when Emacs is not idle is nil.
@@ -5176,7 +4983,7 @@ make_lispy_position (struct frame *f, Lisp_Object x, Lisp_Object y,
int xret = 0, yret = 0;
/* The window or frame under frame pixel coordinates (x,y) */
Lisp_Object window_or_frame = f
- ? window_from_coordinates (f, XINT (x), XINT (y), &part, 0)
+ ? window_from_coordinates (f, XFIXNUM (x), XFIXNUM (y), &part, 0)
: Qnil;
if (WINDOWP (window_or_frame))
@@ -5191,15 +4998,15 @@ make_lispy_position (struct frame *f, Lisp_Object x, Lisp_Object y,
Lisp_Object object = Qnil;
/* Pixel coordinates relative to the window corner. */
- int wx = XINT (x) - WINDOW_LEFT_EDGE_X (w);
- int wy = XINT (y) - WINDOW_TOP_EDGE_Y (w);
+ int wx = XFIXNUM (x) - WINDOW_LEFT_EDGE_X (w);
+ int wy = XFIXNUM (y) - WINDOW_TOP_EDGE_Y (w);
/* For text area clicks, return X, Y relative to the corner of
this text area. Note that dX, dY etc are set below, by
buffer_posn_from_coords. */
if (part == ON_TEXT)
{
- xret = XINT (x) - window_box_left (w, TEXT_AREA);
+ xret = XFIXNUM (x) - window_box_left (w, TEXT_AREA);
yret = wy - WINDOW_HEADER_LINE_HEIGHT (w);
}
/* For mode line and header line clicks, return X, Y relative to
@@ -5218,7 +5025,7 @@ make_lispy_position (struct frame *f, Lisp_Object x, Lisp_Object y,
string = mode_line_string (w, part, &col, &row, &charpos,
&object, &dx, &dy, &width, &height);
if (STRINGP (string))
- string_info = Fcons (string, make_number (charpos));
+ string_info = Fcons (string, make_fixnum (charpos));
textpos = -1;
xret = wx;
@@ -5237,7 +5044,7 @@ make_lispy_position (struct frame *f, Lisp_Object x, Lisp_Object y,
string = marginal_area_string (w, part, &col, &row, &charpos,
&object, &dx, &dy, &width, &height);
if (STRINGP (string))
- string_info = Fcons (string, make_number (charpos));
+ string_info = Fcons (string, make_fixnum (charpos));
xret = wx;
yret = wy - WINDOW_HEADER_LINE_HEIGHT (w);
}
@@ -5319,7 +5126,7 @@ make_lispy_position (struct frame *f, Lisp_Object x, Lisp_Object y,
: (part == ON_RIGHT_FRINGE || part == ON_RIGHT_MARGIN
|| (part == ON_VERTICAL_SCROLL_BAR
&& WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_RIGHT (w)))
- ? (XINT (x) - window_box_left (w, TEXT_AREA))
+ ? (XFIXNUM (x) - window_box_left (w, TEXT_AREA))
: 0;
int y2 = wy;
@@ -5336,10 +5143,10 @@ make_lispy_position (struct frame *f, Lisp_Object x, Lisp_Object y,
if (NILP (posn))
{
- posn = make_number (textpos);
+ posn = make_fixnum (textpos);
if (STRINGP (string2))
string_info = Fcons (string2,
- make_number (CHARPOS (p.string_pos)));
+ make_fixnum (CHARPOS (p.string_pos)));
}
if (NILP (object))
object = object2;
@@ -5361,14 +5168,14 @@ make_lispy_position (struct frame *f, Lisp_Object x, Lisp_Object y,
/* Object info. */
extra_info
= list3 (object,
- Fcons (make_number (dx), make_number (dy)),
- Fcons (make_number (width), make_number (height)));
+ Fcons (make_fixnum (dx), make_fixnum (dy)),
+ Fcons (make_fixnum (width), make_fixnum (height)));
/* String info. */
extra_info = Fcons (string_info,
- Fcons (textpos < 0 ? Qnil : make_number (textpos),
- Fcons (Fcons (make_number (col),
- make_number (row)),
+ Fcons (textpos < 0 ? Qnil : make_fixnum (textpos),
+ Fcons (Fcons (make_fixnum (col),
+ make_fixnum (row)),
extra_info)));
}
@@ -5377,8 +5184,8 @@ make_lispy_position (struct frame *f, Lisp_Object x, Lisp_Object y,
{
/* Return mouse pixel coordinates here. */
XSETFRAME (window_or_frame, f);
- xret = XINT (x);
- yret = XINT (y);
+ xret = XFIXNUM (x);
+ yret = XFIXNUM (y);
if (FRAME_LIVE_P (f)
&& FRAME_INTERNAL_BORDER_WIDTH (f) > 0
@@ -5397,9 +5204,9 @@ make_lispy_position (struct frame *f, Lisp_Object x, Lisp_Object y,
return Fcons (window_or_frame,
Fcons (posn,
- Fcons (Fcons (make_number (xret),
- make_number (yret)),
- Fcons (make_number (t),
+ Fcons (Fcons (make_fixnum (xret),
+ make_fixnum (yret)),
+ Fcons (make_fixnum (t),
extra_info))));
}
@@ -5424,7 +5231,7 @@ static Lisp_Object
make_scroll_bar_position (struct input_event *ev, Lisp_Object type)
{
return list5 (ev->frame_or_window, type, Fcons (ev->x, ev->y),
- make_number (ev->timestamp),
+ make_fixnum (ev->timestamp),
builtin_lisp_symbol (scroll_bar_parts[ev->part]));
}
@@ -5443,7 +5250,66 @@ make_lispy_event (struct input_event *event)
switch (event->kind)
{
- /* A simple keystroke. */
+#if defined (HAVE_X11) || defined (HAVE_NTGUI) || defined (HAVE_NS)
+ case DELETE_WINDOW_EVENT:
+ /* Make an event (delete-frame (FRAME)). */
+ return list2 (Qdelete_frame, list1 (event->frame_or_window));
+
+ case ICONIFY_EVENT:
+ /* Make an event (iconify-frame (FRAME)). */
+ return list2 (Qiconify_frame, list1 (event->frame_or_window));
+
+ case DEICONIFY_EVENT:
+ /* Make an event (make-frame-visible (FRAME)). */
+ return list2 (Qmake_frame_visible, list1 (event->frame_or_window));
+
+ case MOVE_FRAME_EVENT:
+ /* Make an event (move-frame (FRAME)). */
+ return list2 (Qmove_frame, list1 (event->frame_or_window));
+#endif
+
+ case BUFFER_SWITCH_EVENT:
+ {
+ /* The value doesn't matter here; only the type is tested. */
+ Lisp_Object obj;
+ XSETBUFFER (obj, current_buffer);
+ return obj;
+ }
+
+ /* Just discard these, by returning nil.
+ With MULTI_KBOARD, these events are used as placeholders
+ when we need to randomly delete events from the queue.
+ (They shouldn't otherwise be found in the buffer,
+ but on some machines it appears they do show up
+ even without MULTI_KBOARD.) */
+ /* On Windows NT/9X, NO_EVENT is used to delete extraneous
+ mouse events during a popup-menu call. */
+ case NO_EVENT:
+ return Qnil;
+
+ case HELP_EVENT:
+ {
+ Lisp_Object frame = event->frame_or_window;
+ Lisp_Object object = event->arg;
+ Lisp_Object position
+ = make_fixnum (Time_to_position (event->timestamp));
+ Lisp_Object window = event->x;
+ Lisp_Object help = event->y;
+ clear_event (event);
+
+ if (!WINDOWP (window))
+ window = Qnil;
+ return Fcons (Qhelp_echo,
+ list5 (frame, help, window, object, position));
+ }
+
+ case FOCUS_IN_EVENT:
+ return make_lispy_focus_in (event->frame_or_window);
+
+ case FOCUS_OUT_EVENT:
+ return make_lispy_focus_out (event->frame_or_window);
+
+ /* A simple keystroke. */
case ASCII_KEYSTROKE_EVENT:
case MULTIBYTE_CHAR_KEYSTROKE_EVENT:
{
@@ -5507,6 +5373,11 @@ make_lispy_event (struct input_event *event)
}
#ifdef HAVE_NS
+ case NS_TEXT_EVENT:
+ return list1 (intern (event->code == KEY_NS_PUT_WORKING_TEXT
+ ? "ns-put-working-text"
+ : "ns-unput-working-text"));
+
/* NS_NONKEY_EVENTs are just like NON_ASCII_KEYSTROKE_EVENTs,
except that they are non-key events (last-nonmenu-event is nil). */
case NS_NONKEY_EVENT:
@@ -5569,6 +5440,17 @@ make_lispy_event (struct input_event *event)
PTRDIFF_MAX);
#ifdef HAVE_NTGUI
+ case END_SESSION_EVENT:
+ /* Make an event (end-session). */
+ return list1 (Qend_session);
+
+ case LANGUAGE_CHANGE_EVENT:
+ /* Make an event (language-change FRAME CODEPAGE LANGUAGE-ID). */
+ return list4 (Qlanguage_change,
+ event->frame_or_window,
+ make_fixnum (event->code),
+ make_fixnum (event->modifiers));
+
case MULTIMEDIA_KEY_EVENT:
if (event->code < ARRAYELTS (lispy_multimedia_keys)
&& event->code > 0 && lispy_multimedia_keys[event->code])
@@ -5622,7 +5504,7 @@ make_lispy_event (struct input_event *event)
in a menu (non-toolkit version). */
if (!toolkit_menubar_in_use (f))
{
- pixel_to_glyph_coords (f, XINT (event->x), XINT (event->y),
+ pixel_to_glyph_coords (f, XFIXNUM (event->x), XFIXNUM (event->y),
&column, &row, NULL, 1);
/* In the non-toolkit version, clicks on the menu bar
@@ -5647,8 +5529,8 @@ make_lispy_event (struct input_event *event)
pos = AREF (items, i + 3);
if (NILP (string))
break;
- if (column >= XINT (pos)
- && column < XINT (pos) + SCHARS (string))
+ if (column >= XFIXNUM (pos)
+ && column < XFIXNUM (pos) + SCHARS (string))
{
item = AREF (items, i);
break;
@@ -5661,7 +5543,7 @@ make_lispy_event (struct input_event *event)
position = list4 (event->frame_or_window,
Qmenu_bar,
Fcons (event->x, event->y),
- make_number (event->timestamp));
+ make_fixnum (event->timestamp));
return list2 (item, position);
}
@@ -5708,18 +5590,18 @@ make_lispy_event (struct input_event *event)
fuzz = double_click_fuzz / 8;
is_double = (button == last_mouse_button
- && (eabs (XINT (event->x) - last_mouse_x) <= fuzz)
- && (eabs (XINT (event->y) - last_mouse_y) <= fuzz)
+ && (eabs (XFIXNUM (event->x) - last_mouse_x) <= fuzz)
+ && (eabs (XFIXNUM (event->y) - last_mouse_y) <= fuzz)
&& button_down_time != 0
&& (EQ (Vdouble_click_time, Qt)
- || (NATNUMP (Vdouble_click_time)
+ || (FIXNATP (Vdouble_click_time)
&& (event->timestamp - button_down_time
- < XFASTINT (Vdouble_click_time)))));
+ < XFIXNAT (Vdouble_click_time)))));
}
last_mouse_button = button;
- last_mouse_x = XINT (event->x);
- last_mouse_y = XINT (event->y);
+ last_mouse_x = XFIXNUM (event->x);
+ last_mouse_y = XFIXNUM (event->y);
/* If this is a button press, squirrel away the location, so
we can decide later whether it was a click or a drag. */
@@ -5764,10 +5646,10 @@ make_lispy_event (struct input_event *event)
new_down = Fcar (Fcdr (Fcdr (position)));
if (CONSP (down)
- && INTEGERP (XCAR (down)) && INTEGERP (XCDR (down)))
+ && FIXNUMP (XCAR (down)) && FIXNUMP (XCDR (down)))
{
- xdiff = XINT (XCAR (new_down)) - XINT (XCAR (down));
- ydiff = XINT (XCDR (new_down)) - XINT (XCDR (down));
+ xdiff = XFIXNUM (XCAR (new_down)) - XFIXNUM (XCAR (down));
+ ydiff = XFIXNUM (XCDR (new_down)) - XFIXNUM (XCDR (down));
}
if (ignore_mouse_drag_p)
@@ -5822,7 +5704,7 @@ make_lispy_event (struct input_event *event)
if (event->modifiers & drag_modifier)
return list3 (head, start_pos, position);
else if (event->modifiers & (double_modifier | triple_modifier))
- return list3 (head, position, make_number (double_click_count));
+ return list3 (head, position, make_fixnum (double_click_count));
else
return list2 (head, position);
}
@@ -5886,13 +5768,13 @@ make_lispy_event (struct input_event *event)
symbol_num += 2;
is_double = (last_mouse_button == - (1 + symbol_num)
- && (eabs (XINT (event->x) - last_mouse_x) <= fuzz)
- && (eabs (XINT (event->y) - last_mouse_y) <= fuzz)
+ && (eabs (XFIXNUM (event->x) - last_mouse_x) <= fuzz)
+ && (eabs (XFIXNUM (event->y) - last_mouse_y) <= fuzz)
&& button_down_time != 0
&& (EQ (Vdouble_click_time, Qt)
- || (NATNUMP (Vdouble_click_time)
+ || (FIXNATP (Vdouble_click_time)
&& (event->timestamp - button_down_time
- < XFASTINT (Vdouble_click_time)))));
+ < XFIXNAT (Vdouble_click_time)))));
if (is_double)
{
double_click_count++;
@@ -5909,8 +5791,8 @@ make_lispy_event (struct input_event *event)
button_down_time = event->timestamp;
/* Use a negative value to distinguish wheel from mouse button. */
last_mouse_button = - (1 + symbol_num);
- last_mouse_x = XINT (event->x);
- last_mouse_y = XINT (event->y);
+ last_mouse_x = XFIXNUM (event->x);
+ last_mouse_y = XFIXNUM (event->y);
/* Get the symbol we should use for the wheel event. */
head = modify_event_symbol (symbol_num,
@@ -5923,10 +5805,10 @@ make_lispy_event (struct input_event *event)
}
if (NUMBERP (event->arg))
- return list4 (head, position, make_number (double_click_count),
+ return list4 (head, position, make_fixnum (double_click_count),
event->arg);
else if (event->modifiers & (double_modifier | triple_modifier))
- return list3 (head, position, make_number (double_click_count));
+ return list3 (head, position, make_fixnum (double_click_count));
else
return list2 (head, position);
}
@@ -6062,7 +5944,7 @@ make_lispy_event (struct input_event *event)
}
case SAVE_SESSION_EVENT:
- return Qsave_session;
+ return list2 (Qsave_session, event->arg);
#ifdef HAVE_DBUS
case DBUS_EVENT:
@@ -6071,6 +5953,13 @@ make_lispy_event (struct input_event *event)
}
#endif /* HAVE_DBUS */
+#ifdef THREADS_ENABLED
+ case THREAD_EVENT:
+ {
+ return Fcons (Qthread_event, event->arg);
+ }
+#endif /* THREADS_ENABLED */
+
#ifdef HAVE_XWIDGETS
case XWIDGET_EVENT:
{
@@ -6078,12 +5967,15 @@ make_lispy_event (struct input_event *event)
}
#endif
-#if defined HAVE_INOTIFY || defined HAVE_KQUEUE || defined HAVE_GFILENOTIFY
+#ifdef USE_FILE_NOTIFY
case FILE_NOTIFY_EVENT:
- {
- return Fcons (Qfile_notify, event->arg);
- }
-#endif /* HAVE_INOTIFY || HAVE_KQUEUE || HAVE_GFILENOTIFY */
+#ifdef HAVE_W32NOTIFY
+ /* Make an event (file-notify (DESCRIPTOR ACTION FILE) CALLBACK). */
+ return list3 (Qfile_notify, event->arg, event->frame_or_window);
+#else
+ return Fcons (Qfile_notify, event->arg);
+#endif
+#endif /* USE_FILE_NOTIFY */
case CONFIG_CHANGED_EVENT:
return list3 (Qconfig_changed_event,
@@ -6109,7 +6001,7 @@ make_lispy_movement (struct frame *frame, Lisp_Object bar_window, enum scroll_ba
list5 (bar_window,
Qvertical_scroll_bar,
Fcons (x, y),
- make_number (t),
+ make_fixnum (t),
part_sym));
}
/* Or is it an ordinary mouse movement? */
@@ -6134,16 +6026,12 @@ make_lispy_focus_in (Lisp_Object frame)
return list2 (Qfocus_in, frame);
}
-#ifdef HAVE_WINDOW_SYSTEM
-
static Lisp_Object
make_lispy_focus_out (Lisp_Object frame)
{
return list2 (Qfocus_out, frame);
}
-#endif /* HAVE_WINDOW_SYSTEM */
-
/* Manipulating modifiers. */
/* Parse the name of SYMBOL, and return the set of modifiers it contains.
@@ -6353,15 +6241,15 @@ lispy_modifier_list (int modifiers)
SYMBOL's Qevent_symbol_element_mask property, and maintains the
Qevent_symbol_elements property. */
-#define KEY_TO_CHAR(k) (XINT (k) & ((1 << CHARACTERBITS) - 1))
+#define KEY_TO_CHAR(k) (XFIXNUM (k) & ((1 << CHARACTERBITS) - 1))
Lisp_Object
parse_modifiers (Lisp_Object symbol)
{
Lisp_Object elements;
- if (INTEGERP (symbol))
- return list2i (KEY_TO_CHAR (symbol), XINT (symbol) & CHAR_MODIFIER_MASK);
+ if (FIXNUMP (symbol))
+ return list2i (KEY_TO_CHAR (symbol), XFIXNUM (symbol) & CHAR_MODIFIER_MASK);
else if (!SYMBOLP (symbol))
return Qnil;
@@ -6428,8 +6316,8 @@ apply_modifiers (int modifiers, Lisp_Object base)
/* Mask out upper bits. We don't know where this value's been. */
modifiers &= INTMASK;
- if (INTEGERP (base))
- return make_number (XINT (base) | modifiers);
+ if (FIXNUMP (base))
+ return make_fixnum (XFIXNUM (base) | modifiers);
/* The click modifier never figures into cache indices. */
cache = Fget (base, Qmodifier_cache);
@@ -6497,7 +6385,7 @@ reorder_modifiers (Lisp_Object symbol)
Lisp_Object parsed;
parsed = parse_modifiers (symbol);
- return apply_modifiers (XFASTINT (XCAR (XCDR (parsed))),
+ return apply_modifiers (XFIXNAT (XCAR (XCDR (parsed))),
XCAR (parsed));
}
@@ -6560,12 +6448,7 @@ modify_event_symbol (ptrdiff_t symbol_num, int modifiers, Lisp_Object symbol_kin
{
if (! VECTORP (*symbol_table)
|| ASIZE (*symbol_table) != table_size)
- {
- Lisp_Object size;
-
- XSETFASTINT (size, table_size);
- *symbol_table = Fmake_vector (size, Qnil);
- }
+ *symbol_table = make_nil_vector (table_size);
value = AREF (*symbol_table, symbol_num);
}
@@ -6584,7 +6467,7 @@ modify_event_symbol (ptrdiff_t symbol_num, int modifiers, Lisp_Object symbol_kin
USE_SAFE_ALLOCA;
buf = SAFE_ALLOCA (len);
esprintf (buf, "%s-%"pI"d", SDATA (name_alist_or_stem),
- XINT (symbol_int) + 1);
+ XFIXNUM (symbol_int) + 1);
value = intern (buf);
SAFE_FREE ();
}
@@ -6667,22 +6550,22 @@ has the same base event type and all the specified modifiers. */)
if (SYMBOLP (base) && SCHARS (SYMBOL_NAME (base)) == 1)
XSETINT (base, SREF (SYMBOL_NAME (base), 0));
- if (INTEGERP (base))
+ if (FIXNUMP (base))
{
/* Turn (shift a) into A. */
if ((modifiers & shift_modifier) != 0
- && (XINT (base) >= 'a' && XINT (base) <= 'z'))
+ && (XFIXNUM (base) >= 'a' && XFIXNUM (base) <= 'z'))
{
- XSETINT (base, XINT (base) - ('a' - 'A'));
+ XSETINT (base, XFIXNUM (base) - ('a' - 'A'));
modifiers &= ~shift_modifier;
}
/* Turn (control a) into C-a. */
if (modifiers & ctrl_modifier)
- return make_number ((modifiers & ~ctrl_modifier)
- | make_ctrl_char (XINT (base)));
+ return make_fixnum ((modifiers & ~ctrl_modifier)
+ | make_ctrl_char (XFIXNUM (base)));
else
- return make_number (modifiers | XINT (base));
+ return make_fixnum (modifiers | XFIXNUM (base));
}
else if (SYMBOLP (base))
return apply_modifiers (modifiers, base);
@@ -6690,6 +6573,31 @@ has the same base event type and all the specified modifiers. */)
error ("Invalid base event");
}
+DEFUN ("internal-handle-focus-in", Finternal_handle_focus_in,
+ Sinternal_handle_focus_in, 1, 1, 0,
+ doc: /* Internally handle focus-in events.
+This function potentially generates an artifical switch-frame event. */)
+ (Lisp_Object event)
+{
+ Lisp_Object frame;
+ if (!EQ (CAR_SAFE (event), Qfocus_in) ||
+ !CONSP (XCDR (event)) ||
+ !FRAMEP ((frame = XCAR (XCDR (event)))))
+ error ("invalid focus-in event");
+
+ /* Conceptually, the concept of window manager focus on a particular
+ frame and the Emacs selected frame shouldn't be related, but for
+ a long time, we automatically switched the selected frame in
+ response to focus events, so let's keep doing that. */
+ bool switching = (!EQ (frame, internal_last_event_frame)
+ && !EQ (frame, selected_frame));
+ internal_last_event_frame = frame;
+ if (switching || !NILP (unread_switch_frame))
+ unread_switch_frame = make_lispy_switch_frame (frame);
+
+ return Qnil;
+}
+
/* Try to recognize SYMBOL as a modifier name.
Return the modifier flag bit, or 0 if not recognized. */
@@ -6800,7 +6708,7 @@ lucid_event_type_list_p (Lisp_Object object)
{
Lisp_Object elt;
elt = XCAR (tail);
- if (! (INTEGERP (elt) || SYMBOLP (elt)))
+ if (! (FIXNUMP (elt) || SYMBOLP (elt)))
return 0;
}
@@ -7449,7 +7357,7 @@ menu_bar_items (Lisp_Object old)
if (!NILP (old))
menu_bar_items_vector = old;
else
- menu_bar_items_vector = Fmake_vector (make_number (24), Qnil);
+ menu_bar_items_vector = make_nil_vector (24);
menu_bar_items_index = 0;
/* Build our list of keymaps.
@@ -7621,7 +7529,7 @@ menu_bar_item (Lisp_Object key, Lisp_Object item, Lisp_Object dummy1, void *dumm
ASET (menu_bar_items_vector, i,
AREF (item_properties, ITEM_PROPERTY_NAME)); i++;
ASET (menu_bar_items_vector, i, list1 (item)); i++;
- ASET (menu_bar_items_vector, i, make_number (0)); i++;
+ ASET (menu_bar_items_vector, i, make_fixnum (0)); i++;
menu_bar_items_index = i;
}
/* We did find an item for this KEY. Add ITEM to its list of maps. */
@@ -7692,8 +7600,7 @@ parse_menu_item (Lisp_Object item, int inmenubar)
/* Create item_properties vector if necessary. */
if (NILP (item_properties))
- item_properties
- = Fmake_vector (make_number (ITEM_PROPERTY_ENABLE + 1), Qnil);
+ item_properties = make_nil_vector (ITEM_PROPERTY_ENABLE + 1);
/* Initialize optional entries. */
for (i = ITEM_PROPERTY_DEF; i < ITEM_PROPERTY_ENABLE; i++)
@@ -8187,8 +8094,7 @@ parse_tool_bar_item (Lisp_Object key, Lisp_Object item)
set_prop (i, Qnil);
}
else
- tool_bar_item_properties
- = Fmake_vector (make_number (TOOL_BAR_ITEM_NSLOTS), Qnil);
+ tool_bar_item_properties = make_nil_vector (TOOL_BAR_ITEM_NSLOTS);
/* Set defaults. */
set_prop (TOOL_BAR_ITEM_KEY, key);
@@ -8383,7 +8289,7 @@ init_tool_bar_items (Lisp_Object reuse)
if (VECTORP (reuse))
tool_bar_items_vector = reuse;
else
- tool_bar_items_vector = Fmake_vector (make_number (64), Qnil);
+ tool_bar_items_vector = make_nil_vector (64);
ntool_bar_items = 0;
}
@@ -8454,7 +8360,7 @@ read_char_x_menu_prompt (Lisp_Object map,
/* Display the menu and get the selection. */
Lisp_Object value;
- value = Fx_popup_menu (prev_event, get_keymap (map, 0, 1));
+ value = x_popup_menu_1 (prev_event, get_keymap (map, 0, 1));
if (CONSP (value))
{
Lisp_Object tem;
@@ -8473,7 +8379,7 @@ read_char_x_menu_prompt (Lisp_Object map,
{
record_menu_key (XCAR (tem));
if (SYMBOLP (XCAR (tem))
- || INTEGERP (XCAR (tem)))
+ || FIXNUMP (XCAR (tem)))
XSETCAR (tem, Fcons (XCAR (tem), Qdisabled));
}
@@ -8584,7 +8490,7 @@ read_char_minibuf_menu_prompt (int commandflag,
}
/* Ignore the element if it has no prompt string. */
- if (INTEGERP (event) && parse_menu_item (elt, -1))
+ if (FIXNUMP (event) && parse_menu_item (elt, -1))
{
/* True if the char to type matches the string. */
bool char_matches;
@@ -8595,8 +8501,8 @@ read_char_minibuf_menu_prompt (int commandflag,
upcased_event = Fupcase (event);
downcased_event = Fdowncase (event);
- char_matches = (XINT (upcased_event) == SREF (s, 0)
- || XINT (downcased_event) == SREF (s, 0));
+ char_matches = (XFIXNUM (upcased_event) == SREF (s, 0)
+ || XFIXNUM (downcased_event) == SREF (s, 0));
if (! char_matches)
desc = Fsingle_key_description (event, Qnil);
@@ -8652,8 +8558,8 @@ read_char_minibuf_menu_prompt (int commandflag,
/* Add as much of string as fits. */
thiswidth = min (SCHARS (desc), width - i);
menu_strings
- = Fcons (Fsubstring (desc, make_number (0),
- make_number (thiswidth)),
+ = Fcons (Fsubstring (desc, make_fixnum (0),
+ make_fixnum (thiswidth)),
menu_strings);
i += thiswidth;
PUSH_C_STR (" = ", menu_strings);
@@ -8663,8 +8569,8 @@ read_char_minibuf_menu_prompt (int commandflag,
/* Add as much of string as fits. */
thiswidth = min (SCHARS (s), width - i);
menu_strings
- = Fcons (Fsubstring (s, make_number (0),
- make_number (thiswidth)),
+ = Fcons (Fsubstring (s, make_fixnum (0),
+ make_fixnum (thiswidth)),
menu_strings);
i += thiswidth;
}
@@ -8701,10 +8607,10 @@ read_char_minibuf_menu_prompt (int commandflag,
while (BUFFERP (obj));
kset_defining_kbd_macro (current_kboard, orig_defn_macro);
- if (!INTEGERP (obj) || XINT (obj) == -2
+ if (!FIXNUMP (obj) || XFIXNUM (obj) == -2
|| (! EQ (obj, menu_prompt_more_char)
- && (!INTEGERP (menu_prompt_more_char)
- || ! EQ (obj, make_number (Ctl (XINT (menu_prompt_more_char)))))))
+ && (!FIXNUMP (menu_prompt_more_char)
+ || ! EQ (obj, make_fixnum (Ctl (XFIXNUM (menu_prompt_more_char)))))))
{
if (!NILP (KVAR (current_kboard, defining_kbd_macro)))
store_kbd_macro_char (obj);
@@ -8724,10 +8630,19 @@ follow_key (Lisp_Object keymap, Lisp_Object key)
}
static Lisp_Object
-active_maps (Lisp_Object first_event)
+active_maps (Lisp_Object first_event, Lisp_Object second_event)
{
Lisp_Object position
- = CONSP (first_event) ? CAR_SAFE (XCDR (first_event)) : Qnil;
+ = EVENT_HAS_PARAMETERS (first_event) ? EVENT_START (first_event) : Qnil;
+ /* The position of a click can be in the second event if the first event
+ is a fake_prefixed_key like `header-line` or `mode-line`. */
+ if (SYMBOLP (first_event)
+ && EVENT_HAS_PARAMETERS (second_event)
+ && EQ (first_event, POSN_POSN (EVENT_START (second_event))))
+ {
+ eassert (NILP (position));
+ position = EVENT_START (second_event);
+ }
return Fcons (Qkeymap, Fcurrent_active_maps (Qt, position));
}
@@ -8789,8 +8704,7 @@ access_keymap_keyremap (Lisp_Object map, Lisp_Object key, Lisp_Object prompt,
/* Do one step of the key remapping used for function-key-map and
key-translation-map:
- KEYBUF is the buffer holding the input events.
- BUFSIZE is its maximum size.
+ KEYBUF is the READ_KEY_ELTS-size buffer holding the input events.
FKEY is a pointer to the keyremap structure to use.
INPUT is the index of the last element in KEYBUF.
DOIT if true says that the remapping can actually take place.
@@ -8800,7 +8714,7 @@ access_keymap_keyremap (Lisp_Object map, Lisp_Object key, Lisp_Object prompt,
Return true if the remapping actually took place. */
static bool
-keyremap_step (Lisp_Object *keybuf, int bufsize, volatile keyremap *fkey,
+keyremap_step (Lisp_Object *keybuf, volatile keyremap *fkey,
int input, bool doit, int *diff, Lisp_Object prompt)
{
Lisp_Object next, key;
@@ -8817,12 +8731,12 @@ keyremap_step (Lisp_Object *keybuf, int bufsize, volatile keyremap *fkey,
the binding and restart with fkey->start at the end. */
if ((VECTORP (next) || STRINGP (next)) && doit)
{
- int len = XFASTINT (Flength (next));
+ int len = XFIXNAT (Flength (next));
int i;
*diff = len - (fkey->end - fkey->start);
- if (bufsize - input <= *diff)
+ if (READ_KEY_ELTS - input <= *diff)
error ("Key sequence too long");
/* Shift the keys that follow fkey->end. */
@@ -8835,7 +8749,7 @@ keyremap_step (Lisp_Object *keybuf, int bufsize, volatile keyremap *fkey,
/* Overwrite the old keys with the new ones. */
for (i = 0; i < len; i++)
keybuf[fkey->start + i]
- = Faref (next, make_number (i));
+ = Faref (next, make_fixnum (i));
fkey->start = fkey->end += *diff;
fkey->map = fkey->parent;
@@ -8864,8 +8778,13 @@ test_undefined (Lisp_Object binding)
&& EQ (Fcommand_remapping (binding, Qnil, Qnil), Qundefined)));
}
+void init_raw_keybuf_count (void)
+{
+ raw_keybuf_count = 0;
+}
+
/* Read a sequence of keys that ends with a non prefix character,
- storing it in KEYBUF, a buffer of size BUFSIZE.
+ storing it in KEYBUF, a buffer of size READ_KEY_ELTS.
Prompt with PROMPT.
Return the length of the key sequence stored.
Return -1 if the user rejected a command menu.
@@ -8905,7 +8824,7 @@ test_undefined (Lisp_Object binding)
from the selected window's buffer. */
static int
-read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
+read_key_sequence (Lisp_Object *keybuf, Lisp_Object prompt,
bool dont_downcase_last, bool can_return_switch_frame,
bool fix_current_buffer, bool prevent_redisplay)
{
@@ -8920,7 +8839,6 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
ptrdiff_t keys_start;
Lisp_Object current_binding = Qnil;
- Lisp_Object first_event = Qnil;
/* Index of the first key that has no binding.
It is useless to try fkey.start larger than that. */
@@ -8941,6 +8859,9 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
reading characters from the keyboard. */
int mock_input = 0;
+ /* Whether each event in the mocked input came from a mouse menu. */
+ bool used_mouse_menu_history[READ_KEY_ELTS] = {0};
+
/* If the sequence is unbound in submaps[], then
keybuf[fkey.start..fkey.end-1] is a prefix in Vfunction_key_map,
and fkey.map is its binding.
@@ -8975,9 +8896,11 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
/* List of events for which a fake prefix key has been generated. */
Lisp_Object fake_prefixed_keys = Qnil;
- raw_keybuf_count = 0;
-
- last_nonmenu_event = Qnil;
+ /* raw_keybuf_count is now initialized in (most of) the callers of
+ read_key_sequence. This is so that in a recursive call (for
+ mouse menus) a spurious initialization doesn't erase the contents
+ of raw_keybuf created by the outer call. */
+ /* raw_keybuf_count = 0; */
delayed_switch_frame = Qnil;
@@ -9029,17 +8952,20 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
replay_sequence:
starting_buffer = current_buffer;
- first_unbound = bufsize + 1;
+ first_unbound = READ_KEY_ELTS + 1;
+ Lisp_Object first_event = mock_input > 0 ? keybuf[0] : Qnil;
+ Lisp_Object second_event = mock_input > 1 ? keybuf[1] : Qnil;
/* Build our list of keymaps.
If we recognize a function key and replace its escape sequence in
keybuf with its symbol, or if the sequence starts with a mouse
click and we need to switch buffers, we jump back here to rebuild
the initial keymaps from the current buffer. */
- current_binding = active_maps (first_event);
+ current_binding = active_maps (first_event, second_event);
/* Start from the beginning in keybuf. */
t = 0;
+ last_nonmenu_event = Qnil;
/* These are no-ops the first time through, but if we restart, they
revert the echo area and this_command_keys to their original state. */
@@ -9107,7 +9033,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
goto replay_sequence;
}
- if (t >= bufsize)
+ if (t >= READ_KEY_ELTS)
error ("Key sequence too long");
if (INTERACTIVE)
@@ -9138,6 +9064,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
current_kboard->immediate_echo = false;
echo_now ();
}
+ used_mouse_menu = used_mouse_menu_history[t];
}
/* If not, we should actually read a character. */
@@ -9151,7 +9078,8 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
key = read_char (prevent_redisplay ? -2 : NILP (prompt),
current_binding, last_nonmenu_event,
&used_mouse_menu, NULL);
- if ((INTEGERP (key) && XINT (key) == -2) /* wrong_kboard_jmpbuf */
+ used_mouse_menu_history[t] = used_mouse_menu;
+ if ((FIXNUMP (key) && XFIXNUM (key) == -2) /* wrong_kboard_jmpbuf */
/* When switching to a new tty (with a new keyboard),
read_char returns the new buffer, rather than -2
(Bug#5095). This is because `terminal-init-xterm'
@@ -9219,7 +9147,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
/* read_char returns -1 at the end of a macro.
Emacs 18 handles this by returning immediately with a
zero, so that's what we'll do. */
- if (INTEGERP (key) && XINT (key) == -1)
+ if (FIXNUMP (key) && XFIXNUM (key) == -1)
{
t = 0;
/* The Microsoft C compiler can't handle the goto that
@@ -9254,8 +9182,8 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
/* If we have a quit that was typed in another frame, and
quit_throw_to_read_char switched buffers,
replay to get the right keymap. */
- if (INTEGERP (key)
- && XINT (key) == quit_char
+ if (FIXNUMP (key)
+ && XFIXNUM (key) == quit_char
&& current_buffer != starting_buffer)
{
GROW_RAW_KEYBUF;
@@ -9296,11 +9224,14 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
&& (XBUFFER (XWINDOW (selected_window)->contents)
!= current_buffer))
Fset_buffer (XWINDOW (selected_window)->contents);
- current_binding = active_maps (first_event);
+ current_binding = active_maps (first_event, Qnil);
}
GROW_RAW_KEYBUF;
- ASET (raw_keybuf, raw_keybuf_count, key);
+ ASET (raw_keybuf, raw_keybuf_count,
+ /* Copy the event, in case it gets modified by side-effect
+ by some remapping function (bug#30955). */
+ CONSP (key) ? Fcopy_sequence (key) : key);
raw_keybuf_count++;
}
@@ -9347,8 +9278,6 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
&& BUFFERP (XWINDOW (window)->contents)
&& XBUFFER (XWINDOW (window)->contents) != current_buffer)
{
- ASET (raw_keybuf, raw_keybuf_count, key);
- raw_keybuf_count++;
keybuf[t] = key;
mock_input = t + 1;
@@ -9377,7 +9306,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
&& (NILP (fake_prefixed_keys)
|| NILP (Fmemq (key, fake_prefixed_keys))))
{
- if (bufsize - t <= 1)
+ if (READ_KEY_ELTS - t <= 1)
error ("Key sequence too long");
keybuf[t] = posn;
@@ -9393,24 +9322,24 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
}
}
else if (CONSP (XCDR (key))
- && CONSP (EVENT_START (key))
- && CONSP (XCDR (EVENT_START (key))))
+ && CONSP (xevent_start (key))
+ && CONSP (XCDR (xevent_start (key))))
{
Lisp_Object posn;
- posn = POSN_POSN (EVENT_START (key));
+ posn = POSN_POSN (xevent_start (key));
/* Handle menu-bar events:
insert the dummy prefix event `menu-bar'. */
if (EQ (posn, Qmenu_bar) || EQ (posn, Qtool_bar))
{
- if (bufsize - t <= 1)
+ if (READ_KEY_ELTS - t <= 1)
error ("Key sequence too long");
keybuf[t] = posn;
keybuf[t + 1] = key;
/* Zap the position in key, so we know that we've
expanded it, and don't try to do so again. */
- POSN_SET_POSN (EVENT_START (key), list1 (posn));
+ POSN_SET_POSN (xevent_start (key), list1 (posn));
mock_input = t + 2;
goto replay_sequence;
@@ -9454,7 +9383,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
int modifiers;
breakdown = parse_modifiers (head);
- modifiers = XINT (XCAR (XCDR (breakdown)));
+ modifiers = XFIXNUM (XCAR (XCDR (breakdown)));
/* Attempt to reduce an unbound mouse event to a simpler
event that is bound:
Drags reduce to clicks.
@@ -9606,8 +9535,8 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
bool done;
int diff;
- done = keyremap_step (keybuf, bufsize, &indec, max (t, mock_input),
- 1, &diff, prompt);
+ done = keyremap_step (keybuf, &indec, max (t, mock_input),
+ true, &diff, prompt);
if (done)
{
mock_input = diff + max (t, mock_input);
@@ -9637,13 +9566,13 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
bool done;
int diff;
- done = keyremap_step (keybuf, bufsize, &fkey,
+ done = keyremap_step (keybuf, &fkey,
max (t, mock_input),
/* If there's a binding (i.e.
first_binding >= nmaps) we don't want
to apply this function-key-mapping. */
- fkey.end + 1 == t
- && (test_undefined (current_binding)),
+ (fkey.end + 1 == t
+ && test_undefined (current_binding)),
&diff, prompt);
if (done)
{
@@ -9663,8 +9592,8 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
bool done;
int diff;
- done = keyremap_step (keybuf, bufsize, &keytran, max (t, mock_input),
- 1, &diff, prompt);
+ done = keyremap_step (keybuf, &keytran, max (t, mock_input),
+ true, &diff, prompt);
if (done)
{
mock_input = diff + max (t, mock_input);
@@ -9684,14 +9613,14 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
use the corresponding lower-case letter instead. */
if (NILP (current_binding)
&& /* indec.start >= t && fkey.start >= t && */ keytran.start >= t
- && INTEGERP (key))
+ && FIXNUMP (key))
{
Lisp_Object new_key;
- EMACS_INT k = XINT (key);
+ EMACS_INT k = XFIXNUM (key);
if (k & shift_modifier)
XSETINT (new_key, k & ~shift_modifier);
- else if (CHARACTERP (make_number (k & ~CHAR_MODIFIER_MASK)))
+ else if (CHARACTERP (make_fixnum (k & ~CHAR_MODIFIER_MASK)))
{
int dc = downcase (k & ~CHAR_MODIFIER_MASK);
if (dc == (k & ~CHAR_MODIFIER_MASK))
@@ -9734,11 +9663,11 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
{
Lisp_Object breakdown = parse_modifiers (key);
int modifiers
- = CONSP (breakdown) ? (XINT (XCAR (XCDR (breakdown)))) : 0;
+ = CONSP (breakdown) ? (XFIXNUM (XCAR (XCDR (breakdown)))) : 0;
if (modifiers & shift_modifier
/* Treat uppercase keys as shifted. */
- || (INTEGERP (key)
+ || (FIXNUMP (key)
&& (KEY_TO_CHAR (key)
< XCHAR_TABLE (BVAR (current_buffer, downcase_table))->header.size)
&& uppercasep (KEY_TO_CHAR (key))))
@@ -9747,7 +9676,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
= (modifiers & shift_modifier
? apply_modifiers (modifiers & ~shift_modifier,
XCAR (breakdown))
- : make_number (downcase (KEY_TO_CHAR (key)) | modifiers));
+ : make_fixnum (downcase (KEY_TO_CHAR (key)) | modifiers));
original_uppercase = key;
original_uppercase_position = t - 1;
@@ -9817,8 +9746,6 @@ read_key_sequence_vs (Lisp_Object prompt, Lisp_Object continue_echo,
Lisp_Object can_return_switch_frame,
Lisp_Object cmd_loop, bool allow_string)
{
- Lisp_Object keybuf[30];
- int i;
ptrdiff_t count = SPECPDL_INDEX ();
if (!NILP (prompt))
@@ -9841,9 +9768,10 @@ read_key_sequence_vs (Lisp_Object prompt, Lisp_Object continue_echo,
cancel_hourglass ();
#endif
- i = read_key_sequence (keybuf, ARRAYELTS (keybuf),
- prompt, ! NILP (dont_downcase_last),
- ! NILP (can_return_switch_frame), 0, 0);
+ raw_keybuf_count = 0;
+ Lisp_Object keybuf[READ_KEY_ELTS];
+ int i = read_key_sequence (keybuf, prompt, ! NILP (dont_downcase_last),
+ ! NILP (can_return_switch_frame), false, false);
#if 0 /* The following is fine for code reading a key sequence and
then proceeding with a lengthy computation, but it's not good
@@ -10069,16 +9997,16 @@ Internal use only. */)
/* Kludge alert: this makes M-x be in the form expected by
novice.el. (248 is \370, a.k.a. "Meta-x".) Any better ideas? */
if (key0 == 248)
- add_command_key (make_number ('x' | meta_modifier));
+ add_command_key (make_fixnum ('x' | meta_modifier));
else
- add_command_key (make_number (key0));
+ add_command_key (make_fixnum (key0));
for (ptrdiff_t i = 1; i < SCHARS (keys); i++)
{
int key_i;
FETCH_STRING_CHAR_ADVANCE (key_i, keys, charidx, byteidx);
if (CHAR_BYTE8_P (key_i))
key_i = CHAR_TO_BYTE8 (key_i);
- add_command_key (make_number (key_i));
+ add_command_key (make_fixnum (key_i));
}
return Qnil;
}
@@ -10151,15 +10079,18 @@ DEFUN ("recursion-depth", Frecursion_depth, Srecursion_depth, 0, 0, 0,
{
EMACS_INT sum;
INT_ADD_WRAPV (command_loop_level, minibuf_level, &sum);
- return make_number (sum);
+ return make_fixnum (sum);
}
DEFUN ("open-dribble-file", Fopen_dribble_file, Sopen_dribble_file, 1, 1,
"FOpen dribble file: ",
- doc: /* Start writing all keyboard characters to a dribble file called FILE.
+ doc: /* Start writing input events to a dribble file called FILE.
If FILE is nil, close any open dribble file.
The file will be closed when Emacs exits.
+The events written to the file include keyboard and mouse input
+events, but not events from executing keyboard macros.
+
Be aware that this records ALL characters you type!
This may include sensitive information such as passwords. */)
(Lisp_Object file)
@@ -10290,15 +10221,14 @@ stuff_buffered_input (Lisp_Object stuffstring)
rms: we should stuff everything back into the kboard
it came from. */
- for (; kbd_fetch_ptr != kbd_store_ptr; kbd_fetch_ptr++)
+ for (; kbd_fetch_ptr != kbd_store_ptr;
+ kbd_fetch_ptr = next_kbd_event (kbd_fetch_ptr))
{
- if (kbd_fetch_ptr == kbd_buffer + KBD_BUFFER_SIZE)
- kbd_fetch_ptr = kbd_buffer;
if (kbd_fetch_ptr->kind == ASCII_KEYSTROKE_EVENT)
stuff_char (kbd_fetch_ptr->ie.code);
- clear_event (kbd_fetch_ptr);
+ clear_event (&kbd_fetch_ptr->ie);
}
input_pending = false;
@@ -10701,7 +10631,7 @@ See also `current-input-mode'. */)
return Qnil;
tty = t->display_info.tty;
- if (NILP (quit) || !INTEGERP (quit) || XINT (quit) < 0 || XINT (quit) > 0400)
+ if (NILP (quit) || !FIXNUMP (quit) || XFIXNUM (quit) < 0 || XFIXNUM (quit) > 0400)
error ("QUIT must be an ASCII character");
#ifndef DOS_NT
@@ -10710,7 +10640,7 @@ See also `current-input-mode'. */)
#endif
/* Don't let this value be out of range. */
- quit_char = XINT (quit) & (tty->meta_key == 0 ? 0177 : 0377);
+ quit_char = XFIXNUM (quit) & (tty->meta_key == 0 ? 0177 : 0377);
#ifndef DOS_NT
init_sys_modes (tty);
@@ -10764,7 +10694,7 @@ The elements of this list correspond to the arguments of
{
flow = FRAME_TTY (sf)->flow_control ? Qt : Qnil;
meta = (FRAME_TTY (sf)->meta_key == 2
- ? make_number (0)
+ ? make_fixnum (0)
: (CURTTY ()->meta_key == 1 ? Qt : Qnil));
}
else
@@ -10772,7 +10702,7 @@ The elements of this list correspond to the arguments of
flow = Qnil;
meta = Qt;
}
- Lisp_Object quit = make_number (quit_char);
+ Lisp_Object quit = make_fixnum (quit_char);
return list4 (interrupt, flow, meta, quit);
}
@@ -10790,12 +10720,12 @@ The return value is similar to a mouse click position:
The `posn-' functions access elements of such lists. */)
(Lisp_Object x, Lisp_Object y, Lisp_Object frame_or_window, Lisp_Object whole)
{
- CHECK_NUMBER (x);
+ CHECK_FIXNUM (x);
/* We allow X of -1, for the newline in a R2L line that overflowed
into the left fringe. */
- if (XINT (x) != -1)
- CHECK_NATNUM (x);
- CHECK_NATNUM (y);
+ if (XFIXNUM (x) != -1)
+ CHECK_FIXNAT (x);
+ CHECK_FIXNAT (y);
if (NILP (frame_or_window))
frame_or_window = selected_window;
@@ -10804,12 +10734,12 @@ The `posn-' functions access elements of such lists. */)
{
struct window *w = decode_live_window (frame_or_window);
- XSETINT (x, (XINT (x)
+ XSETINT (x, (XFIXNUM (x)
+ WINDOW_LEFT_EDGE_X (w)
+ (NILP (whole)
? window_box_left_offset (w, TEXT_AREA)
: 0)));
- XSETINT (y, WINDOW_TO_FRAME_PIXEL_Y (w, XINT (y)));
+ XSETINT (y, WINDOW_TO_FRAME_PIXEL_Y (w, XFIXNUM (y)));
frame_or_window = w->frame;
}
@@ -10842,17 +10772,17 @@ The `posn-' functions access elements of such lists. */)
Lisp_Object x = XCAR (tem);
Lisp_Object y = XCAR (XCDR (tem));
Lisp_Object aux_info = XCDR (XCDR (tem));
- int y_coord = XINT (y);
+ int y_coord = XFIXNUM (y);
/* Point invisible due to hscrolling? X can be -1 when a
newline in a R2L line overflows into the left fringe. */
- if (XINT (x) < -1)
+ if (XFIXNUM (x) < -1)
return Qnil;
if (!NILP (aux_info) && y_coord < 0)
{
- int rtop = XINT (XCAR (aux_info));
+ int rtop = XFIXNUM (XCAR (aux_info));
- y = make_number (y_coord + rtop);
+ y = make_fixnum (y_coord + rtop);
}
tem = Fposn_at_x_y (x, y, window, Qnil);
}
@@ -11119,6 +11049,10 @@ syms_of_keyboard (void)
DEFSYM (Qdbus_event, "dbus-event");
#endif
+#ifdef THREADS_ENABLED
+ DEFSYM (Qthread_event, "thread-event");
+#endif
+
#ifdef HAVE_XWIDGETS
DEFSYM (Qxwidget_event, "xwidget-event");
#endif
@@ -11243,32 +11177,31 @@ syms_of_keyboard (void)
}
}
- button_down_location = Fmake_vector (make_number (5), Qnil);
+ button_down_location = make_nil_vector (5);
staticpro (&button_down_location);
- mouse_syms = Fmake_vector (make_number (5), Qnil);
+ mouse_syms = make_nil_vector (5);
staticpro (&mouse_syms);
- wheel_syms = Fmake_vector (make_number (ARRAYELTS (lispy_wheel_names)),
- Qnil);
+ wheel_syms = make_nil_vector (ARRAYELTS (lispy_wheel_names));
staticpro (&wheel_syms);
{
int i;
int len = ARRAYELTS (modifier_names);
- modifier_symbols = Fmake_vector (make_number (len), Qnil);
+ modifier_symbols = make_nil_vector (len);
for (i = 0; i < len; i++)
if (modifier_names[i])
ASET (modifier_symbols, i, intern_c_string (modifier_names[i]));
staticpro (&modifier_symbols);
}
- recent_keys = Fmake_vector (make_number (NUM_RECENT_KEYS), Qnil);
+ recent_keys = make_nil_vector (NUM_RECENT_KEYS);
staticpro (&recent_keys);
- this_command_keys = Fmake_vector (make_number (40), Qnil);
+ this_command_keys = make_nil_vector (40);
staticpro (&this_command_keys);
- raw_keybuf = Fmake_vector (make_number (30), Qnil);
+ raw_keybuf = make_nil_vector (30);
staticpro (&raw_keybuf);
DEFSYM (Qcommand_execute, "command-execute");
@@ -11306,6 +11239,7 @@ syms_of_keyboard (void)
defsubr (&Scurrent_idle_time);
defsubr (&Sevent_symbol_parse_modifiers);
defsubr (&Sevent_convert_list);
+ defsubr (&Sinternal_handle_focus_in);
defsubr (&Sread_key_sequence);
defsubr (&Sread_key_sequence_vector);
defsubr (&Srecursive_edit);
@@ -11431,6 +11365,10 @@ result of looking up the original command in the active keymaps. */);
Zero means disable autosaving due to number of characters typed. */);
auto_save_interval = 300;
+ DEFVAR_BOOL ("auto-save-no-message", auto_save_no_message,
+ doc: /* Non-nil means do not print any message when auto-saving. */);
+ auto_save_no_message = false;
+
DEFVAR_LISP ("auto-save-timeout", Vauto_save_timeout,
doc: /* Number of seconds idle time before auto-save.
Zero or nil means disable auto-saving due to idleness.
@@ -11442,7 +11380,7 @@ Emacs also does a garbage collection if that seems to be warranted. */);
doc: /* Nonzero means echo unfinished commands after this many seconds of pause.
The value may be integer or floating point.
If the value is zero, don't echo at all. */);
- Vecho_keystrokes = make_number (1);
+ Vecho_keystrokes = make_fixnum (1);
DEFVAR_INT ("polling-period", polling_period,
doc: /* Interval between polling for input during Lisp execution.
@@ -11456,7 +11394,7 @@ Polling is automatically disabled in all other cases. */);
Measured in milliseconds. The value nil means disable double-click
recognition; t means double-clicks have no time limit and are detected
by position only. */);
- Vdouble_click_time = make_number (500);
+ Vdouble_click_time = make_fixnum (500);
DEFVAR_INT ("double-click-fuzz", double_click_fuzz,
doc: /* Maximum mouse movement between clicks to make a double-click.
@@ -11806,7 +11744,7 @@ suppressed only after special commands that leave
doc: /* How long to display an echo-area message when the minibuffer is active.
If the value is a number, it should be specified in seconds.
If the value is not a number, such messages never time out. */);
- Vminibuffer_message_timeout = make_number (2);
+ Vminibuffer_message_timeout = make_fixnum (2);
DEFVAR_LISP ("throw-on-input", Vthrow_on_input,
doc: /* If non-nil, any keyboard input throws to this symbol.
@@ -11897,6 +11835,14 @@ If nil, Emacs crashes immediately in response to fatal signals. */);
Vwhile_no_input_ignore_events,
doc: /* Ignored events from while-no-input. */);
Vwhile_no_input_ignore_events = Qnil;
+
+ DEFVAR_BOOL ("inhibit--record-char",
+ inhibit_record_char,
+ doc: /* If non-nil, don't record input events.
+This inhibits recording input events for the purposes of keyboard
+macros, dribble file, and `recent-keys'.
+Internal use only. */);
+ inhibit_record_char = false;
}
void
@@ -11957,6 +11903,12 @@ keys_of_keyboard (void)
"dbus-handle-event");
#endif
+#ifdef THREADS_ENABLED
+ /* Define a special event which is raised for thread signals. */
+ initial_define_lispy_key (Vspecial_event_map, "thread-event",
+ "thread-handle-event");
+#endif
+
#ifdef USE_FILE_NOTIFY
/* Define a special event which is raised for notification callback
functions. */
@@ -12009,26 +11961,18 @@ mark_kboards (void)
mark_object (KVAR (kb, echo_string));
mark_object (KVAR (kb, echo_prompt));
}
- {
- union buffered_input_event *event;
- for (event = kbd_fetch_ptr; event != kbd_store_ptr; event++)
- {
- if (event == kbd_buffer + KBD_BUFFER_SIZE)
- {
- event = kbd_buffer;
- if (event == kbd_store_ptr)
- break;
- }
- /* These two special event types has no Lisp_Objects to mark. */
- if (event->kind != SELECTION_REQUEST_EVENT
- && event->kind != SELECTION_CLEAR_EVENT)
- {
- mark_object (event->ie.x);
- mark_object (event->ie.y);
- mark_object (event->ie.frame_or_window);
- mark_object (event->ie.arg);
- }
- }
- }
+ for (union buffered_input_event *event = kbd_fetch_ptr;
+ event != kbd_store_ptr; event = next_kbd_event (event))
+ {
+ /* These two special event types have no Lisp_Objects to mark. */
+ if (event->kind != SELECTION_REQUEST_EVENT
+ && event->kind != SELECTION_CLEAR_EVENT)
+ {
+ mark_object (event->ie.x);
+ mark_object (event->ie.y);
+ mark_object (event->ie.frame_or_window);
+ mark_object (event->ie.arg);
+ }
+ }
}