diff options
| author | Paul Eggert | 2019-03-04 00:00:39 -0800 |
|---|---|---|
| committer | Paul Eggert | 2019-03-04 00:05:04 -0800 |
| commit | 5c2563a5472cd5580e7af570aa320ac581ad1985 (patch) | |
| tree | fbf88ede49dc0ba527d3925dfc274c230b8cf95f /src/keymap.c | |
| parent | d6b3e5bbc5e14c32f3faad9f1481ec16807ac2fe (diff) | |
| download | emacs-5c2563a5472cd5580e7af570aa320ac581ad1985.tar.gz emacs-5c2563a5472cd5580e7af570aa320ac581ad1985.zip | |
Simplify list creation in C code
The main new thing here is that C code can now say
‘list (a, b, c, d, e, f)’ instead of
‘listn (CONSTYPE_HEAP, 6, a, b, c, d, e, f)’,
thus relieving callers of the responsibility of counting
arguments (plus, the code feels more like Lisp). The old
list1 ... list5 functions remain, as they’re probably a bit
faster for small lists.
* src/alloc.c (cons_listn, pure_listn): New functions.
(listn): Omit enum argument.
All callers changed to use either new ‘list’ or ‘pure_list’ macros.
* src/charset.c (Fdefine_charset_internal):
* src/coding.c (detect_coding_system)
(Fset_terminal_coding_system_internal):
* src/frame.c (frame_size_history_add, adjust_frame_size):
* src/gtkutil.c (xg_frame_set_char_size):
* src/keyboard.c (command_loop_1):
* src/nsfns.m (frame_geometry):
* src/widget.c (set_frame_size):
* src/xfaces.c (Fcolor_distance):
* src/xfns.c (frame_geometry):
* src/xterm.c (x_set_window_size_1):
* src/xwidget.c (Fxwidget_size_request):
Prefer list1i, list2i, etc. to open-coding them.
* src/charset.c (Fset_charset_priority):
* src/nsterm.m (append2):
* src/window.c (window_list):
* src/xfaces.c (Fx_list_fonts):
Use nconc2 instead of open-coding it.
* src/eval.c (eval_sub, backtrace_frame_apply):
* src/kqueue.c (kqueue_generate_event):
* src/nsterm.m (performDragOperation:):
* src/pdumper.c (Fpdumper_stats):
* src/w32.c (init_environment):
Prefer list1, list2, etc. to open-coding them.
* src/font.c (font_list_entities):
Parenthesize to avoid expanding new ‘list’ macro.
* src/gtkutil.c (GETSETUP): Rename from MAKE_FLOAT_PAGE_SETUP
to get lines to fit. Move outside the ‘list’ call, since it’s
now a macro.
* src/keymap.c (Fmake_keymap): Simplify.
* src/lisp.h (list, pure_list): New macros.
(list1i): New function.
Diffstat (limited to 'src/keymap.c')
| -rw-r--r-- | src/keymap.c | 34 |
1 files changed, 13 insertions, 21 deletions
diff --git a/src/keymap.c b/src/keymap.c index dda552ba471..2ac3d33460c 100644 --- a/src/keymap.c +++ b/src/keymap.c | |||
| @@ -120,11 +120,7 @@ The optional arg STRING supplies a menu name for the keymap | |||
| 120 | in case you use it as a menu with `x-popup-menu'. */) | 120 | in case you use it as a menu with `x-popup-menu'. */) |
| 121 | (Lisp_Object string) | 121 | (Lisp_Object string) |
| 122 | { | 122 | { |
| 123 | Lisp_Object tail; | 123 | Lisp_Object tail = !NILP (string) ? list1 (string) : Qnil; |
| 124 | if (!NILP (string)) | ||
| 125 | tail = list1 (string); | ||
| 126 | else | ||
| 127 | tail = Qnil; | ||
| 128 | return Fcons (Qkeymap, | 124 | return Fcons (Qkeymap, |
| 129 | Fcons (Fmake_char_table (Qkeymap, Qnil), tail)); | 125 | Fcons (Fmake_char_table (Qkeymap, Qnil), tail)); |
| 130 | } | 126 | } |
| @@ -3608,12 +3604,12 @@ syms_of_keymap (void) | |||
| 3608 | Fset (intern_c_string ("ctl-x-map"), control_x_map); | 3604 | Fset (intern_c_string ("ctl-x-map"), control_x_map); |
| 3609 | Ffset (intern_c_string ("Control-X-prefix"), control_x_map); | 3605 | Ffset (intern_c_string ("Control-X-prefix"), control_x_map); |
| 3610 | 3606 | ||
| 3611 | exclude_keys = listn (CONSTYPE_PURE, 5, | 3607 | exclude_keys = pure_list |
| 3612 | pure_cons (build_pure_c_string ("DEL"), build_pure_c_string ("\\d")), | 3608 | (pure_cons (build_pure_c_string ("DEL"), build_pure_c_string ("\\d")), |
| 3613 | pure_cons (build_pure_c_string ("TAB"), build_pure_c_string ("\\t")), | 3609 | pure_cons (build_pure_c_string ("TAB"), build_pure_c_string ("\\t")), |
| 3614 | pure_cons (build_pure_c_string ("RET"), build_pure_c_string ("\\r")), | 3610 | pure_cons (build_pure_c_string ("RET"), build_pure_c_string ("\\r")), |
| 3615 | pure_cons (build_pure_c_string ("ESC"), build_pure_c_string ("\\e")), | 3611 | pure_cons (build_pure_c_string ("ESC"), build_pure_c_string ("\\e")), |
| 3616 | pure_cons (build_pure_c_string ("SPC"), build_pure_c_string (" "))); | 3612 | pure_cons (build_pure_c_string ("SPC"), build_pure_c_string (" "))); |
| 3617 | staticpro (&exclude_keys); | 3613 | staticpro (&exclude_keys); |
| 3618 | 3614 | ||
| 3619 | DEFVAR_LISP ("define-key-rebound-commands", Vdefine_key_rebound_commands, | 3615 | DEFVAR_LISP ("define-key-rebound-commands", Vdefine_key_rebound_commands, |
| @@ -3669,16 +3665,12 @@ be preferred. */); | |||
| 3669 | DEFSYM (Qmode_line, "mode-line"); | 3665 | DEFSYM (Qmode_line, "mode-line"); |
| 3670 | 3666 | ||
| 3671 | staticpro (&Vmouse_events); | 3667 | staticpro (&Vmouse_events); |
| 3672 | Vmouse_events = listn (CONSTYPE_PURE, 9, | 3668 | Vmouse_events = pure_list (Qmenu_bar, Qtool_bar, Qheader_line, Qmode_line, |
| 3673 | Qmenu_bar, | 3669 | intern_c_string ("mouse-1"), |
| 3674 | Qtool_bar, | 3670 | intern_c_string ("mouse-2"), |
| 3675 | Qheader_line, | 3671 | intern_c_string ("mouse-3"), |
| 3676 | Qmode_line, | 3672 | intern_c_string ("mouse-4"), |
| 3677 | intern_c_string ("mouse-1"), | 3673 | intern_c_string ("mouse-5")); |
| 3678 | intern_c_string ("mouse-2"), | ||
| 3679 | intern_c_string ("mouse-3"), | ||
| 3680 | intern_c_string ("mouse-4"), | ||
| 3681 | intern_c_string ("mouse-5")); | ||
| 3682 | 3674 | ||
| 3683 | /* Keymap used for minibuffers when doing completion. */ | 3675 | /* Keymap used for minibuffers when doing completion. */ |
| 3684 | /* Keymap used for minibuffers when doing completion and require a match. */ | 3676 | /* Keymap used for minibuffers when doing completion and require a match. */ |