/* Keyboard and mouse input; editor command loop.
- Copyright (C) 1985,86,87,88,89,93,94,95,96,97,99 Free Software Foundation, Inc.
+ Copyright (C) 1985,86,87,88,89,93,94,95,96,97,99, 2000
+ Free Software Foundation, Inc.
This file is part of GNU Emacs.
#include "intervals.h"
#include "blockinput.h"
#include "puresize.h"
+#include "systime.h"
+#include "atimer.h"
#include <setjmp.h>
#include <errno.h>
key sequence that it reads. */
Lisp_Object read_key_sequence_cmd;
+/* Echo unfinished commands after this many seconds of pause. */
+Lisp_Object Vecho_keystrokes;
+
/* Form to evaluate (if non-nil) when Emacs is started. */
Lisp_Object Vtop_level;
#ifdef HAVE_WINDOW_SYSTEM
#define POLL_FOR_INPUT
#endif
+
+/* After a command is executed, if point is moved into a region that
+ has specific properties (e.g. composition, display), we adjust
+ point to the boundary of the region. But, if a command sets this
+ valiable to non-nil, we suppress this point adjustment. This
+ variable is set to nil before reading a command. */
+Lisp_Object Vdisable_point_adjustment;
+
+/* If non-nil, always disable point adjustment. */
+Lisp_Object Vglobal_disable_point_adjustment;
+
\f
/* Global variable declarations. */
static void restore_getcjmp ();
static Lisp_Object apply_modifiers P_ ((int, Lisp_Object));
-/* > 0 if we are to echo keystrokes. */
-static int echo_keystrokes;
-
/* Nonzero means don't try to suspend even if the operating system seems
to support it. */
static int cannot_suspend;
if (INTEGERP (c))
{
- if (ptr - current_kboard->echobuf > ECHOBUFSIZE - 6)
+ if (ptr - current_kboard->echobuf
+ > ECHOBUFSIZE - KEY_DESCRIPTION_SIZE)
return;
ptr = push_key_description (XINT (c), ptr);
Lisp_Object Fcommand_execute ();
static int read_key_sequence ();
void safe_run_hooks ();
+static void adjust_point_for_property ();
Lisp_Object
command_loop_1 ()
int nonundocount;
Lisp_Object keybuf[30];
int i;
- int no_redisplay;
int no_direct;
int prev_modiff;
struct buffer *prev_buffer;
cancel_echoing ();
nonundocount = 0;
- no_redisplay = 0;
this_command_key_count = 0;
this_single_command_key_start = 0;
}
/* Do redisplay processing after this command except in special
- cases identified below that set no_redisplay to 1.
- (actually, there's currently no way to prevent the redisplay,
- and no_redisplay is ignored.
- Perhaps someday we will really implement it.) */
- no_redisplay = 0;
-
+ cases identified below. */
prev_buffer = current_buffer;
prev_modiff = MODIFF;
last_point_position = PT;
XSETBUFFER (last_point_position_buffer, prev_buffer);
+ /* By default, we adjust point to a boundary of a region that
+ has such a property that should be treated intangible
+ (e.g. composition, display). But, some commands will set
+ this variable differently. */
+ Vdisable_point_adjustment = Qnil;
+
/* Execute the command. */
Vthis_command = cmd;
&& !detect_input_pending ()
&& NILP (XWINDOW (selected_window)->column_number_displayed)
&& NILP (Vexecuting_macro))
- no_redisplay = direct_output_forward_char (1);
+ direct_output_forward_char (1);
goto directly_done;
}
else if (EQ (Vthis_command, Qbackward_char) && PT > BEGV)
&& !detect_input_pending ()
&& NILP (XWINDOW (selected_window)->column_number_displayed)
&& NILP (Vexecuting_macro))
- no_redisplay = direct_output_forward_char (-1);
+ direct_output_forward_char (-1);
goto directly_done;
}
else if (EQ (Vthis_command, Qself_insert_command)
installed which is the case most of the time
because FONT-LOCK installs one. */
if (!lose && !value)
- no_redisplay = direct_output_for_insert (c);
+ direct_output_for_insert (c);
goto directly_done;
}
}
#ifdef HAVE_X_WINDOWS
if (display_busy_cursor_p)
- {
- if (inhibit_busy_cursor != 2)
- inhibit_busy_cursor = 0;
- if (!inhibit_busy_cursor)
- Fx_show_busy_cursor ();
- }
+ start_busy_cursor ();
#endif
nonundocount = 0;
if (NILP (current_kboard->Vprefix_arg))
Fundo_boundary ();
Fcommand_execute (Vthis_command, Qnil, Qnil, Qnil);
+
+#ifdef HAVE_X_WINDOWS
+ if (display_busy_cursor_p)
+ cancel_busy_cursor ();
+#endif
}
directly_done: ;
current_kboard->Vlast_prefix_arg = Vcurrent_prefix_arg;
}
finalize:
+
+ if (current_buffer == prev_buffer
+ && last_point_position != PT
+ && NILP (Vdisable_point_adjustment)
+ && NILP (Vglobal_disable_point_adjustment))
+ adjust_point_for_property (last_point_position);
+
/* Install chars successfully executed in kbd macro. */
if (!NILP (current_kboard->defining_kbd_macro)
}
}
+extern Lisp_Object Qcomposition, Qdisplay;
+
+/* Adjust point to a boundary of a region that has such a property
+ that should be treated intangible. For the moment, we check
+ `composition' and `display' property. LAST_PT is the last position
+ of point. */
+
+static void
+adjust_point_for_property (last_pt)
+ int last_pt;
+{
+ int start, end;
+ Lisp_Object val;
+ int check_composition = 1, check_display = 1;
+
+ while (check_composition || check_display)
+ {
+ if (check_composition
+ && PT > BEGV && PT < ZV
+ && get_property_and_range (PT, Qcomposition, &val, &start, &end, Qnil)
+ && COMPOSITION_VALID_P (start, end, val)
+ && start < PT && end > PT
+ && (last_pt <= start || last_pt >= end))
+ {
+ if (PT < last_pt)
+ SET_PT (start);
+ else
+ SET_PT (end);
+ check_display = 1;
+ }
+ check_composition = 0;
+ if (check_display
+ && PT > BEGV && PT < ZV
+ && get_property_and_range (PT, Qdisplay, &val, &start, &end, Qnil)
+ && start < PT && end > PT
+ && (last_pt <= start || last_pt >= end))
+ {
+ if (PT < last_pt)
+ SET_PT (start);
+ else
+ SET_PT (end);
+ check_composition = 1;
+ }
+ check_display = 0;
+ }
+}
+
/* Subroutine for safe_run_hooks: run the hook HOOK. */
static Lisp_Object
unbind_to (count, Qnil);
}
+
\f
-/* Number of seconds between polling for input. */
+/* Number of seconds between polling for input. This is a Lisp
+ variable that can be bound. */
+
int polling_period;
/* Nonzero means polling for input is temporarily suppressed. */
+
int poll_suppress_count;
-/* Nonzero if polling_for_input is actually being used. */
-int polling_for_input;
+/* Asynchronous timer for polling. */
+
+struct atimer *poll_timer;
+
#ifdef POLL_FOR_INPUT
-/* Handle an alarm once each second and read pending input
- so as to handle a C-g if it comces in. */
+/* Poll for input, so what we catch a C-g if it comes in. This
+ function is called from x_make_frame_visible, see comment
+ there. */
-SIGTYPE
-input_poll_signal (signalnum) /* If we don't have an argument, */
- int signalnum; /* some compilers complain in signal calls. */
+void
+poll_for_input_1 ()
{
- /* This causes the call to start_polling at the end
- to do its job. It also arranges for a quit or error
- from within read_avail_input to resume polling. */
- poll_suppress_count++;
if (interrupt_input_blocked == 0
&& !waiting_for_input)
read_avail_input (0);
- /* Turn on the SIGALRM handler and request another alarm. */
- start_polling ();
}
-#endif
+/* Timer callback function for poll_timer. TIMER is equal to
+ poll_timer. */
+
+void
+poll_for_input (timer)
+ struct atimer *timer;
+{
+ if (poll_suppress_count == 0)
+ poll_for_input_1 ();
+}
+
+#endif /* POLL_FOR_INPUT */
/* Begin signals to poll for input, if they are appropriate.
This function is called unconditionally from various places. */
#ifdef POLL_FOR_INPUT
if (read_socket_hook && !interrupt_input)
{
- poll_suppress_count--;
- if (poll_suppress_count == 0)
+ /* Turn alarm handling on unconditionally. It might have
+ been turned off in process.c. */
+ turn_on_atimers (1);
+
+ /* If poll timer doesn't exist, are we need one with
+ a different interval, start a new one. */
+ if (poll_timer == NULL
+ || EMACS_SECS (poll_timer->interval) != polling_period)
{
- signal (SIGALRM, input_poll_signal);
- polling_for_input = 1;
- alarm (polling_period);
+ EMACS_TIME interval;
+
+ if (poll_timer)
+ cancel_atimer (poll_timer);
+
+ EMACS_SET_SECS_USECS (interval, polling_period, 0);
+ poll_timer = start_atimer (ATIMER_CONTINUOUS, interval,
+ poll_for_input, NULL);
}
+
+ /* Let the timer's callback function poll for input
+ if this becomes zero. */
+ --poll_suppress_count;
}
#endif
}
{
#ifdef POLL_FOR_INPUT
if (read_socket_hook && !interrupt_input)
- {
- if (poll_suppress_count == 0)
- {
- polling_for_input = 0;
- alarm (0);
- }
- poll_suppress_count++;
- }
+ ++poll_suppress_count;
#endif
}
if (n > new)
new = n;
+ stop_other_atimers (poll_timer);
stop_polling ();
specbind (Qpolling_period, make_number (new));
/* Start a new alarm with the new period. */
reread = 0;
if (CONSP (Vunread_post_input_method_events))
{
- c = XCONS (Vunread_post_input_method_events)->car;
+ c = XCAR (Vunread_post_input_method_events);
Vunread_post_input_method_events
- = XCONS (Vunread_post_input_method_events)->cdr;
+ = XCDR (Vunread_post_input_method_events);
/* Undo what read_char_x_menu_prompt did when it unread
additional keys returned by Fx_popup_menu. */
if (CONSP (c)
- && (SYMBOLP (XCONS (c)->car) || INTEGERP (XCONS (c)->car))
- && NILP (XCONS (c)->cdr))
- c = XCONS (c)->car;
+ && (SYMBOLP (XCAR (c)) || INTEGERP (XCAR (c)))
+ && NILP (XCDR (c)))
+ c = XCAR (c);
reread = 1;
goto reread_first;
if (CONSP (Vunread_command_events))
{
- c = XCONS (Vunread_command_events)->car;
- Vunread_command_events = XCONS (Vunread_command_events)->cdr;
+ c = XCAR (Vunread_command_events);
+ Vunread_command_events = XCDR (Vunread_command_events);
/* Undo what read_char_x_menu_prompt did when it unread
additional keys returned by Fx_popup_menu. */
if (CONSP (c)
- && (SYMBOLP (XCONS (c)->car) || INTEGERP (XCONS (c)->car))
- && NILP (XCONS (c)->cdr))
- c = XCONS (c)->car;
+ && (SYMBOLP (XCAR (c)) || INTEGERP (XCAR (c)))
+ && NILP (XCDR (c)))
+ c = XCAR (c);
reread = 1;
goto reread_for_input_method;
if (CONSP (Vunread_input_method_events))
{
- c = XCONS (Vunread_input_method_events)->car;
- Vunread_input_method_events = XCONS (Vunread_input_method_events)->cdr;
+ c = XCAR (Vunread_input_method_events);
+ Vunread_input_method_events = XCDR (Vunread_input_method_events);
/* Undo what read_char_x_menu_prompt did when it unread
additional keys returned by Fx_popup_menu. */
if (CONSP (c)
- && (SYMBOLP (XCONS (c)->car) || INTEGERP (XCONS (c)->car))
- && NILP (XCONS (c)->cdr))
- c = XCONS (c)->car;
+ && (SYMBOLP (XCAR (c)) || INTEGERP (XCAR (c)))
+ && NILP (XCDR (c)))
+ c = XCAR (c);
reread = 1;
goto reread_for_input_method;
}
if (single_kboard)
abort ();
while (CONSP (*tailp))
- tailp = &XCONS (*tailp)->cdr;
+ tailp = &XCDR (*tailp);
if (!NILP (*tailp))
abort ();
*tailp = Fcons (c, Qnil);
&& !current_kboard->immediate_echo
&& this_command_key_count > 0
&& ! noninteractive
- && echo_keystrokes > 0
+ && (FLOATP (Vecho_keystrokes) || INTEGERP (Vecho_keystrokes))
+ && NILP (Fzerop (Vecho_keystrokes))
&& (/* No message. */
NILP (echo_area_buffer[0])
/* Or empty message. */
echo_now ();
else
{
+ int sec, usec;
+ double duration = extract_float (Vecho_keystrokes);
+ sec = (int) duration;
+ usec += (duration - sec) * 1000000;
save_getcjmp (save_jump);
restore_getcjmp (local_getcjmp);
- tem0 = sit_for (echo_keystrokes, 0, 1, 1, 0);
+ tem0 = sit_for (sec, usec, 1, 1, 0);
restore_getcjmp (save_jump);
if (EQ (tem0, Qt)
&& ! CONSP (Vunread_command_events))
if (nmaps > 0 && INTERACTIVE
&& !NILP (prev_event)
&& EVENT_HAS_PARAMETERS (prev_event)
- && !EQ (XCONS (prev_event)->car, Qmenu_bar)
- && !EQ (XCONS (prev_event)->car, Qtool_bar)
+ && !EQ (XCAR (prev_event), Qmenu_bar)
+ && !EQ (XCAR (prev_event), Qtool_bar)
/* Don't bring up a menu if we already have another event. */
&& NILP (Vunread_command_events)
&& unread_command_char < 0)
or sentinel or filter. */
if (CONSP (Vunread_command_events))
{
- c = XCONS (Vunread_command_events)->car;
- Vunread_command_events = XCONS (Vunread_command_events)->cdr;
+ c = XCAR (Vunread_command_events);
+ Vunread_command_events = XCDR (Vunread_command_events);
}
/* Read something from current KBOARD's side queue, if possible. */
{
if (!CONSP (current_kboard->kbd_queue))
abort ();
- c = XCONS (current_kboard->kbd_queue)->car;
+ c = XCAR (current_kboard->kbd_queue);
current_kboard->kbd_queue
- = XCONS (current_kboard->kbd_queue)->cdr;
+ = XCDR (current_kboard->kbd_queue);
if (NILP (current_kboard->kbd_queue))
current_kboard->kbd_queue_has_data = 0;
input_pending = readable_events (0);
if (EVENT_HAS_PARAMETERS (c)
&& EQ (EVENT_HEAD_KIND (EVENT_HEAD (c)), Qswitch_frame))
- internal_last_event_frame = XCONS (XCONS (c)->cdr)->car;
+ internal_last_event_frame = XCAR (XCDR (c));
Vlast_event_frame = internal_last_event_frame;
}
}
{
Lisp_Object *tailp = &kb->kbd_queue;
while (CONSP (*tailp))
- tailp = &XCONS (*tailp)->cdr;
+ tailp = &XCDR (*tailp);
if (!NILP (*tailp))
abort ();
*tailp = Fcons (c, Qnil);
return just menu-bar for now. Modify the mouse click event
so we won't do this twice, then queue it up. */
if (EVENT_HAS_PARAMETERS (c)
- && CONSP (XCONS (c)->cdr)
+ && CONSP (XCDR (c))
&& CONSP (EVENT_START (c))
- && CONSP (XCONS (EVENT_START (c))->cdr))
+ && CONSP (XCDR (EVENT_START (c))))
{
Lisp_Object posn;
goto retry;
}
/* It returned one event or more. */
- c = XCONS (tem)->car;
+ c = XCAR (tem);
Vunread_post_input_method_events
- = nconc2 (XCONS (tem)->cdr, Vunread_post_input_method_events);
+ = nconc2 (XCDR (tem), Vunread_post_input_method_events);
}
reread_first:
before_command_echo_length = echo_length ();
/* Don't echo mouse motion events. */
- if (echo_keystrokes
+ if ((FLOATP (Vecho_keystrokes) || INTEGERP (Vecho_keystrokes))
+ && NILP (Fzerop (Vecho_keystrokes))
&& ! (EVENT_HAS_PARAMETERS (c)
&& EQ (EVENT_HEAD_KIND (EVENT_HEAD (c)), Qmouse_movement)))
{
before_command_echo_length = echo_length ();
/* Don't echo mouse motion events. */
- if (echo_keystrokes)
+ if ((FLOATP (Vecho_keystrokes) || INTEGERP (Vecho_keystrokes))
+ && NILP (Fzerop (Vecho_keystrokes)))
{
echo_char (c);
if (EQ (c, Vhelp_char))
return 1;
- for (tail = Vhelp_event_list; CONSP (tail); tail = XCONS (tail)->cdr)
- if (EQ (c, XCONS (tail)->car))
+ for (tail = Vhelp_event_list; CONSP (tail); tail = XCDR (tail))
+ if (EQ (c, XCAR (tail)))
return 1;
return 0;
}
Lisp_Object frame;
frame = event->frame_or_window;
if (CONSP (frame))
- frame = XCONS (frame)->car;
+ frame = XCAR (frame);
else if (WINDOWP (frame))
frame = WINDOW_FRAME (XWINDOW (frame));
if (CONSP (Vunread_command_events))
{
Lisp_Object first;
- first = XCONS (Vunread_command_events)->car;
- Vunread_command_events = XCONS (Vunread_command_events)->cdr;
+ first = XCAR (Vunread_command_events);
+ Vunread_command_events = XCDR (Vunread_command_events);
*kbp = current_kboard;
return first;
}
frame = event->frame_or_window;
if (CONSP (frame))
- frame = XCONS (frame)->car;
+ frame = XCAR (frame);
else if (WINDOWP (frame))
frame = WINDOW_FRAME (XWINDOW (frame));
that as the `event with parameters' for this selection. */
if ((event->kind == menu_bar_event
|| event->kind == TOOL_BAR_EVENT)
- && !(CONSP (obj) && EQ (XCONS (obj)->car, Qmenu_bar))
- && !(CONSP (obj) && EQ (XCONS (obj)->car, Qtool_bar))
+ && !(CONSP (obj) && EQ (XCAR (obj), Qmenu_bar))
+ && !(CONSP (obj) && EQ (XCAR (obj), Qtool_bar))
&& used_mouse_menu)
*used_mouse_menu = 1;
#endif
EMACS_GET_TIME (timer_idleness_start_time);
/* Mark all idle-time timers as once again candidates for running. */
- for (timers = Vtimer_idle_list; CONSP (timers); timers = XCONS (timers)->cdr)
+ for (timers = Vtimer_idle_list; CONSP (timers); timers = XCDR (timers))
{
Lisp_Object timer;
- timer = XCONS (timers)->car;
+ timer = XCAR (timers);
if (!VECTORP (timer) || XVECTOR (timer)->size != 8)
continue;
/* Skip past invalid timers and timers already handled. */
if (!NILP (timers))
{
- timer = XCONS (timers)->car;
+ timer = XCAR (timers);
if (!VECTORP (timer) || XVECTOR (timer)->size != 8)
{
- timers = XCONS (timers)->cdr;
+ timers = XCDR (timers);
continue;
}
vector = XVECTOR (timer)->contents;
|| !INTEGERP (vector[3])
|| ! NILP (vector[0]))
{
- timers = XCONS (timers)->cdr;
+ timers = XCDR (timers);
continue;
}
}
if (!NILP (idle_timers))
{
- timer = XCONS (idle_timers)->car;
+ timer = XCAR (idle_timers);
if (!VECTORP (timer) || XVECTOR (timer)->size != 8)
{
- idle_timers = XCONS (idle_timers)->cdr;
+ idle_timers = XCDR (idle_timers);
continue;
}
vector = XVECTOR (timer)->contents;
|| !INTEGERP (vector[3])
|| ! NILP (vector[0]))
{
- idle_timers = XCONS (idle_timers)->cdr;
+ idle_timers = XCDR (idle_timers);
continue;
}
}
this timer becomes ripe (negative if it's already ripe). */
if (!NILP (timers))
{
- timer = XCONS (timers)->car;
+ timer = XCAR (timers);
vector = XVECTOR (timer)->contents;
EMACS_SET_SECS (timer_time,
(XINT (vector[1]) << 16) | (XINT (vector[2])));
based on the next idle timer. */
if (!NILP (idle_timers))
{
- idle_timer = XCONS (idle_timers)->car;
+ idle_timer = XCAR (idle_timers);
vector = XVECTOR (idle_timer)->contents;
EMACS_SET_SECS (idle_timer_time,
(XINT (vector[1]) << 16) | (XINT (vector[2])));
if (EMACS_TIME_NEG_P (temp))
{
chosen_timer = timer;
- timers = XCONS (timers)->cdr;
+ timers = XCDR (timers);
difference = timer_difference;
}
else
{
chosen_timer = idle_timer;
- idle_timers = XCONS (idle_timers)->cdr;
+ idle_timers = XCDR (idle_timers);
difference = idle_timer_difference;
}
}
else if (! NILP (timers))
{
chosen_timer = timer;
- timers = XCONS (timers)->cdr;
+ timers = XCDR (timers);
difference = timer_difference;
}
else
{
chosen_timer = idle_timer;
- idle_timers = XCONS (idle_timers)->cdr;
+ idle_timers = XCDR (idle_timers);
difference = idle_timer_difference;
}
vector = XVECTOR (chosen_timer)->contents;
{
int was_locked = single_kboard;
int count = specpdl_ptr - specpdl;
-#ifdef HAVE_WINDOW_SYSTEM
- int old_inhibit_busy_cursor = inhibit_busy_cursor;
-#endif
/* Mark the timer as triggered to prevent problems if the lisp
code fails to reschedule it right. */
specbind (Qinhibit_quit, Qt);
-#ifdef HAVE_WINDOW_SYSTEM
- inhibit_busy_cursor = 2;
-#endif
-
call1 (Qtimer_event_handler, chosen_timer);
timers_run++;
-#ifdef HAVE_WINDOW_SYSTEM
- inhibit_busy_cursor = old_inhibit_busy_cursor;
-#endif
-
unbind_to (count, Qnil);
/* Resume allowing input from any kboard, if that was true before. */
/* Scroll bar parts. */
Lisp_Object Qabove_handle, Qhandle, Qbelow_handle;
Lisp_Object Qup, Qdown, Qbottom, Qend_scroll;
-Lisp_Object Qtop;
+Lisp_Object Qtop, Qratio;
/* An array of scroll bar parts, indexed by an enum scroll_bar_part value. */
Lisp_Object *scroll_bar_parts[] = {
&Qabove_handle, &Qhandle, &Qbelow_handle,
- &Qup, &Qdown, &Qtop, &Qbottom, &Qend_scroll
+ &Qup, &Qdown, &Qtop, &Qbottom, &Qend_scroll, &Qratio
};
/* User signal events. */
Lisp_Object down;
down = Fnth (make_number (2), start_pos);
- if (EQ (event->x, XCONS (down)->car)
- && EQ (event->y, XCONS (down)->cdr))
+ if (EQ (event->x, XCAR (down))
+ && EQ (event->y, XCDR (down)))
{
event->modifiers |= click_modifier;
}
if (! CONSP (event->frame_or_window))
abort ();
- f = XFRAME (XCONS (event->frame_or_window)->car);
- files = XCONS (event->frame_or_window)->cdr;
+ f = XFRAME (XCAR (event->frame_or_window));
+ files = XCDR (event->frame_or_window);
/* Ignore mouse events that were made on frames that
have been deleted. */
if (!WINDOWP (window))
{
- window = XCONS (event->frame_or_window)->car;
+ window = XCAR (event->frame_or_window);
posn = Qnil;
}
else
/* The event value is in the cdr of the frame_or_window slot. */
if (!CONSP (event->frame_or_window))
abort ();
- return XCONS (event->frame_or_window)->cdr;
+ return XCDR (event->frame_or_window);
#endif
case TOOL_BAR_EVENT:
entry = assq_no_quit (index, cache);
if (CONSP (entry))
- new_symbol = XCONS (entry)->cdr;
+ new_symbol = XCDR (entry);
else
{
/* We have to create the symbol ourselves. */
Lisp_Object parsed;
parsed = parse_modifiers (symbol);
- return apply_modifiers ((int) XINT (XCONS (XCONS (parsed)->cdr)->car),
- XCONS (parsed)->car);
+ return apply_modifiers ((int) XINT (XCAR (XCDR (parsed))),
+ XCAR (parsed));
}
Lisp_Object elt;
int this = 0;
- elt = XCONS (rest)->car;
- rest = XCONS (rest)->cdr;
+ elt = XCAR (rest);
+ rest = XCDR (rest);
/* Given a symbol, see if it is a modifier name. */
if (SYMBOLP (elt) && CONSP (rest))
if (! CONSP (object))
return 0;
- for (tail = object; CONSP (tail); tail = XCONS (tail)->cdr)
+ for (tail = object; CONSP (tail); tail = XCDR (tail))
{
Lisp_Object elt;
- elt = XCONS (tail)->car;
+ elt = XCAR (tail);
if (! (INTEGERP (elt) || SYMBOLP (elt)))
return 0;
}
nmaps = current_minor_maps (NULL, &tmaps);
maps = (Lisp_Object *) alloca ((nmaps + 2) * sizeof (maps[0]));
bcopy (tmaps, maps, nmaps * sizeof (maps[0]));
-#ifdef USE_TEXT_PROPERTIES
maps[nmaps++] = get_local_map (PT, current_buffer);
-#else
- maps[nmaps++] = current_buffer->keymap;
-#endif
}
maps[nmaps++] = current_global_map;
}
/* Move to the end those items that should be at the end. */
- for (tail = Vmenu_bar_final_items; CONSP (tail); tail = XCONS (tail)->cdr)
+ for (tail = Vmenu_bar_final_items; CONSP (tail); tail = XCDR (tail))
{
int i;
int end = menu_bar_items_index;
for (i = 0; i < end; i += 4)
- if (EQ (XCONS (tail)->car, XVECTOR (menu_bar_items_vector)->contents[i]))
+ if (EQ (XCAR (tail), XVECTOR (menu_bar_items_vector)->contents[i]))
{
Lisp_Object tem0, tem1, tem2, tem3;
/* Move the item at index I to the end,
menu_bar_one_keymap_changed_items = Qnil;
/* Loop over all keymap entries that have menu strings. */
- for (tail = keymap; CONSP (tail); tail = XCONS (tail)->cdr)
+ for (tail = keymap; CONSP (tail); tail = XCDR (tail))
{
- item = XCONS (tail)->car;
+ item = XCAR (tail);
if (CONSP (item))
- menu_bar_item (XCONS (item)->car, XCONS (item)->cdr);
+ menu_bar_item (XCAR (item), XCDR (item));
else if (VECTORP (item))
{
/* Loop over the char values represented in the vector. */
{
/* If we got a quit from within the menu computation,
quit all the way out of it. This takes care of C-] in the debugger. */
- if (CONSP (arg) && EQ (XCONS (arg)->car, Qquit))
+ if (CONSP (arg) && EQ (XCAR (arg), Qquit))
Fsignal (Qquit, Qnil);
return Qnil;
/* Save the item here to protect it from GC. */
XVECTOR (item_properties)->contents[ITEM_PROPERTY_ITEM] = item;
- item_string = XCONS (item)->car;
+ item_string = XCAR (item);
start = item;
- item = XCONS (item)->cdr;
+ item = XCDR (item);
if (STRINGP (item_string))
{
/* Old format menu item. */
XVECTOR (item_properties)->contents[ITEM_PROPERTY_NAME] = item_string;
/* Maybe help string. */
- if (CONSP (item) && STRINGP (XCONS (item)->car))
+ if (CONSP (item) && STRINGP (XCAR (item)))
{
XVECTOR (item_properties)->contents[ITEM_PROPERTY_HELP]
- = XCONS (item)->car;
+ = XCAR (item);
start = item;
- item = XCONS (item)->cdr;
+ item = XCDR (item);
}
/* Maybee key binding cache. */
- if (CONSP (item) && CONSP (XCONS (item)->car)
- && (NILP (XCONS (XCONS (item)->car)->car)
- || VECTORP (XCONS (XCONS (item)->car)->car)))
+ if (CONSP (item) && CONSP (XCAR (item))
+ && (NILP (XCAR (XCAR (item)))
+ || VECTORP (XCAR (XCAR (item)))))
{
- cachelist = XCONS (item)->car;
- item = XCONS (item)->cdr;
+ cachelist = XCAR (item);
+ item = XCDR (item);
}
/* This is the real definition--the function to run. */
{
/* New format menu item. */
XVECTOR (item_properties)->contents[ITEM_PROPERTY_NAME]
- = XCONS (item)->car;
- start = XCONS (item)->cdr;
+ = XCAR (item);
+ start = XCDR (item);
if (CONSP (start))
{
/* We have a real binding. */
XVECTOR (item_properties)->contents[ITEM_PROPERTY_DEF]
- = XCONS (start)->car;
+ = XCAR (start);
- item = XCONS (start)->cdr;
+ item = XCDR (start);
/* Is there a cache list with key equivalences. */
- if (CONSP (item) && CONSP (XCONS (item)->car))
+ if (CONSP (item) && CONSP (XCAR (item)))
{
- cachelist = XCONS (item)->car;
- item = XCONS (item)->cdr;
+ cachelist = XCAR (item);
+ item = XCDR (item);
}
/* Parse properties. */
- while (CONSP (item) && CONSP (XCONS (item)->cdr))
+ while (CONSP (item) && CONSP (XCDR (item)))
{
- tem = XCONS (item)->car;
- item = XCONS (item)->cdr;
+ tem = XCAR (item);
+ item = XCDR (item);
if (EQ (tem, QCenable))
XVECTOR (item_properties)->contents[ITEM_PROPERTY_ENABLE]
- = XCONS (item)->car;
+ = XCAR (item);
else if (EQ (tem, QCvisible) && !notreal)
{
/* If got a visible property and that evaluates to nil
then ignore this item. */
- tem = menu_item_eval_property (XCONS (item)->car);
+ tem = menu_item_eval_property (XCAR (item));
if (NILP (tem))
return 0;
}
else if (EQ (tem, QChelp))
XVECTOR (item_properties)->contents[ITEM_PROPERTY_HELP]
- = XCONS (item)->car;
+ = XCAR (item);
else if (EQ (tem, QCfilter))
filter = item;
else if (EQ (tem, QCkey_sequence))
{
- tem = XCONS (item)->car;
+ tem = XCAR (item);
if (NILP (cachelist)
&& (SYMBOLP (tem) || STRINGP (tem) || VECTORP (tem)))
/* Be GC protected. Set keyhint to item instead of tem. */
}
else if (EQ (tem, QCkeys))
{
- tem = XCONS (item)->car;
+ tem = XCAR (item);
if (CONSP (tem) || (STRINGP (tem) && NILP (cachelist)))
XVECTOR (item_properties)->contents[ITEM_PROPERTY_KEYEQ]
= tem;
}
- else if (EQ (tem, QCbutton) && CONSP (XCONS (item)->car))
+ else if (EQ (tem, QCbutton) && CONSP (XCAR (item)))
{
Lisp_Object type;
- tem = XCONS (item)->car;
- type = XCONS (tem)->car;
+ tem = XCAR (item);
+ type = XCAR (tem);
if (EQ (type, QCtoggle) || EQ (type, QCradio))
{
XVECTOR (item_properties)->contents[ITEM_PROPERTY_SELECTED]
- = XCONS (tem)->cdr;
+ = XCDR (tem);
XVECTOR (item_properties)->contents[ITEM_PROPERTY_TYPE]
= type;
}
}
- item = XCONS (item)->cdr;
+ item = XCDR (item);
}
}
else if (inmenubar || !NILP (start))
def = XVECTOR (item_properties)->contents[ITEM_PROPERTY_DEF];
if (!NILP (filter))
{
- def = menu_item_eval_property (list2 (XCONS (filter)->car,
+ def = menu_item_eval_property (list2 (XCAR (filter),
list2 (Qquote, def)));
XVECTOR (item_properties)->contents[ITEM_PROPERTY_DEF] = def;
{
/* We have to create a cachelist. */
CHECK_IMPURE (start);
- XCONS (start)->cdr = Fcons (Fcons (Qnil, Qnil), XCONS (start)->cdr);
- cachelist = XCONS (XCONS (start)->cdr)->car;
+ XCDR (start) = Fcons (Fcons (Qnil, Qnil), XCDR (start));
+ cachelist = XCAR (XCDR (start));
newcache = 1;
tem = XVECTOR (item_properties)->contents[ITEM_PROPERTY_KEYEQ];
if (!NILP (keyhint))
{
- XCONS (cachelist)->car = XCONS (keyhint)->car;
+ XCAR (cachelist) = XCAR (keyhint);
newcache = 0;
}
else if (STRINGP (tem))
{
- XCONS (cachelist)->cdr = Fsubstitute_command_keys (tem);
- XCONS (cachelist)->car = Qt;
+ XCDR (cachelist) = Fsubstitute_command_keys (tem);
+ XCAR (cachelist) = Qt;
}
}
- tem = XCONS (cachelist)->car;
+ tem = XCAR (cachelist);
if (!EQ (tem, Qt))
{
int chkcache = 0;
prefix = XVECTOR (item_properties)->contents[ITEM_PROPERTY_KEYEQ];
if (CONSP (prefix))
{
- def = XCONS (prefix)->car;
- prefix = XCONS (prefix)->cdr;
+ def = XCAR (prefix);
+ prefix = XCDR (prefix);
}
else
def = XVECTOR (item_properties)->contents[ITEM_PROPERTY_DEF];
- if (NILP (XCONS (cachelist)->car)) /* Have no saved key. */
+ if (NILP (XCAR (cachelist))) /* Have no saved key. */
{
if (newcache /* Always check first time. */
/* Should we check everything when precomputing key
&& ! NILP (Fget (def, Qmenu_alias)))
def = XSYMBOL (def)->function;
tem = Fwhere_is_internal (def, Qnil, Qt, Qnil);
- XCONS (cachelist)->car = tem;
+ XCAR (cachelist) = tem;
if (NILP (tem))
{
- XCONS (cachelist)->cdr = Qnil;
+ XCDR (cachelist) = Qnil;
chkcache = 0;
}
}
- else if (!NILP (keyhint) && !NILP (XCONS (cachelist)->car))
+ else if (!NILP (keyhint) && !NILP (XCAR (cachelist)))
{
- tem = XCONS (cachelist)->car;
+ tem = XCAR (cachelist);
chkcache = 1;
}
tem = Fkey_description (tem);
if (CONSP (prefix))
{
- if (STRINGP (XCONS (prefix)->car))
- tem = concat2 (XCONS (prefix)->car, tem);
- if (STRINGP (XCONS (prefix)->cdr))
- tem = concat2 (tem, XCONS (prefix)->cdr);
+ if (STRINGP (XCAR (prefix)))
+ tem = concat2 (XCAR (prefix), tem);
+ if (STRINGP (XCDR (prefix)))
+ tem = concat2 (tem, XCDR (prefix));
}
- XCONS (cachelist)->cdr = tem;
+ XCDR (cachelist) = tem;
}
}
- tem = XCONS (cachelist)->cdr;
+ tem = XCDR (cachelist);
if (newcache && !NILP (tem))
{
tem = concat3 (build_string (" ("), tem, build_string (")"));
- XCONS (cachelist)->cdr = tem;
+ XCDR (cachelist) = tem;
}
/* If we only want to precompute equivalent key bindings, stop here. */
nmaps = current_minor_maps (NULL, &tmaps);
maps = (Lisp_Object *) alloca ((nmaps + 2) * sizeof (maps[0]));
bcopy (tmaps, maps, nmaps * sizeof (maps[0]));
-#ifdef USE_TEXT_PROPERTIES
maps[nmaps++] = get_local_map (PT, current_buffer);
-#else
- maps[nmaps++] = current_buffer->keymap;
-#endif
}
/* Add global keymap at the end. */
Lisp_Object tail;
/* KEYMAP is a list `(keymap (KEY . BINDING) ...)'. */
- for (tail = keymap; CONSP (tail); tail = XCONS (tail)->cdr)
+ for (tail = keymap; CONSP (tail); tail = XCDR (tail))
{
Lisp_Object keydef = XCAR (tail);
if (CONSP (keydef))
/* If we got to this point via a mouse click,
use a real menu for mouse selection. */
if (EVENT_HAS_PARAMETERS (prev_event)
- && !EQ (XCONS (prev_event)->car, Qmenu_bar)
- && !EQ (XCONS (prev_event)->car, Qtool_bar))
+ && !EQ (XCAR (prev_event), Qmenu_bar)
+ && !EQ (XCAR (prev_event), Qtool_bar))
{
/* Display the menu and get the selection. */
Lisp_Object *realmaps
{
Lisp_Object tem;
- record_menu_key (XCONS (value)->car);
+ record_menu_key (XCAR (value));
/* If we got multiple events, unread all but
the first.
to indicate that they came from a mouse menu,
so that when present in last_nonmenu_event
they won't confuse things. */
- for (tem = XCONS (value)->cdr; !NILP (tem);
- tem = XCONS (tem)->cdr)
+ for (tem = XCDR (value); !NILP (tem);
+ tem = XCDR (tem))
{
- record_menu_key (XCONS (tem)->car);
- if (SYMBOLP (XCONS (tem)->car)
- || INTEGERP (XCONS (tem)->car))
- XCONS (tem)->car
- = Fcons (XCONS (tem)->car, Qnil);
+ record_menu_key (XCAR (tem));
+ if (SYMBOLP (XCAR (tem))
+ || INTEGERP (XCAR (tem)))
+ XCAR (tem)
+ = Fcons (XCAR (tem), Qnil);
}
/* If we got more than one event, put all but the first
onto this list to be read later.
Return just the first event now. */
Vunread_command_events
- = nconc2 (XCONS (value)->cdr, Vunread_command_events);
- value = XCONS (value)->car;
+ = nconc2 (XCDR (value), Vunread_command_events);
+ value = XCAR (value);
}
else if (NILP (value))
value = Qt;
{
if (!NILP (prompt))
echo_prompt (XSTRING (prompt)->data);
- else if (cursor_in_echo_area && echo_keystrokes)
+ else if (cursor_in_echo_area
+ && (FLOATP (Vecho_keystrokes) || INTEGERP (Vecho_keystrokes))
+ && NILP (Fzerop (Vecho_keystrokes)))
/* This doesn't put in a dash if the echo buffer is empty, so
you don't always see a dash hanging out in the minibuffer. */
echo_dash ();
nmaps_allocated = nmaps + 2;
}
bcopy (maps, submaps, nmaps * sizeof (submaps[0]));
-#ifdef USE_TEXT_PROPERTIES
submaps[nmaps++] = orig_local_map;
-#else
- submaps[nmaps++] = current_buffer->keymap;
-#endif
}
submaps[nmaps++] = current_global_map;
}
{
key = keybuf[t];
add_command_key (key);
- if (echo_keystrokes)
+ if ((FLOATP (Vecho_keystrokes) || INTEGERP (Vecho_keystrokes))
+ && NILP (Fzerop (Vecho_keystrokes)))
echo_char (key);
}
/* If the side queue is non-empty, ensure it begins with a
switch-frame, so we'll replay it in the right context. */
if (CONSP (interrupted_kboard->kbd_queue)
- && (key = XCONS (interrupted_kboard->kbd_queue)->car,
+ && (key = XCAR (interrupted_kboard->kbd_queue),
!(EVENT_HAS_PARAMETERS (key)
&& EQ (EVENT_HEAD_KIND (EVENT_HEAD (key)),
Qswitch_frame))))
/* For a mouse click, get the local text-property keymap
of the place clicked on, rather than point. */
if (last_real_key_start == 0
- && CONSP (XCONS (key)->cdr)
+ && CONSP (XCDR (key))
&& ! localized_local_map)
{
Lisp_Object map_here, start, pos;
localized_local_map = 1;
start = EVENT_START (key);
- if (CONSP (start) && CONSP (XCONS (start)->cdr))
+ if (CONSP (start) && CONSP (XCDR (start)))
{
pos = POSN_BUFFER_POSN (start);
if (INTEGERP (pos)
goto replay_key;
}
}
- else if (CONSP (XCONS (key)->cdr)
+ else if (CONSP (XCDR (key))
&& CONSP (EVENT_START (key))
- && CONSP (XCONS (EVENT_START (key))->cdr))
+ && CONSP (XCDR (EVENT_START (key))))
{
Lisp_Object posn;
int modifiers;
breakdown = parse_modifiers (head);
- modifiers = XINT (XCONS (XCONS (breakdown)->cdr)->car);
+ modifiers = XINT (XCAR (XCDR (breakdown)));
/* Attempt to reduce an unbound mouse event to a simpler
event that is bound:
Drags reduce to clicks.
}
new_head
- = apply_modifiers (modifiers, XCONS (breakdown)->car);
+ = apply_modifiers (modifiers, XCAR (breakdown));
new_click
= Fcons (new_head, Fcons (EVENT_START (key), Qnil));
/* Handle symbol with autoload definition. */
if (SYMBOLP (fkey_next) && ! NILP (Ffboundp (fkey_next))
&& CONSP (XSYMBOL (fkey_next)->function)
- && EQ (XCONS (XSYMBOL (fkey_next)->function)->car, Qautoload))
+ && EQ (XCAR (XSYMBOL (fkey_next)->function), Qautoload))
do_autoload (XSYMBOL (fkey_next)->function,
fkey_next);
/* Handle symbol with autoload definition. */
if (SYMBOLP (keytran_next) && ! NILP (Ffboundp (keytran_next))
&& CONSP (XSYMBOL (keytran_next)->function)
- && EQ (XCONS (XSYMBOL (keytran_next)->function)->car, Qautoload))
+ && EQ (XCAR (XSYMBOL (keytran_next)->function), Qautoload))
do_autoload (XSYMBOL (keytran_next)->function,
keytran_next);
int modifiers;
breakdown = parse_modifiers (key);
- modifiers = XINT (XCONS (XCONS (breakdown)->cdr)->car);
+ modifiers = XINT (XCAR (XCDR (breakdown)));
if (modifiers & shift_modifier)
{
Lisp_Object new_key;
modifiers &= ~shift_modifier;
new_key = apply_modifiers (modifiers,
- XCONS (breakdown)->car);
+ XCAR (breakdown));
keybuf[t - 1] = new_key;
mock_input = t;
Better ideas? */
for (; t < mock_input; t++)
{
- if (echo_keystrokes)
+ if ((FLOATP (Vecho_keystrokes) || INTEGERP (Vecho_keystrokes))
+ && NILP (Fzerop (Vecho_keystrokes)))
echo_char (keybuf[t]);
add_command_key (keybuf[t]);
}
this_single_command_key_start = 0;
}
+#ifdef HAVE_X_WINDOWS
+ if (display_busy_cursor_p)
+ cancel_busy_cursor ();
+#endif
+
i = read_key_sequence (keybuf, (sizeof keybuf/sizeof (keybuf[0])),
prompt, ! NILP (dont_downcase_last),
! NILP (can_return_switch_frame), 0);
+#ifdef HAVE_X_WINDOWS
+ if (display_busy_cursor_p)
+ start_busy_cursor ();
+#endif
+
if (i == -1)
{
Vquit_flag = Qt;
this_single_command_key_start = 0;
}
+#ifdef HAVE_X_WINDOWS
+ if (display_busy_cursor_p)
+ cancel_busy_cursor ();
+#endif
+
i = read_key_sequence (keybuf, (sizeof keybuf/sizeof (keybuf[0])),
prompt, ! NILP (dont_downcase_last),
! NILP (can_return_switch_frame), 0);
+#ifdef HAVE_X_WINDOWS
+ if (display_busy_cursor_p)
+ start_busy_cursor ();
+#endif
+
if (i == -1)
{
Vquit_flag = Qt;
{
tem = Fnthcdr (Vhistory_length, Vcommand_history);
if (CONSP (tem))
- XCONS (tem)->cdr = Qnil;
+ XCDR (tem) = Qnil;
}
}
if (EQ (prefixarg, Qminus))
strcpy (buf, "- ");
- else if (CONSP (prefixarg) && XINT (XCONS (prefixarg)->car) == 4)
+ else if (CONSP (prefixarg) && XINT (XCAR (prefixarg)) == 4)
strcpy (buf, "C-u ");
- else if (CONSP (prefixarg) && INTEGERP (XCONS (prefixarg)->car))
+ else if (CONSP (prefixarg) && INTEGERP (XCAR (prefixarg)))
{
if (sizeof (int) == sizeof (EMACS_INT))
- sprintf (buf, "%d ", XINT (XCONS (prefixarg)->car));
+ sprintf (buf, "%d ", XINT (XCAR (prefixarg)));
else if (sizeof (long) == sizeof (EMACS_INT))
- sprintf (buf, "%ld ", (long) XINT (XCONS (prefixarg)->car));
+ sprintf (buf, "%ld ", (long) XINT (XCAR (prefixarg)));
else
abort ();
}
nmaps = current_minor_maps (NULL, &tmaps);
maps = (Lisp_Object *) xmalloc ((nmaps + 2) * sizeof (maps[0]));
bcopy (tmaps, maps, nmaps * sizeof (maps[0]));
-#ifdef USE_TEXT_PROPERTIES
maps[nmaps++] = get_local_map (PT, current_buffer);
-#else
- maps[nmaps++] = current_buffer->keymap;
-#endif
}
maps[nmaps++] = current_global_map;
DEFUN ("clear-this-command-keys", Fclear_this_command_keys,
Sclear_this_command_keys, 0, 0, 0,
- "Clear out the vector that `this-command-keys' returns.")
+ "Clear out the vector that `this-command-keys' returns.\n\
+Clear vector containing last 100 events.")
()
{
+ int i;
+
this_command_key_count = 0;
+
+ for (i = 0; i < XVECTOR (recent_keys)->size; ++i)
+ XVECTOR (recent_keys)->contents[i] = Qnil;
+ total_keys = 0;
+ recent_keys_index = 0;
return Qnil;
}
staticpro (&Qbottom);
Qend_scroll = intern ("end-scroll");
staticpro (&Qend_scroll);
+ Qratio = intern ("ratio");
+ staticpro (&Qratio);
Qevent_kind = intern ("event-kind");
staticpro (&Qevent_kind);
Emacs also does a garbage collection if that seems to be warranted.");
XSETFASTINT (Vauto_save_timeout, 30);
- DEFVAR_INT ("echo-keystrokes", &echo_keystrokes,
- "*Nonzero means echo unfinished commands after this many seconds of pause.");
- echo_keystrokes = 1;
+ DEFVAR_LISP ("echo-keystrokes", &Vecho_keystrokes,
+ "*Nonzero means echo unfinished commands after this many seconds of pause.\n\
+The value may be integer or floating point.");
+ Vecho_keystrokes = make_number (1);
DEFVAR_INT ("polling-period", &polling_period,
"*Interval between polling for input during Lisp execution.\n\
"If non-nil, the function that implements the display of help.\n\
It's called with one argument, the help string to display.");
Vshow_help_function = Qnil;
+
+ DEFVAR_LISP ("disable-point-adjustment", &Vdisable_point_adjustment,
+ "If non-nil, suppress point adjustment after executing a command.\n\
+\n\
+After a command is executed, if point is moved into a region that has\n\
+special properties (e.g. composition, display), we adjust point to\n\
+the boundary of the region. But, several special commands sets this\n\
+variable to non-nil, then we suppress the point adjustment.\n\
+\n\
+This variable is set to nil before reading a command, and is checked\n\
+just after executing the command");
+ Vdisable_point_adjustment = Qnil;
+
+ DEFVAR_LISP ("global-disable-point-adjustment",
+ &Vglobal_disable_point_adjustment,
+ "*If non-nil, always suppress point adjustment.\n\
+\n\
+The default value is nil, in which case, point adjustment are\n\
+suppressed only after special commands that set\n\
+`disable-point-adjustment' (which see) to non-nil.");
+ Vglobal_disable_point_adjustment = Qnil;
}
void