aboutsummaryrefslogtreecommitdiffstats
path: root/src/keymap.c
diff options
context:
space:
mode:
authorPaul Eggert2013-07-15 23:39:49 -0700
committerPaul Eggert2013-07-15 23:39:49 -0700
commit6c6f1994bf684f510d600bd18023fa01b4b06500 (patch)
tree04b7125d1327d8419024f28d14bfb384afc52cdd /src/keymap.c
parent8abee653a22b0b879a9376c1dce3e3ca2e2f31d6 (diff)
downloademacs-6c6f1994bf684f510d600bd18023fa01b4b06500.tar.gz
emacs-6c6f1994bf684f510d600bd18023fa01b4b06500.zip
Prefer list1 (X) to Fcons (X, Qnil) when building lists.
This makes the code easier to read and the executable a bit smaller. Do not replace all calls to Fcons that happen to create lists, just calls that are intended to create lists. For example, when creating an alist that maps FOO to nil, use list1 (Fcons (FOO, Qnil)) rather than list1 (list1 (FOO)) or Fcons (Fcons (FOO, Qnil), Qnil). Similarly for list2 through list5. * buffer.c (Fget_buffer_create, Fmake_indirect_buffer): * bytecode.c (exec_byte_code): * callint.c (quotify_arg, Fcall_interactively): * callproc.c (Fcall_process, create_temp_file): * charset.c (load_charset_map_from_file) (Fdefine_charset_internal, init_charset): * coding.c (get_translation_table, detect_coding_system) (Fcheck_coding_systems_region) (Fset_terminal_coding_system_internal) (Fdefine_coding_system_internal, Fdefine_coding_system_alias): * composite.c (update_compositions, Ffind_composition_internal): * dired.c (directory_files_internal, file_name_completion) (Fsystem_users): * dispnew.c (Fopen_termscript, bitch_at_user, init_display): * doc.c (Fsnarf_documentation): * editfns.c (Fmessage_box): * emacs.c (main): * eval.c (do_debug_on_call, signal_error, maybe_call_debugger) (Feval, eval_sub, Ffuncall, apply_lambda): * fileio.c (make_temp_name, Fcopy_file, Faccess_file) (Fset_file_selinux_context, Fset_file_acl, Fset_file_modes) (Fset_file_times, Finsert_file_contents) (Fchoose_write_coding_system, Fwrite_region): * fns.c (Flax_plist_put, Fyes_or_no_p, syms_of_fns): * font.c (font_registry_charsets, font_parse_fcname) (font_prepare_cache, font_update_drivers, Flist_fonts): * fontset.c (Fset_fontset_font, Ffontset_info, syms_of_fontset): * frame.c (make_frame, Fmake_terminal_frame) (x_set_frame_parameters, x_report_frame_params) (x_default_parameter, Fx_parse_geometry): * ftfont.c (syms_of_ftfont): * image.c (gif_load): * keyboard.c (command_loop_1): * keymap.c (Fmake_keymap, Fmake_sparse_keymap, access_keymap_1) (Fcopy_keymap, append_key, Fcurrent_active_maps) (Fminor_mode_key_binding, accessible_keymaps_1) (Faccessible_keymaps, Fwhere_is_internal): * lread.c (read_emacs_mule_char): * menu.c (find_and_return_menu_selection): * minibuf.c (get_minibuffer): * nsfns.m (Fns_perform_service): * nsfont.m (ns_script_to_charset): * nsmenu.m (ns_popup_dialog): * nsselect.m (ns_get_local_selection, ns_string_from_pasteboard) (Fx_own_selection_internal): * nsterm.m (append2): * print.c (Fredirect_debugging_output) (print_prune_string_charset): * process.c (Fdelete_process, Fprocess_contact) (Fformat_network_address, set_socket_option) (read_and_dispose_of_process_output, write_queue_push) (send_process, exec_sentinel): * sound.c (Fplay_sound_internal): * textprop.c (validate_plist, add_properties) (Fput_text_property, Fadd_face_text_property) (copy_text_properties, text_property_list, syms_of_textprop): * unexaix.c (report_error): * unexcoff.c (report_error): * unexsol.c (unexec): * xdisp.c (redisplay_tool_bar, store_mode_line_string) (Fformat_mode_line, syms_of_xdisp): * xfaces.c (set_font_frame_param) (Finternal_lisp_face_attribute_values) (Finternal_merge_in_global_face, syms_of_xfaces): * xfns.c (x_default_scroll_bar_color_parameter) (x_default_font_parameter, x_create_tip_frame): * xfont.c (xfont_supported_scripts): * xmenu.c (Fx_popup_dialog, xmenu_show, xdialog_show) (menu_help_callback, xmenu_show): * xml.c (make_dom): * xterm.c (set_wm_state): Prefer list1 (FOO) to Fcons (FOO, Qnil) when creating a list, and similarly for list2 through list5.
Diffstat (limited to 'src/keymap.c')
-rw-r--r--src/keymap.c31
1 files changed, 15 insertions, 16 deletions
diff --git a/src/keymap.c b/src/keymap.c
index d29d5636e1c..e1268c8a06c 100644
--- a/src/keymap.c
+++ b/src/keymap.c
@@ -129,7 +129,7 @@ in case you use it as a menu with `x-popup-menu'. */)
129{ 129{
130 Lisp_Object tail; 130 Lisp_Object tail;
131 if (!NILP (string)) 131 if (!NILP (string))
132 tail = Fcons (string, Qnil); 132 tail = list1 (string);
133 else 133 else
134 tail = Qnil; 134 tail = Qnil;
135 return Fcons (Qkeymap, 135 return Fcons (Qkeymap,
@@ -151,9 +151,9 @@ in case you use it as a menu with `x-popup-menu'. */)
151 { 151 {
152 if (!NILP (Vpurify_flag)) 152 if (!NILP (Vpurify_flag))
153 string = Fpurecopy (string); 153 string = Fpurecopy (string);
154 return Fcons (Qkeymap, Fcons (string, Qnil)); 154 return list2 (Qkeymap, string);
155 } 155 }
156 return Fcons (Qkeymap, Qnil); 156 return list1 (Qkeymap);
157} 157}
158 158
159/* This function is used for installing the standard key bindings 159/* This function is used for installing the standard key bindings
@@ -534,12 +534,12 @@ access_keymap_1 (Lisp_Object map, Lisp_Object idx,
534 retval = val; 534 retval = val;
535 else if (CONSP (retval_tail)) 535 else if (CONSP (retval_tail))
536 { 536 {
537 XSETCDR (retval_tail, Fcons (val, Qnil)); 537 XSETCDR (retval_tail, list1 (val));
538 retval_tail = XCDR (retval_tail); 538 retval_tail = XCDR (retval_tail);
539 } 539 }
540 else 540 else
541 { 541 {
542 retval_tail = Fcons (val, Qnil); 542 retval_tail = list1 (val);
543 retval = Fcons (Qkeymap, Fcons (retval, retval_tail)); 543 retval = Fcons (Qkeymap, Fcons (retval, retval_tail));
544 } 544 }
545 } 545 }
@@ -1045,9 +1045,9 @@ However, a key definition which is a symbol whose definition is a keymap
1045is not copied. */) 1045is not copied. */)
1046 (Lisp_Object keymap) 1046 (Lisp_Object keymap)
1047{ 1047{
1048 register Lisp_Object copy, tail; 1048 Lisp_Object copy, tail;
1049 keymap = get_keymap (keymap, 1, 0); 1049 keymap = get_keymap (keymap, 1, 0);
1050 copy = tail = Fcons (Qkeymap, Qnil); 1050 copy = tail = list1 (Qkeymap);
1051 keymap = XCDR (keymap); /* Skip the `keymap' symbol. */ 1051 keymap = XCDR (keymap); /* Skip the `keymap' symbol. */
1052 1052
1053 while (CONSP (keymap) && !EQ (XCAR (keymap), Qkeymap)) 1053 while (CONSP (keymap) && !EQ (XCAR (keymap), Qkeymap))
@@ -1073,7 +1073,7 @@ is not copied. */)
1073 else 1073 else
1074 elt = Fcons (XCAR (elt), copy_keymap_item (XCDR (elt))); 1074 elt = Fcons (XCAR (elt), copy_keymap_item (XCDR (elt)));
1075 } 1075 }
1076 XSETCDR (tail, Fcons (elt, Qnil)); 1076 XSETCDR (tail, list1 (elt));
1077 tail = XCDR (tail); 1077 tail = XCDR (tail);
1078 keymap = XCDR (keymap); 1078 keymap = XCDR (keymap);
1079 } 1079 }
@@ -1341,8 +1341,7 @@ append_key (Lisp_Object key_sequence, Lisp_Object key)
1341 Lisp_Object args[2]; 1341 Lisp_Object args[2];
1342 1342
1343 args[0] = key_sequence; 1343 args[0] = key_sequence;
1344 1344 args[1] = list1 (key);
1345 args[1] = Fcons (key, Qnil);
1346 return Fvconcat (2, args); 1345 return Fvconcat (2, args);
1347} 1346}
1348 1347
@@ -1549,7 +1548,7 @@ like in the respective argument of `key-binding'. */)
1549{ 1548{
1550 ptrdiff_t count = SPECPDL_INDEX (); 1549 ptrdiff_t count = SPECPDL_INDEX ();
1551 1550
1552 Lisp_Object keymaps = Fcons (current_global_map, Qnil); 1551 Lisp_Object keymaps = list1 (current_global_map);
1553 1552
1554 /* If a mouse click position is given, our variables are based on 1553 /* If a mouse click position is given, our variables are based on
1555 the buffer clicked on, not the current buffer. So we may have to 1554 the buffer clicked on, not the current buffer. So we may have to
@@ -1809,7 +1808,7 @@ bindings; see the description of `lookup-key' for more details about this. */)
1809 if (KEYMAPP (binding)) 1808 if (KEYMAPP (binding))
1810 maps[j++] = Fcons (modes[i], binding); 1809 maps[j++] = Fcons (modes[i], binding);
1811 else if (j == 0) 1810 else if (j == 0)
1812 RETURN_UNGCPRO (Fcons (Fcons (modes[i], binding), Qnil)); 1811 RETURN_UNGCPRO (list1 (Fcons (modes[i], binding)));
1813 } 1812 }
1814 1813
1815 UNGCPRO; 1814 UNGCPRO;
@@ -1951,7 +1950,7 @@ accessible_keymaps_1 (Lisp_Object key, Lisp_Object cmd, Lisp_Object args, void *
1951 else 1950 else
1952 { 1951 {
1953 tem = append_key (thisseq, key); 1952 tem = append_key (thisseq, key);
1954 nconc2 (tail, Fcons (Fcons (tem, cmd), Qnil)); 1953 nconc2 (tail, list1 (Fcons (tem, cmd)));
1955 } 1954 }
1956} 1955}
1957 1956
@@ -2005,13 +2004,13 @@ then the value includes only maps for prefixes that start with PREFIX. */)
2005 } 2004 }
2006 prefix = copy; 2005 prefix = copy;
2007 } 2006 }
2008 maps = Fcons (Fcons (prefix, tem), Qnil); 2007 maps = list1 (Fcons (prefix, tem));
2009 } 2008 }
2010 else 2009 else
2011 return Qnil; 2010 return Qnil;
2012 } 2011 }
2013 else 2012 else
2014 maps = Fcons (Fcons (zero_vector, get_keymap (keymap, 1, 0)), Qnil); 2013 maps = list1 (Fcons (zero_vector, get_keymap (keymap, 1, 0)));
2015 2014
2016 /* For each map in the list maps, 2015 /* For each map in the list maps,
2017 look at any other maps it points to, 2016 look at any other maps it points to,
@@ -2619,7 +2618,7 @@ The optional 5th arg NO-REMAP alters how command remapping is handled:
2619 if (CONSP (keymap) && KEYMAPP (XCAR (keymap))) 2618 if (CONSP (keymap) && KEYMAPP (XCAR (keymap)))
2620 keymaps = keymap; 2619 keymaps = keymap;
2621 else if (!NILP (keymap)) 2620 else if (!NILP (keymap))
2622 keymaps = Fcons (keymap, Fcons (current_global_map, Qnil)); 2621 keymaps = list2 (keymap, current_global_map);
2623 else 2622 else
2624 keymaps = Fcurrent_active_maps (Qnil, Qnil); 2623 keymaps = Fcurrent_active_maps (Qnil, Qnil);
2625 2624