ASCII character. */
int quit_char;
-extern Lisp_Object current_global_map;
-extern int minibuf_level;
-
/* If non-nil, this is a map that overrides all other local maps. */
Lisp_Object Voverriding_local_map;
X Windows wants this for selection ownership. */
unsigned long last_event_timestamp;
+/* If non-nil, active regions automatically become the window selection. */
+Lisp_Object Vselect_active_regions;
+
+/* The text in the active region prior to modifying the buffer.
+ Used by the `select-active-regions' feature. */
+Lisp_Object Vsaved_region_selection;
+
+Lisp_Object Qx_set_selection, QPRIMARY, Qhandle_switch_frame;
+
Lisp_Object Qself_insert_command;
Lisp_Object Qforward_char;
Lisp_Object Qbackward_char;
Lisp_Object Qselect_window;
Lisp_Object Qhelp_echo;
-extern Lisp_Object Qremap;
-
#if defined (HAVE_MOUSE) || defined (HAVE_GPM)
Lisp_Object Qmouse_fixup_help_message;
#endif
Lisp_Object Qmenu_enable;
Lisp_Object QCenable, QCvisible, QChelp, QCfilter, QCkeys, QCkey_sequence;
Lisp_Object QCbutton, QCtoggle, QCradio, QClabel;
-extern Lisp_Object Qmenu_item;
/* An event header symbol HEAD may have a property named
Qevent_symbol_element_mask, which is of the form (BASE MODIFIERS);
Lisp_Object Qvertical_line;
Lisp_Object Qvertical_scroll_bar;
Lisp_Object Qmenu_bar;
-extern Lisp_Object Qleft_margin, Qright_margin;
-extern Lisp_Object Qleft_fringe, Qright_fringe;
-extern Lisp_Object QCmap;
Lisp_Object recursive_edit_unwind (Lisp_Object buffer), command_loop (void);
Lisp_Object Fthis_command_keys (void);
Lisp_Object Qextended_command_history;
EMACS_TIME timer_check (int do_it_now);
-extern Lisp_Object Vhistory_length, Vtranslation_table_for_input;
-
static void record_menu_key (Lisp_Object c);
static int echo_length (void);
/* Incremented whenever a timer is run. */
int timers_run;
-extern Lisp_Object Vprint_level, Vprint_length;
-
/* Address (if not 0) of EMACS_TIME to zero out if a SIGIO interrupt
happens. */
EMACS_TIME *input_available_clear_time;
unsigned long);
#endif
static Lisp_Object modify_event_symbol (int, unsigned, Lisp_Object,
- Lisp_Object, char **,
+ Lisp_Object, const char **,
Lisp_Object *, unsigned);
static Lisp_Object make_lispy_switch_frame (Lisp_Object);
static void save_getcjmp (jmp_buf);
to support it. */
static int cannot_suspend;
-extern Lisp_Object Qidentity, Qonly;
\f
/* Install the string STR as the beginning of the string of echoing,
so that it serves as a prompt for the next character.
while (INPUT_BLOCKED_P)
UNBLOCK_INPUT;
- return Fthrow (Qtop_level, Qnil);
+ Fthrow (Qtop_level, Qnil);
}
DEFUN ("exit-recursive-edit", Fexit_recursive_edit, Sexit_recursive_edit, 0, 0, "",
Fthrow (Qexit, Qnil);
error ("No recursive edit is in progress");
- return Qnil;
}
DEFUN ("abort-recursive-edit", Fabort_recursive_edit, Sabort_recursive_edit, 0, 0, "",
Fthrow (Qexit, Qt);
error ("No recursive edit is in progress");
- return Qnil;
}
\f
#if defined (HAVE_MOUSE) || defined (HAVE_GPM)
}
#endif
+/* FIXME: This is wrong rather than test window-system, we should call
+ a new set-selection, which will then dispatch to x-set-selection, or
+ tty-set-selection, or w32-set-selection, ... */
+EXFUN (Fwindow_system, 1);
+
Lisp_Object
command_loop_1 (void)
{
Vtransient_mark_mode = Qidentity;
if (!NILP (Vdeactivate_mark))
+ /* If `select-active-regions' is non-nil, this call to
+ `deactivate-mark' also sets the PRIMARY selection. */
call0 (Qdeactivate_mark);
- else if (current_buffer != prev_buffer || MODIFF != prev_modiff)
- call1 (Vrun_hooks, intern ("activate-mark-hook"));
+ else
+ {
+ /* Even if not deactivating the mark, set PRIMARY if
+ `select-active-regions' is non-nil. */
+ if (!NILP (Fwindow_system (Qnil))
+ && (EQ (Vselect_active_regions, Qonly)
+ ? EQ (CAR_SAFE (Vtransient_mark_mode), Qonly)
+ : (!NILP (Vselect_active_regions)
+ && !NILP (Vtransient_mark_mode)))
+ && !EQ (Vthis_command, Qhandle_switch_frame))
+ {
+ EMACS_INT beg =
+ XINT (Fmarker_position (current_buffer->mark));
+ EMACS_INT end = PT;
+ if (beg < end)
+ call2 (Qx_set_selection, QPRIMARY,
+ make_buffer_string (beg, end, 0));
+ else if (beg > end)
+ call2 (Qx_set_selection, QPRIMARY,
+ make_buffer_string (end, beg, 0));
+ /* Don't set empty selections. */
+ }
+
+ if (current_buffer != prev_buffer || MODIFF != prev_modiff)
+ call1 (Vrun_hooks, intern ("activate-mark-hook"));
+ }
+
+ Vsaved_region_selection = Qnil;
}
finalize:
}
}
-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', `display' and `invisible' properties.
LAST_PT is the last position of point. */
-extern Lisp_Object Qafter_string, Qbefore_string;
-extern Lisp_Object get_pos_property (Lisp_Object, Lisp_Object, Lisp_Object);
-
static void
adjust_point_for_property (int last_pt, int modified)
{
...). Each element has the form (FUN . ARGS). */
Lisp_Object pending_funcalls;
-extern Lisp_Object Qapply;
-
/* Check whether a timer has fired. To prevent larger problems we simply
disregard elements that are not proper timers. Do not make a circular
timer list for the time being.
/* This is a list of Lisp names for special "accent" characters.
It parallels lispy_accent_codes. */
-static char *lispy_accent_keys[] =
+static const char *lispy_accent_keys[] =
{
"dead-circumflex",
"dead-grave",
#ifdef HAVE_NTGUI
#define FUNCTION_KEY_OFFSET 0x0
-char *lispy_function_keys[] =
+char const *lispy_function_keys[] =
{
0, /* 0 */
0, /* VK_OEM_102 0xE2 */
"ico-help", /* VK_ICO_HELP 0xE3 */
"ico-00", /* VK_ICO_00 0xE4 */
- 0, /* VK_PROCESSKEY 0xE5 */
+ 0, /* VK_PROCESSKEY 0xE5 - used by IME */
"ico-clear", /* VK_ICO_CLEAR 0xE6 */
- "packet", /* VK_PACKET 0xE7 */
+ 0, /* VK_PACKET 0xE7 - used to pass unicode chars */
0, /* 0xE8 */
"reset", /* VK_OEM_RESET 0xE9 */
"jump", /* VK_OEM_JUMP 0xEA */
/* Some of these duplicate the "Media keys" on newer keyboards,
but they are delivered to the application in a different way. */
-static char *lispy_multimedia_keys[] =
+static const char *lispy_multimedia_keys[] =
{
0,
"browser-back",
the XK_kana_A case below. */
#if 0
#ifdef XK_kana_A
-static char *lispy_kana_keys[] =
+static const char *lispy_kana_keys[] =
{
/* X Keysym value */
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x400 .. 0x40f */
/* You'll notice that this table is arranged to be conveniently
indexed by X Windows keysym values. */
-static char *lispy_function_keys[] =
+static const char *lispy_function_keys[] =
{
/* X Keysym value */
/* ISO 9995 Function and Modifier Keys; the first byte is 0xFE. */
#define ISO_FUNCTION_KEY_OFFSET 0xfe00
-static char *iso_lispy_function_keys[] =
+static const char *iso_lispy_function_keys[] =
{
0, 0, 0, 0, 0, 0, 0, 0, /* 0xfe00 */
0, 0, 0, 0, 0, 0, 0, 0, /* 0xfe08 */
Lisp_Object Vlispy_mouse_stem;
-static char *lispy_wheel_names[] =
+static const char *lispy_wheel_names[] =
{
"wheel-up", "wheel-down", "wheel-left", "wheel-right"
};
/* drag-n-drop events are generated when a set of selected files are
dragged from another application and dropped onto an Emacs window. */
-static char *lispy_drag_n_drop_names[] =
+static const char *lispy_drag_n_drop_names[] =
{
"drag-n-drop"
};
Lisp_Object Qtop, Qratio;
/* An array of scroll bar parts, indexed by an enum scroll_bar_part value. */
-Lisp_Object *scroll_bar_parts[] = {
+const Lisp_Object *scroll_bar_parts[] = {
&Qabove_handle, &Qhandle, &Qbelow_handle,
&Qup, &Qdown, &Qtop, &Qbottom, &Qend_scroll, &Qratio
};
static Lisp_Object
modify_event_symbol (int symbol_num, unsigned int modifiers, Lisp_Object symbol_kind,
- Lisp_Object name_alist_or_stem, char **name_table,
+ Lisp_Object name_alist_or_stem, const char **name_table,
Lisp_Object *symbol_table, unsigned int table_size)
{
Lisp_Object value;
static int ntool_bar_items;
-/* The symbols `tool-bar', `:image' and `:rtl'. */
+/* The symbols `:image' and `:rtl'. */
-extern Lisp_Object Qtool_bar;
Lisp_Object QCimage;
Lisp_Object Qrtl;
process_tool_bar_item (Lisp_Object key, Lisp_Object def, Lisp_Object data, void *args)
{
int i;
- extern Lisp_Object Qundefined;
struct gcpro gcpro1, gcpro2;
/* Protect KEY and DEF from GC because parse_tool_bar_item may call
return 0;
}
else if (EQ (key, QChelp))
- /* `:help HELP-STRING'. */
- PROP (TOOL_BAR_ITEM_HELP) = value;
+ /* `:help HELP-STRING'. */
+ PROP (TOOL_BAR_ITEM_HELP) = value;
else if (EQ (key, QClabel))
{
+ const char *bad_label = "!!?GARBLED ITEM?!!";
/* `:label LABEL-STRING'. */
- PROP (TOOL_BAR_ITEM_LABEL) = value;
+ PROP (TOOL_BAR_ITEM_LABEL) = STRINGP (value)
+ ? value
+ : make_string (bad_label, strlen (bad_label));
have_label = 1;
}
else if (EQ (key, QCfilter))
/* Try to make one from caption and key. */
Lisp_Object key = PROP (TOOL_BAR_ITEM_KEY);
Lisp_Object capt = PROP (TOOL_BAR_ITEM_CAPTION);
- char *label = SYMBOLP (key) ? (char *) SDATA (SYMBOL_NAME (key)) : "";
- char *caption = STRINGP (capt) ? (char *) SDATA (capt) : "";
- char buf[64];
- EMACS_INT max_lbl = 2*tool_bar_max_label_size;
+ const char *label = SYMBOLP (key) ? (char *) SDATA (SYMBOL_NAME (key)) : "";
+ const char *caption = STRINGP (capt) ? (char *) SDATA (capt) : "";
+ EMACS_INT max_lbl = 2 * tool_bar_max_label_size;
+ char *buf = (char *) xmalloc (max_lbl + 1);
Lisp_Object new_lbl;
+ size_t caption_len = strlen (caption);
- if (strlen (caption) < max_lbl && caption[0] != '\0')
+ if (caption_len <= max_lbl && caption[0] != '\0')
{
strcpy (buf, caption);
- while (buf[0] != '\0' && buf[strlen (buf) -1] == '.')
- buf[strlen (buf)-1] = '\0';
- if (strlen (buf) <= max_lbl)
- caption = buf;
+ while (caption_len > 0 && buf[caption_len - 1] == '.')
+ caption_len--;
+ buf[caption_len] = '\0';
+ label = caption = buf;
}
- if (strlen (caption) <= max_lbl)
- label = caption;
-
if (strlen (label) <= max_lbl && label[0] != '\0')
{
int i;
- if (label != buf) strcpy (buf, label);
+ if (label != buf)
+ strcpy (buf, label);
- for (i = 0; i < strlen (buf); ++i)
- {
- if (buf[i] == '-') buf[i] = ' ';
- }
+ for (i = 0; buf[i] != '\0'; ++i)
+ if (buf[i] == '-')
+ buf[i] = ' ';
label = buf;
}
- else label = "";
+ else
+ label = "";
new_lbl = Fupcase_initials (make_string (label, strlen (label)));
if (SCHARS (new_lbl) <= tool_bar_max_label_size)
PROP (TOOL_BAR_ITEM_LABEL) = new_lbl;
+ else
+ PROP (TOOL_BAR_ITEM_LABEL) = make_string ("", 0);
+ free (buf);
}
/* If got a filter apply it on binding. */
register Lisp_Object final;
register Lisp_Object tem;
Lisp_Object prefixarg;
- extern int debug_on_next_call;
debug_on_next_call = 0;
(Lisp_Object prefixarg)
{
Lisp_Object function;
- char buf[40];
int saved_last_point_position;
Lisp_Object saved_keys, saved_last_point_position_buffer;
Lisp_Object bindings, value;
struct gcpro gcpro1, gcpro2, gcpro3;
#ifdef HAVE_WINDOW_SYSTEM
- /* The call to Fcompleting_read wil start and cancel the hourglass,
+ /* The call to Fcompleting_read will start and cancel the hourglass,
but if the hourglass was already scheduled, this means that no
hourglass will be shown for the actual M-x command itself.
So we restart it if it is already scheduled. Note that checking
XVECTOR (this_command_keys)->contents);
saved_last_point_position_buffer = last_point_position_buffer;
saved_last_point_position = last_point_position;
- buf[0] = 0;
GCPRO3 (saved_keys, prefixarg, saved_last_point_position_buffer);
- if (EQ (prefixarg, Qminus))
- strcpy (buf, "- ");
- else if (CONSP (prefixarg) && XINT (XCAR (prefixarg)) == 4)
- strcpy (buf, "C-u ");
- else if (CONSP (prefixarg) && INTEGERP (XCAR (prefixarg)))
- sprintf (buf, "%ld ", (long) XINT (XCAR (prefixarg)));
- else if (INTEGERP (prefixarg))
- sprintf (buf, "%ld ", (long) XINT (prefixarg));
-
- /* This isn't strictly correct if execute-extended-command
- is bound to anything else. Perhaps it should use
- this_command_keys? */
- strcat (buf, "M-x ");
-
- /* Prompt with buf, and then read a string, completing from and
- restricting to the set of all defined commands. Don't provide
- any initial input. Save the command read on the extended-command
- history list. */
- function = Fcompleting_read (build_string (buf),
- Vobarray, Qcommandp,
- Qt, Qnil, Qextended_command_history, Qnil,
- Qnil);
+ function = call0 (intern ("read-extended-command"));
#ifdef HAVE_WINDOW_SYSTEM
if (hstarted) start_hourglass ();
Emacs on SIGINT when there are no termcap frames on the
controlling terminal. */
signal (SIGINT, interrupt_signal);
-#if defined (HAVE_TERMIO) || defined (HAVE_TERMIOS)
+#ifndef DOS_NT
/* For systems with SysV TERMIO, C-g is set up for both SIGINT and
SIGQUIT and we can't tell which one it will give us. */
signal (SIGQUIT, interrupt_signal);
-#endif /* HAVE_TERMIO */
+#endif /* not DOS_NT */
}
/* Note SIGIO has been undef'd if FIONREAD is missing. */
#ifdef SIGIO
event header symbols and put properties on them. */
struct event_head {
Lisp_Object *var;
- char *name;
+ const char *name;
Lisp_Object *kind;
};
Qinput_method_function = intern_c_string ("input-method-function");
staticpro (&Qinput_method_function);
+ Qx_set_selection = intern_c_string ("x-set-selection");
+ staticpro (&Qx_set_selection);
+ QPRIMARY = intern_c_string ("PRIMARY");
+ staticpro (&QPRIMARY);
+ Qhandle_switch_frame = intern_c_string ("handle-switch-frame");
+ staticpro (&Qhandle_switch_frame);
+
Qinput_method_exit_on_first_char = intern_c_string ("input-method-exit-on-first-char");
staticpro (&Qinput_method_exit_on_first_char);
Qinput_method_use_echo_area = intern_c_string ("input-method-use-echo-area");
and tool-bar buttons. */);
Venable_disabled_menus_and_buttons = Qnil;
+ DEFVAR_LISP ("select-active-regions",
+ &Vselect_active_regions,
+ doc: /* If non-nil, an active region automatically becomes the window selection.
+If the value is `only', only temporarily active regions (usually made
+by mouse-dragging or shift-selection) set the window selection.
+
+This takes effect only when Transient Mark mode is enabled. */);
+ Vselect_active_regions = Qt;
+
+ DEFVAR_LISP ("saved-region-selection",
+ &Vsaved_region_selection,
+ doc: /* Contents of active region prior to buffer modification.
+If `select-active-regions' is non-nil, Emacs sets this to the
+text in the region before modifying the buffer. The next
+`deactivate-mark' call uses this to set the window selection. */);
+ Vsaved_region_selection = Qnil;
+
/* Create the initial keyboard. */
initial_kboard = (KBOARD *) xmalloc (sizeof (KBOARD));
init_kboard (initial_kboard);