HCoop
/
bpt
/
emacs.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Supply malloc and alloc_size attributes for extern allocators.
[bpt/emacs.git]
/
src
/
keyboard.c
diff --git
a/src/keyboard.c
b/src/keyboard.c
index
439a40f
..
26afc02
100644
(file)
--- a/
src/keyboard.c
+++ b/
src/keyboard.c
@@
-1,7
+1,6
@@
/* Keyboard and mouse input; editor command loop.
/* Keyboard and mouse input; editor command loop.
-Copyright (C) 1985-1989, 1993-1997, 1999-2014 Free Software Foundation,
-Inc.
+Copyright (C) 1985-1989, 1993-1997, 1999-2014 Free Software Foundation, Inc.
This file is part of GNU Emacs.
This file is part of GNU Emacs.
@@
-21,6
+20,7
@@
along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include <config.h>
#include "sysstdio.h"
#include <config.h>
#include "sysstdio.h"
+#include <sys/stat.h>
#include "lisp.h"
#include "termchar.h"
#include "lisp.h"
#include "termchar.h"
@@
-228,7
+228,7
@@
static Lisp_Object Qbackward_char;
Lisp_Object Qundefined;
static Lisp_Object Qtimer_event_handler;
Lisp_Object Qundefined;
static Lisp_Object Qtimer_event_handler;
-/*
read_key_sequence
stores here the command definition of the
+/*
`read_key_sequence'
stores here the command definition of the
key sequence that it reads. */
static Lisp_Object read_key_sequence_cmd;
static Lisp_Object read_key_sequence_remapped;
key sequence that it reads. */
static Lisp_Object read_key_sequence_cmd;
static Lisp_Object read_key_sequence_remapped;
@@
-825,22
+825,25
@@
This function is called by the editor initialization to begin editing. */)
if (input_blocked_p ())
return Qnil;
if (input_blocked_p ())
return Qnil;
- command_loop_level++;
- update_mode_lines = 17;
-
- if (command_loop_level
+ if (command_loop_level >= 0
&& current_buffer != XBUFFER (XWINDOW (selected_window)->contents))
buffer = Fcurrent_buffer ();
else
buffer = Qnil;
&& current_buffer != XBUFFER (XWINDOW (selected_window)->contents))
buffer = Fcurrent_buffer ();
else
buffer = Qnil;
+ /* Don't do anything interesting between the increment and the
+ record_unwind_protect! Otherwise, we could get distracted and
+ never decrement the counter again. */
+ command_loop_level++;
+ update_mode_lines = 17;
+ record_unwind_protect (recursive_edit_unwind, buffer);
+
/* If we leave recursive_edit_1 below with a `throw' for instance,
like it is done in the splash screen display, we have to
make sure that we restore single_kboard as command_loop_1
would have done if it were left normally. */
if (command_loop_level > 0)
temporarily_switch_to_single_kboard (SELECTED_FRAME ());
/* If we leave recursive_edit_1 below with a `throw' for instance,
like it is done in the splash screen display, we have to
make sure that we restore single_kboard as command_loop_1
would have done if it were left normally. */
if (command_loop_level > 0)
temporarily_switch_to_single_kboard (SELECTED_FRAME ());
- record_unwind_protect (recursive_edit_unwind, buffer);
recursive_edit_1 ();
return unbind_to (count, Qnil);
recursive_edit_1 ();
return unbind_to (count, Qnil);
@@
-1446,7
+1449,7
@@
command_loop_1 (void)
Vthis_command_keys_shift_translated = Qnil;
/* Read next key sequence; i gets its length. */
Vthis_command_keys_shift_translated = Qnil;
/* Read next key sequence; i gets its length. */
- i = read_key_sequence (keybuf,
sizeof keybuf / sizeof keybuf[0]
,
+ i = read_key_sequence (keybuf,
ARRAYELTS (keybuf)
,
Qnil, 0, 1, 1, 0);
/* A filter may have run while we were reading the input. */
Qnil, 0, 1, 1, 0);
/* A filter may have run while we were reading the input. */
@@
-1694,7
+1697,7
@@
read_menu_command (void)
menus. */
specbind (Qecho_keystrokes, make_number (0));
menus. */
specbind (Qecho_keystrokes, make_number (0));
- i = read_key_sequence (keybuf,
sizeof keybuf / sizeof keybuf[0]
,
+ i = read_key_sequence (keybuf,
ARRAYELTS (keybuf)
,
Qnil, 0, 1, 1, 1);
unbind_to (count, Qnil);
Qnil, 0, 1, 1, 1);
unbind_to (count, Qnil);
@@
-2379,7
+2382,7
@@
read_decoded_event_from_main_queue (struct timespec *end_time,
-2 means do neither.
1 means do both. */
-2 means do neither.
1 means do both. */
-/* The argument
s MAP is for menu prompting. MAP is a keymap
.
+/* The argument
MAP is a keymap for menu prompting
.
PREV_EVENT is the previous input event, or nil if we are reading
the first event of a key sequence (or not reading a key sequence).
PREV_EVENT is the previous input event, or nil if we are reading
the first event of a key sequence (or not reading a key sequence).
@@
-5478,14
+5481,13
@@
make_lispy_event (struct input_event *event)
case NON_ASCII_KEYSTROKE_EVENT:
button_down_time = 0;
case NON_ASCII_KEYSTROKE_EVENT:
button_down_time = 0;
- for (i = 0; i <
sizeof (lispy_accent_codes) / sizeof (int
); i++)
+ for (i = 0; i <
ARRAYELTS (lispy_accent_codes
); i++)
if (event->code == lispy_accent_codes[i])
return modify_event_symbol (i,
event->modifiers,
Qfunction_key, Qnil,
lispy_accent_keys, &accent_key_syms,
if (event->code == lispy_accent_codes[i])
return modify_event_symbol (i,
event->modifiers,
Qfunction_key, Qnil,
lispy_accent_keys, &accent_key_syms,
- (sizeof (lispy_accent_keys)
- / sizeof (lispy_accent_keys[0])));
+ ARRAYELTS (lispy_accent_keys));
#if 0
#ifdef XK_kana_A
#if 0
#ifdef XK_kana_A
@@
-5494,8
+5496,7
@@
make_lispy_event (struct input_event *event)
event->modifiers & ~shift_modifier,
Qfunction_key, Qnil,
lispy_kana_keys, &func_key_syms,
event->modifiers & ~shift_modifier,
Qfunction_key, Qnil,
lispy_kana_keys, &func_key_syms,
- (sizeof (lispy_kana_keys)
- / sizeof (lispy_kana_keys[0])));
+ ARRAYELTS (lispy_kana_keys));
#endif /* XK_kana_A */
#endif /* 0 */
#endif /* XK_kana_A */
#endif /* 0 */
@@
-5506,15
+5507,14
@@
make_lispy_event (struct input_event *event)
event->modifiers,
Qfunction_key, Qnil,
iso_lispy_function_keys, &func_key_syms,
event->modifiers,
Qfunction_key, Qnil,
iso_lispy_function_keys, &func_key_syms,
- (sizeof (iso_lispy_function_keys)
- / sizeof (iso_lispy_function_keys[0])));
+ ARRAYELTS (iso_lispy_function_keys));
#endif
/* Handle system-specific or unknown keysyms. */
if (event->code & (1 << 28)
|| event->code - FUNCTION_KEY_OFFSET < 0
|| (event->code - FUNCTION_KEY_OFFSET
#endif
/* Handle system-specific or unknown keysyms. */
if (event->code & (1 << 28)
|| event->code - FUNCTION_KEY_OFFSET < 0
|| (event->code - FUNCTION_KEY_OFFSET
- >=
sizeof lispy_function_keys / sizeof *lispy_function_keys
)
+ >=
ARRAYELTS (lispy_function_keys)
)
|| !lispy_function_keys[event->code - FUNCTION_KEY_OFFSET])
{
/* We need to use an alist rather than a vector as the cache
|| !lispy_function_keys[event->code - FUNCTION_KEY_OFFSET])
{
/* We need to use an alist rather than a vector as the cache
@@
-5533,20
+5533,17
@@
make_lispy_event (struct input_event *event)
event->modifiers,
Qfunction_key, Qnil,
lispy_function_keys, &func_key_syms,
event->modifiers,
Qfunction_key, Qnil,
lispy_function_keys, &func_key_syms,
- (sizeof (lispy_function_keys)
- / sizeof (lispy_function_keys[0])));
+ ARRAYELTS (lispy_function_keys));
#ifdef HAVE_NTGUI
case MULTIMEDIA_KEY_EVENT:
#ifdef HAVE_NTGUI
case MULTIMEDIA_KEY_EVENT:
- if (event->code < (sizeof (lispy_multimedia_keys)
- / sizeof (lispy_multimedia_keys[0]))
+ if (event->code < ARRAYELTS (lispy_multimedia_keys)
&& event->code > 0 && lispy_multimedia_keys[event->code])
{
return modify_event_symbol (event->code, event->modifiers,
Qfunction_key, Qnil,
lispy_multimedia_keys, &func_key_syms,
&& event->code > 0 && lispy_multimedia_keys[event->code])
{
return modify_event_symbol (event->code, event->modifiers,
Qfunction_key, Qnil,
lispy_multimedia_keys, &func_key_syms,
- (sizeof (lispy_multimedia_keys)
- / sizeof (lispy_multimedia_keys[0])));
+ ARRAYELTS (lispy_multimedia_keys));
}
return Qnil;
#endif
}
return Qnil;
#endif
@@
-6268,7
+6265,7
@@
static const char *const modifier_names[] =
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, "alt", "super", "hyper", "shift", "control", "meta"
};
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, "alt", "super", "hyper", "shift", "control", "meta"
};
-#define NUM_MOD_NAMES
(sizeof (modifier_names) / sizeof (modifier_names[0])
)
+#define NUM_MOD_NAMES
ARRAYELTS (modifier_names
)
static Lisp_Object modifier_symbols;
static Lisp_Object modifier_symbols;
@@
-7123,7
+7120,12
@@
unblock_input_to (int level)
/* End critical section.
If doing signal-driven input, and a signal came in when input was
/* End critical section.
If doing signal-driven input, and a signal came in when input was
- blocked, reinvoke the signal handler now to deal with it. */
+ blocked, reinvoke the signal handler now to deal with it.
+
+ It will also process queued input, if it was not read before.
+ When a longer code sequence does not use block/unblock input
+ at all, the whole input gathered up to the next call to
+ unblock_input will be processed inside that call. */
void
unblock_input (void)
void
unblock_input (void)
@@
-7288,7
+7290,7
@@
store_user_signal_events (void)
}
\f
}
\f
-static void menu_bar_item (Lisp_Object, Lisp_Object, Lisp_Object, void*);
+static void menu_bar_item (Lisp_Object, Lisp_Object, Lisp_Object, void
*);
static Lisp_Object menu_bar_one_keymap_changed_items;
/* These variables hold the vector under construction within
static Lisp_Object menu_bar_one_keymap_changed_items;
/* These variables hold the vector under construction within
@@
-7298,7
+7300,7
@@
static Lisp_Object menu_bar_items_vector;
static int menu_bar_items_index;
static int menu_bar_items_index;
-static const char
*
separator_names[] = {
+static const char
*
separator_names[] = {
"space",
"no-line",
"single-line",
"space",
"no-line",
"single-line",
@@
-7906,7
+7908,8
@@
static Lisp_Object QCrtl;
/* Function prototypes. */
static void init_tool_bar_items (Lisp_Object);
/* Function prototypes. */
static void init_tool_bar_items (Lisp_Object);
-static void process_tool_bar_item (Lisp_Object, Lisp_Object, Lisp_Object, void*);
+static void process_tool_bar_item (Lisp_Object, Lisp_Object, Lisp_Object,
+ void *);
static bool parse_tool_bar_item (Lisp_Object, Lisp_Object);
static void append_tool_bar_item (void);
static bool parse_tool_bar_item (Lisp_Object, Lisp_Object);
static void append_tool_bar_item (void);
@@
-9758,7
+9761,7
@@
read_key_sequence_vs (Lisp_Object prompt, Lisp_Object continue_echo,
memset (keybuf, 0, sizeof keybuf);
GCPRO1 (keybuf[0]);
memset (keybuf, 0, sizeof keybuf);
GCPRO1 (keybuf[0]);
- gcpro1.nvars =
(sizeof keybuf / sizeof (keybuf[0])
);
+ gcpro1.nvars =
ARRAYELTS (keybuf
);
if (NILP (continue_echo))
{
if (NILP (continue_echo))
{
@@
-9772,7
+9775,7
@@
read_key_sequence_vs (Lisp_Object prompt, Lisp_Object continue_echo,
cancel_hourglass ();
#endif
cancel_hourglass ();
#endif
- i = read_key_sequence (keybuf,
(sizeof keybuf / sizeof (keybuf[0])
),
+ i = read_key_sequence (keybuf,
ARRAYELTS (keybuf
),
prompt, ! NILP (dont_downcase_last),
! NILP (can_return_switch_frame), 0, 0);
prompt, ! NILP (dont_downcase_last),
! NILP (can_return_switch_frame), 0, 0);
@@
-10073,7
+10076,10
@@
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.
If FILE is nil, close any open dribble file.
"FOpen dribble file: ",
doc: /* Start writing all keyboard characters to a dribble file called FILE.
If FILE is nil, close any open dribble file.
-The file will be closed when Emacs exits. */)
+The file will be closed when Emacs exits.
+
+Be aware that this records ALL characters you type!
+This may include sensitive information such as passwords. */)
(Lisp_Object file)
{
if (dribble)
(Lisp_Object file)
{
if (dribble)
@@
-10085,8
+10091,15
@@
The file will be closed when Emacs exits. */)
}
if (!NILP (file))
{
}
if (!NILP (file))
{
+ int fd;
+ Lisp_Object encfile;
+
file = Fexpand_file_name (file, Qnil);
file = Fexpand_file_name (file, Qnil);
- dribble = emacs_fopen (SSDATA (file), "w");
+ encfile = ENCODE_FILE (file);
+ fd = emacs_open (SSDATA (encfile), O_WRONLY | O_CREAT | O_EXCL, 0600);
+ if (fd < 0 && errno == EEXIST && unlink (SSDATA (encfile)) == 0)
+ fd = emacs_open (SSDATA (encfile), O_WRONLY | O_CREAT | O_EXCL, 0600);
+ dribble = fd < 0 ? 0 : fdopen (fd, "w");
if (dribble == 0)
report_file_error ("Opening dribble", file);
}
if (dribble == 0)
report_file_error ("Opening dribble", file);
}
@@
-10675,7
+10688,7
@@
The elements of this list correspond to the arguments of
}
XSETFASTINT (val[3], quit_char);
}
XSETFASTINT (val[3], quit_char);
- return Flist (
sizeof (val) / sizeof (val[0]
), val);
+ return Flist (
ARRAYELTS (val
), val);
}
DEFUN ("posn-at-x-y", Fposn_at_x_y, Sposn_at_x_y, 2, 4, 0,
}
DEFUN ("posn-at-x-y", Fposn_at_x_y, Sposn_at_x_y, 2, 4, 0,
@@
-11043,7
+11056,7
@@
syms_of_keyboard (void)
{
int i;
{
int i;
- int len =
sizeof (head_table) / sizeof (head_table[0]
);
+ int len =
ARRAYELTS (head_table
);
for (i = 0; i < len; i++)
{
for (i = 0; i < len; i++)
{
@@
-11059,14
+11072,13
@@
syms_of_keyboard (void)
staticpro (&button_down_location);
mouse_syms = Fmake_vector (make_number (5), Qnil);
staticpro (&mouse_syms);
staticpro (&button_down_location);
mouse_syms = Fmake_vector (make_number (5), Qnil);
staticpro (&mouse_syms);
- wheel_syms = Fmake_vector (make_number (sizeof (lispy_wheel_names)
- / sizeof (lispy_wheel_names[0])),
+ wheel_syms = Fmake_vector (make_number (ARRAYELTS (lispy_wheel_names)),
Qnil);
staticpro (&wheel_syms);
{
int i;
Qnil);
staticpro (&wheel_syms);
{
int i;
- int len =
sizeof (modifier_names) / sizeof (modifier_names[0]
);
+ int len =
ARRAYELTS (modifier_names
);
modifier_symbols = Fmake_vector (make_number (len), Qnil);
for (i = 0; i < len; i++)
modifier_symbols = Fmake_vector (make_number (len), Qnil);
for (i = 0; i < len; i++)
@@
-11385,6
+11397,7
@@
and tests the value when the command returns.
Buffer modification stores t in this variable. */);
Vdeactivate_mark = Qnil;
DEFSYM (Qdeactivate_mark, "deactivate-mark");
Buffer modification stores t in this variable. */);
Vdeactivate_mark = Qnil;
DEFSYM (Qdeactivate_mark, "deactivate-mark");
+ Fmake_variable_buffer_local (Qdeactivate_mark);
DEFVAR_LISP ("pre-command-hook", Vpre_command_hook,
doc: /* Normal hook run before each command is executed.
DEFVAR_LISP ("pre-command-hook", Vpre_command_hook,
doc: /* Normal hook run before each command is executed.