replace XTYPE calls in nextstep files
[bpt/emacs.git] / src / keymap.c
index d29d563..739af68 100644 (file)
@@ -1,5 +1,5 @@
 /* Manipulation of keymaps
-   Copyright (C) 1985-1988, 1993-1995, 1998-2013 Free Software
+   Copyright (C) 1985-1988, 1993-1995, 1998-2014 Free Software
    Foundation, Inc.
 
 This file is part of GNU Emacs.
@@ -129,7 +129,7 @@ in case you use it as a menu with `x-popup-menu'.  */)
 {
   Lisp_Object tail;
   if (!NILP (string))
-    tail = Fcons (string, Qnil);
+    tail = list1 (string);
   else
     tail = Qnil;
   return Fcons (Qkeymap,
@@ -151,9 +151,9 @@ in case you use it as a menu with `x-popup-menu'.  */)
     {
       if (!NILP (Vpurify_flag))
        string = Fpurecopy (string);
-      return Fcons (Qkeymap, Fcons (string, Qnil));
+      return list2 (Qkeymap, string);
     }
-  return Fcons (Qkeymap, Qnil);
+  return list1 (Qkeymap);
 }
 
 /* This function is used for installing the standard key bindings
@@ -534,12 +534,12 @@ access_keymap_1 (Lisp_Object map, Lisp_Object idx,
              retval = val;
            else if (CONSP (retval_tail))
              {
-               XSETCDR (retval_tail, Fcons (val, Qnil));
+               XSETCDR (retval_tail, list1 (val));
                retval_tail = XCDR (retval_tail);
              }
            else
              {
-               retval_tail = Fcons (val, Qnil);
+               retval_tail = list1 (val);
                retval = Fcons (Qkeymap, Fcons (retval, retval_tail));
              }
          }
@@ -617,8 +617,8 @@ map_keymap_internal (Lisp_Object map,
        }
       else if (CHAR_TABLE_P (binding))
        map_char_table (map_keymap_char_table_item, Qnil, binding,
-                       make_save_value (SAVE_TYPE_FUNCPTR_PTR_OBJ,
-                                        (voidfuncptr) fun, data, args));
+                       make_save_funcptr_ptr_obj ((voidfuncptr) fun, data,
+                                                  args));
     }
   UNGCPRO;
   return tail;
@@ -1045,9 +1045,9 @@ However, a key definition which is a symbol whose definition is a keymap
 is not copied.  */)
   (Lisp_Object keymap)
 {
-  register Lisp_Object copy, tail;
+  Lisp_Object copy, tail;
   keymap = get_keymap (keymap, 1, 0);
-  copy = tail = Fcons (Qkeymap, Qnil);
+  copy = tail = list1 (Qkeymap);
   keymap = XCDR (keymap);              /* Skip the `keymap' symbol.  */
 
   while (CONSP (keymap) && !EQ (XCAR (keymap), Qkeymap))
@@ -1073,7 +1073,7 @@ is not copied.  */)
          else
            elt = Fcons (XCAR (elt), copy_keymap_item (XCDR (elt)));
        }
-      XSETCDR (tail, Fcons (elt, Qnil));
+      XSETCDR (tail, list1 (elt));
       tail = XCDR (tail);
       keymap = XCDR (keymap);
     }
@@ -1341,8 +1341,7 @@ append_key (Lisp_Object key_sequence, Lisp_Object key)
   Lisp_Object args[2];
 
   args[0] = key_sequence;
-
-  args[1] = Fcons (key, Qnil);
+  args[1] = list1 (key);
   return Fvconcat (2, args);
 }
 
@@ -1384,9 +1383,7 @@ silly_event_symbol_error (Lisp_Object c)
       c = reorder_modifiers (c);
       keystring = concat2 (build_string (new_mods), XCDR (assoc));
 
-      error ((modifiers & ~meta_modifier
-             ? "To bind the key %s, use [?%s], not [%s]"
-             : "To bind the key %s, use \"%s\", not [%s]"),
+      error ("To bind the key %s, use [?%s], not [%s]",
             SDATA (SYMBOL_NAME (c)), SDATA (keystring),
             SDATA (SYMBOL_NAME (c)));
     }
@@ -1480,26 +1477,26 @@ current_minor_maps (Lisp_Object **modeptr, Lisp_Object **mapptr)
                /* Use malloc here.  See the comment above this function.
                   Avoid realloc here; it causes spurious traps on GNU/Linux [KFS] */
                block_input ();
-               newmodes = malloc (allocsize);
+               newmodes = xmalloc_unsafe (allocsize);
                if (newmodes)
                  {
                    if (cmm_modes)
                      {
                        memcpy (newmodes, cmm_modes,
                                cmm_size * sizeof cmm_modes[0]);
-                       free (cmm_modes);
+                       xfree (cmm_modes);
                      }
                    cmm_modes = newmodes;
                  }
 
-               newmaps = malloc (allocsize);
+               newmaps = xmalloc_unsafe (allocsize);
                if (newmaps)
                  {
                    if (cmm_maps)
                      {
                        memcpy (newmaps, cmm_maps,
                                cmm_size * sizeof cmm_maps[0]);
-                       free (cmm_maps);
+                       xfree (cmm_maps);
                      }
                    cmm_maps = newmaps;
                  }
@@ -1549,7 +1546,7 @@ like in the respective argument of `key-binding'.  */)
 {
   ptrdiff_t count = SPECPDL_INDEX ();
 
-  Lisp_Object keymaps = Fcons (current_global_map, Qnil);
+  Lisp_Object keymaps = list1 (current_global_map);
 
   /* If a mouse click position is given, our variables are based on
      the buffer clicked on, not the current buffer.  So we may have to
@@ -1809,7 +1806,7 @@ bindings; see the description of `lookup-key' for more details about this.  */)
        if (KEYMAPP (binding))
          maps[j++] = Fcons (modes[i], binding);
        else if (j == 0)
-         RETURN_UNGCPRO (Fcons (Fcons (modes[i], binding), Qnil));
+         RETURN_UNGCPRO (list1 (Fcons (modes[i], binding)));
       }
 
   UNGCPRO;
@@ -1895,7 +1892,7 @@ struct accessible_keymaps_data {
 
 static void
 accessible_keymaps_1 (Lisp_Object key, Lisp_Object cmd, Lisp_Object args, void *data)
-/* Use void* data to be compatible with map_keymap_function_t.  */
+/* Use void * data to be compatible with map_keymap_function_t.  */
 {
   struct accessible_keymaps_data *d = data; /* Cast! */
   Lisp_Object maps = d->maps;
@@ -1951,7 +1948,7 @@ accessible_keymaps_1 (Lisp_Object key, Lisp_Object cmd, Lisp_Object args, void *
   else
     {
       tem = append_key (thisseq, key);
-      nconc2 (tail, Fcons (Fcons (tem, cmd), Qnil));
+      nconc2 (tail, list1 (Fcons (tem, cmd)));
     }
 }
 
@@ -2005,13 +2002,13 @@ then the value includes only maps for prefixes that start with PREFIX.  */)
                }
              prefix = copy;
            }
-         maps = Fcons (Fcons (prefix, tem), Qnil);
+         maps = list1 (Fcons (prefix, tem));
        }
       else
        return Qnil;
     }
   else
-    maps = Fcons (Fcons (zero_vector, get_keymap (keymap, 1, 0)), Qnil);
+    maps = list1 (Fcons (zero_vector, get_keymap (keymap, 1, 0)));
 
   /* For each map in the list maps,
      look at any other maps it points to,
@@ -2619,7 +2616,7 @@ The optional 5th arg NO-REMAP alters how command remapping is handled:
   if (CONSP (keymap) && KEYMAPP (XCAR (keymap)))
     keymaps = keymap;
   else if (!NILP (keymap))
-    keymaps = Fcons (keymap, Fcons (current_global_map, Qnil));
+    keymaps = list2 (keymap, current_global_map);
   else
     keymaps = Fcurrent_active_maps (Qnil, Qnil);
 
@@ -3250,8 +3247,7 @@ describe_map (Lisp_Object map, Lisp_Object prefix,
   for (tail = map; CONSP (tail); tail = XCDR (tail))
     length_needed++;
 
-  vect = ((struct describe_map_elt *)
-         alloca (sizeof (struct describe_map_elt) * length_needed));
+  vect = alloca (length_needed * sizeof *vect);
 
   for (tail = map; CONSP (tail); tail = XCDR (tail))
     {
@@ -3385,9 +3381,12 @@ describe_map (Lisp_Object map, Lisp_Object prefix,
 
       if (vect[i].shadowed)
        {
-         SET_PT (PT - 1);
+         ptrdiff_t pt = max (PT - 1, BEG);
+
+         SET_PT (pt);
          insert_string ("\n  (that binding is currently shadowed by another mode)");
-         SET_PT (PT + 1);
+         pt = min (PT + 1, Z);
+         SET_PT (pt);
        }
     }
 
@@ -3752,7 +3751,7 @@ it is provided for major modes to bind locally.  */);
   Vminor_mode_overriding_map_alist = Qnil;
 
   DEFVAR_LISP ("emulation-mode-map-alists", Vemulation_mode_map_alists,
-              doc: /* List of keymap alists to use for emulations modes.
+              doc: /* List of keymap alists to use for emulation modes.
 It is intended for modes or packages using multiple minor-mode keymaps.
 Each element is a keymap alist just like `minor-mode-map-alist', or a
 symbol with a variable binding which is a keymap alist, and it is used