]> code.delx.au - gnu-emacs/blobdiff - src/fns.c
(Fy_or_n_p): Change call to read_filtered_event to use new arg.
[gnu-emacs] / src / fns.c
index e910c87375b3b161a1d11a5d8842847ae7137859..ca4a098878a37540d1a01efb4d7ceb3c2c4bff80 100644 (file)
--- a/src/fns.c
+++ b/src/fns.c
@@ -1,6 +1,7 @@
 /* Random utility Lisp functions.
-   Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995, 1997, 1998, 1999, 2000,
-     2001, 2002, 2003, 2004, 2005  Free Software Foundation, Inc.
+   Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995, 1997,
+                 1998, 1999, 2000, 2001, 2002, 2003, 2004,
+                 2005, 2006 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -16,8 +17,8 @@ GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with GNU Emacs; see the file COPYING.  If not, write to
-the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.  */
+the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+Boston, MA 02110-1301, USA.  */
 
 #include <config.h>
 
@@ -47,8 +48,12 @@ Boston, MA 02111-1307, USA.  */
 #include "frame.h"
 #include "window.h"
 #include "blockinput.h"
-#if defined (HAVE_MENUS) && defined (HAVE_X_WINDOWS)
+#ifdef HAVE_MENUS
+#if defined (HAVE_X_WINDOWS)
 #include "xterm.h"
+#elif defined (MAC_OS)
+#include "macterm.h"
+#endif
 #endif
 
 #ifndef NULL
@@ -76,10 +81,10 @@ Lisp_Object Qcodeset, Qdays, Qmonths, Qpaper;
 
 extern Lisp_Object Qinput_method_function;
 
-static int internal_equal ();
+static int internal_equal P_ ((Lisp_Object , Lisp_Object, int, int));
 
 extern long get_random ();
-extern void seed_random ();
+extern void seed_random P_ ((long));
 
 #ifndef HAVE_UNISTD_H
 extern long time ();
@@ -142,7 +147,6 @@ To get the number of bytes, use `string-bytes'. */)
   register Lisp_Object val;
   register int i;
 
- retry:
   if (STRINGP (sequence))
     XSETFASTINT (val, SCHARS (sequence));
   else if (VECTORP (sequence))
@@ -171,18 +175,15 @@ To get the number of bytes, use `string-bytes'. */)
          QUIT;
        }
 
-      if (!NILP (sequence))
-       wrong_type_argument (Qlistp, sequence);
+      CHECK_LIST_END (sequence, sequence);
 
       val = make_number (i);
     }
   else if (NILP (sequence))
     XSETFASTINT (val, 0);
   else
-    {
-      sequence = wrong_type_argument (Qsequencep, sequence);
-      goto retry;
-    }
+    wrong_type_argument (Qsequencep, sequence);
+
   return val;
 }
 
@@ -524,7 +525,8 @@ with the original. */)
     }
 
   if (!CONSP (arg) && !VECTORP (arg) && !STRINGP (arg))
-    arg = wrong_type_argument (Qsequencep, arg);
+    wrong_type_argument (Qsequencep, arg);
+
   return concat (1, &arg, CONSP (arg) ? Lisp_Cons : XTYPE (arg), 0);
 }
 
@@ -576,15 +578,13 @@ concat (nargs, args, target_type, last_special)
   else
     last_tail = Qnil;
 
-  /* Canonicalize each argument.  */
+  /* Check each argument.  */
   for (argnum = 0; argnum < nargs; argnum++)
     {
       this = args[argnum];
       if (!(CONSP (this) || NILP (this) || VECTORP (this) || STRINGP (this)
            || COMPILEDP (this) || BOOL_VECTOR_P (this)))
-       {
-           args[argnum] = wrong_type_argument (Qsequencep, this);
-       }
+       wrong_type_argument (Qsequencep, this);
     }
 
   /* Compute total length in chars of arguments in RESULT_LEN.
@@ -611,8 +611,7 @@ concat (nargs, args, target_type, last_special)
            for (i = 0; i < len; i++)
              {
                ch = XVECTOR (this)->contents[i];
-               if (! INTEGERP (ch))
-                 wrong_type_argument (Qintegerp, ch);
+               CHECK_NUMBER (ch);
                this_len_byte = CHAR_BYTES (XINT (ch));
                result_len_byte += this_len_byte;
                if (!SINGLE_BYTE_CHAR_P (XINT (ch)))
@@ -624,8 +623,7 @@ concat (nargs, args, target_type, last_special)
            for (; CONSP (this); this = XCDR (this))
              {
                ch = XCAR (this);
-               if (! INTEGERP (ch))
-                 wrong_type_argument (Qintegerp, ch);
+               CHECK_NUMBER (ch);
                this_len_byte = CHAR_BYTES (XINT (ch));
                result_len_byte += this_len_byte;
                if (!SINGLE_BYTE_CHAR_P (XINT (ch)))
@@ -1153,13 +1151,13 @@ Beware, this often doesn't really do what you think it does.
 It is similar to (decode-coding-string STRING 'emacs-mule-unix).
 If you're not sure, whether to use `string-as-multibyte' or
 `string-to-multibyte', use `string-to-multibyte'.  Beware:
-   (aref (string-as-multibyte "\201") 0) -> 129 (aka ?\201)
-   (aref (string-as-multibyte "\300") 0) -> 192 (aka ?\300)
-   (aref (string-as-multibyte "\300\201") 0) -> 192 (aka ?\300)
-   (aref (string-as-multibyte "\300\201") 1) -> 129 (aka ?\201)
+   (aref (string-as-multibyte "\\201") 0) -> 129 (aka ?\\201)
+   (aref (string-as-multibyte "\\300") 0) -> 192 (aka ?\\300)
+   (aref (string-as-multibyte "\\300\\201") 0) -> 192 (aka ?\\300)
+   (aref (string-as-multibyte "\\300\\201") 1) -> 129 (aka ?\\201)
 but
-   (aref (string-as-multibyte "\201\300") 0) -> 2240
-   (aref (string-as-multibyte "\201\300") 1) -> <error>  */)
+   (aref (string-as-multibyte "\\201\\300") 0) -> 2240
+   (aref (string-as-multibyte "\\201\\300") 1) -> <error>  */)
      (string)
      Lisp_Object string;
 {
@@ -1247,9 +1245,7 @@ This function allows vectors as well as strings.  */)
   int from_char, to_char;
   int from_byte = 0, to_byte = 0;
 
-  if (! (STRINGP (string) || VECTORP (string)))
-    wrong_type_argument (Qarrayp, string);
-
+  CHECK_VECTOR_OR_STRING (string);
   CHECK_NUMBER (from);
 
   if (STRINGP (string))
@@ -1373,8 +1369,7 @@ substring_both (string, from, from_byte, to, to_byte)
   int size;
   int size_byte;
 
-  if (! (STRINGP (string) || VECTORP (string)))
-    wrong_type_argument (Qarrayp, string);
+  CHECK_VECTOR_OR_STRING (string);
 
   if (STRINGP (string))
     {
@@ -1414,8 +1409,7 @@ DEFUN ("nthcdr", Fnthcdr, Snthcdr, 2, 2, 0,
   for (i = 0; i < num && !NILP (list); i++)
     {
       QUIT;
-      if (! CONSP (list))
-       wrong_type_argument (Qlistp, list);
+      CHECK_LIST_CONS (list, list);
       list = XCDR (list);
     }
   return list;
@@ -1436,16 +1430,12 @@ DEFUN ("elt", Felt, Selt, 2, 2, 0,
      register Lisp_Object sequence, n;
 {
   CHECK_NUMBER (n);
-  while (1)
-    {
-      if (CONSP (sequence) || NILP (sequence))
-       return Fcar (Fnthcdr (n, sequence));
-      else if (STRINGP (sequence) || VECTORP (sequence)
-              || BOOL_VECTOR_P (sequence) || CHAR_TABLE_P (sequence))
-       return Faref (sequence, n);
-      else
-       sequence = wrong_type_argument (Qsequencep, sequence);
-    }
+  if (CONSP (sequence) || NILP (sequence))
+    return Fcar (Fnthcdr (n, sequence));
+
+  /* Faref signals a "not array" error, so check here.  */
+  CHECK_ARRAY (sequence, Qsequencep);
+  return Faref (sequence, n);
 }
 
 DEFUN ("member", Fmember, Smember, 2, 2, 0,
@@ -1459,8 +1449,7 @@ The value is actually the tail of LIST whose car is ELT.  */)
   for (tail = list; !NILP (tail); tail = XCDR (tail))
     {
       register Lisp_Object tem;
-      if (! CONSP (tail))
-       wrong_type_argument (Qlistp, list);
+      CHECK_LIST_CONS (tail, list);
       tem = XCAR (tail);
       if (! NILP (Fequal (elt, tem)))
        return tail;
@@ -1471,7 +1460,7 @@ The value is actually the tail of LIST whose car is ELT.  */)
 
 DEFUN ("memq", Fmemq, Smemq, 2, 2, 0,
        doc: /* Return non-nil if ELT is an element of LIST.
-Comparison done with EQ.  The value is actually the tail of LIST
+Comparison done with `eq'.  The value is actually the tail of LIST
 whose car is ELT.  */)
      (elt, list)
      Lisp_Object elt, list;
@@ -1493,9 +1482,7 @@ whose car is ELT.  */)
       QUIT;
     }
 
-  if (!CONSP (list) && !NILP (list))
-    list = wrong_type_argument (Qlistp, list);
-
+  CHECK_LIST (list);
   return list;
 }
 
@@ -1506,8 +1493,6 @@ Elements of LIST that are not conses are ignored.  */)
      (key, list)
      Lisp_Object key, list;
 {
-  Lisp_Object result;
-
   while (1)
     {
       if (!CONSP (list)
@@ -1531,14 +1516,7 @@ Elements of LIST that are not conses are ignored.  */)
       QUIT;
     }
 
-  if (CONSP (list))
-    result = XCAR (list);
-  else if (NILP (list))
-    result = Qnil;
-  else
-    result = wrong_type_argument (Qlistp, list);
-
-  return result;
+  return CAR (list);
 }
 
 /* Like Fassq but never report an error and do not allow quits.
@@ -1553,7 +1531,7 @@ assq_no_quit (key, list)
             || !EQ (XCAR (XCAR (list)), key)))
     list = XCDR (list);
 
-  return CONSP (list) ? XCAR (list) : Qnil;
+  return CAR_SAFE (list);
 }
 
 DEFUN ("assoc", Fassoc, Sassoc, 2, 2, 0,
@@ -1562,7 +1540,7 @@ The value is actually the first element of LIST whose car equals KEY.  */)
      (key, list)
      Lisp_Object key, list;
 {
-  Lisp_Object result, car;
+  Lisp_Object car;
 
   while (1)
     {
@@ -1590,14 +1568,7 @@ The value is actually the first element of LIST whose car equals KEY.  */)
       QUIT;
     }
 
-  if (CONSP (list))
-    result = XCAR (list);
-  else if (NILP (list))
-    result = Qnil;
-  else
-    result = wrong_type_argument (Qlistp, list);
-
-  return result;
+  return CAR (list);
 }
 
 DEFUN ("rassq", Frassq, Srassq, 2, 2, 0,
@@ -1607,8 +1578,6 @@ The value is actually the first element of LIST whose cdr is KEY.  */)
      register Lisp_Object key;
      Lisp_Object list;
 {
-  Lisp_Object result;
-
   while (1)
     {
       if (!CONSP (list)
@@ -1632,14 +1601,7 @@ The value is actually the first element of LIST whose cdr is KEY.  */)
       QUIT;
     }
 
-  if (NILP (list))
-    result = Qnil;
-  else if (CONSP (list))
-    result = XCAR (list);
-  else
-    result = wrong_type_argument (Qlistp, list);
-
-  return result;
+  return CAR (list);
 }
 
 DEFUN ("rassoc", Frassoc, Srassoc, 2, 2, 0,
@@ -1648,7 +1610,7 @@ The value is actually the first element of LIST whose cdr equals KEY.  */)
      (key, list)
      Lisp_Object key, list;
 {
-  Lisp_Object result, cdr;
+  Lisp_Object cdr;
 
   while (1)
     {
@@ -1676,14 +1638,7 @@ The value is actually the first element of LIST whose cdr equals KEY.  */)
       QUIT;
     }
 
-  if (CONSP (list))
-    result = XCAR (list);
-  else if (NILP (list))
-    result = Qnil;
-  else
-    result = wrong_type_argument (Qlistp, list);
-
-  return result;
+  return CAR (list);
 }
 \f
 DEFUN ("delq", Fdelq, Sdelq, 2, 2, 0,
@@ -1703,8 +1658,7 @@ to be sure of changing the value of `foo'.  */)
   prev = Qnil;
   while (!NILP (tail))
     {
-      if (! CONSP (tail))
-       wrong_type_argument (Qlistp, list);
+      CHECK_LIST_CONS (tail, list);
       tem = XCAR (tail);
       if (EQ (elt, tem))
        {
@@ -1826,8 +1780,7 @@ to be sure of changing the value of `foo'.  */)
 
       for (tail = seq, prev = Qnil; !NILP (tail); tail = XCDR (tail))
        {
-         if (!CONSP (tail))
-           wrong_type_argument (Qlistp, seq);
+         CHECK_LIST_CONS (tail, seq);
 
          if (!NILP (Fequal (elt, XCAR (tail))))
            {
@@ -1859,8 +1812,7 @@ Return the reversed list.  */)
   while (!NILP (tail))
     {
       QUIT;
-      if (! CONSP (tail))
-       wrong_type_argument (Qlistp, list);
+      CHECK_LIST_CONS (tail, list);
       next = XCDR (tail);
       Fsetcdr (tail, prev);
       prev = tail;
@@ -1882,8 +1834,7 @@ See also the function `nreverse', which is used more often.  */)
       QUIT;
       new = Fcons (XCAR (list), new);
     }
-  if (!NILP (list))
-    wrong_type_argument (Qconsp, list);
+  CHECK_LIST_END (list, list);
   return new;
 }
 \f
@@ -1892,8 +1843,8 @@ Lisp_Object merge ();
 DEFUN ("sort", Fsort, Ssort, 2, 2, 0,
        doc: /* Sort LIST, stably, comparing elements using PREDICATE.
 Returns the sorted list.  LIST is modified by side effects.
-PREDICATE is called with two elements of LIST, and should return t
-if the first element is "less" than the second.  */)
+PREDICATE is called with two elements of LIST, and should return non-nil
+if the first element should sort before the second.  */)
      (list, predicate)
      Lisp_Object list, predicate;
 {
@@ -2007,8 +1958,7 @@ one of the properties on the list.  */)
        QUIT;
     }
 
-  if (!NILP (tail))
-    wrong_type_argument (Qlistp, prop);
+  CHECK_LIST_END (tail, prop);
 
   return Qnil;
 }
@@ -2124,8 +2074,7 @@ one of the properties on the list.  */)
       QUIT;
     }
 
-  if (!NILP (tail))
-    wrong_type_argument (Qlistp, prop);
+  CHECK_LIST_END (tail, prop);
 
   return Qnil;
 }
@@ -2249,7 +2198,7 @@ internal_equal (o1, o2, depth, props)
          if (!internal_equal (OVERLAY_START (o1), OVERLAY_START (o2),
                               depth + 1, props)
              || !internal_equal (OVERLAY_END (o1), OVERLAY_END (o2),
-                                 depth + 1))
+                                 depth + 1, props))
            return 0;
          o1 = XOVERLAY (o1)->plist;
          o2 = XOVERLAY (o2)->plist;
@@ -2339,7 +2288,6 @@ ARRAY is a vector, string, char-table, or bool-vector.  */)
      Lisp_Object array, item;
 {
   register int size, index, charval;
- retry:
   if (VECTORP (array))
     {
       register Lisp_Object *p = XVECTOR (array)->contents;
@@ -2403,10 +2351,7 @@ ARRAY is a vector, string, char-table, or bool-vector.  */)
        }
     }
   else
-    {
-      array = wrong_type_argument (Qarrayp, array);
-      goto retry;
-    }
+    wrong_type_argument (Qarrayp, array);
   return array;
 }
 
@@ -2546,14 +2491,14 @@ RANGE should be nil (for the default value),
 a vector which identifies a character set or a row of a character set,
 a character set name, or a character code.
 If the characters in the specified range have different values,
-an error is signalled.
+an error is signaled.
 
 Note that this function doesn't check the parent of CHAR-TABLE.  */)
      (char_table, range)
      Lisp_Object char_table, range;
 {
   int charset_id, c1 = 0, c2 = 0;
-  int size, i;
+  int size;
   Lisp_Object ch, val, current_default;
 
   CHECK_CHAR_TABLE (char_table);
@@ -3037,8 +2982,7 @@ usage: (nconc &rest LISTS)  */)
 
       if (argnum + 1 == nargs) break;
 
-      if (!CONSP (tem))
-       tem = wrong_type_argument (Qlistp, tem);
+      CHECK_LIST_CONS (tem, tem);
 
       while (CONSP (tem))
        {
@@ -3305,7 +3249,7 @@ is nil and `use-dialog-box' is non-nil.  */)
          Fraise_frame (mini_frame);
        }
 
-      obj = read_filtered_event (1, 0, 0, 0);
+      obj = read_filtered_event (1, 0, 0, 0, Qnil);
       cursor_in_echo_area = 0;
       /* If we need to quit, quit with cursor_in_echo_area = 0.  */
       QUIT;
@@ -3424,7 +3368,7 @@ is nil, and `use-dialog-box' is non-nil.  */)
     {
       ans = Fdowncase (Fread_from_minibuffer (prompt, Qnil, Qnil, Qnil,
                                              Qyes_or_no_p_history, Qnil,
-                                             Qnil, Qnil));
+                                             Qnil));
       if (SCHARS (ans) == 3 && !strcmp (SDATA (ans), "yes"))
        {
          UNGCPRO;
@@ -3513,7 +3457,8 @@ particular subfeatures supported in this version of FEATURE.  */)
   CHECK_SYMBOL (feature);
   CHECK_LIST (subfeatures);
   if (!NILP (Vautoload_queue))
-    Vautoload_queue = Fcons (Fcons (Vfeatures, Qnil), Vautoload_queue);
+    Vautoload_queue = Fcons (Fcons (make_number (0), Vfeatures),
+                            Vautoload_queue);
   tem = Fmemq (feature, Vfeatures);
   if (NILP (tem))
     Vfeatures = Fcons (feature, Vfeatures);
@@ -3558,14 +3503,20 @@ The normal messages at start and end of loading FILENAME are suppressed.  */)
 {
   register Lisp_Object tem;
   struct gcpro gcpro1, gcpro2;
+  int from_file = load_in_progress;
 
   CHECK_SYMBOL (feature);
 
   /* Record the presence of `require' in this file
      even if the feature specified is already loaded.
      But not more than once in any file,
-     and not when we aren't loading a file.  */
-  if (load_in_progress)
+     and not when we aren't loading or reading from a file.  */
+  if (!from_file)
+    for (tem = Vcurrent_load_list; CONSP (tem); tem = XCDR (tem))
+      if (NILP (XCDR (tem)) && STRINGP (XCAR (tem)))
+       from_file = 1;
+
+  if (from_file)
     {
       tem = Fcons (Qrequire, feature);
       if (NILP (Fmember (tem, Vcurrent_load_list)))
@@ -4536,10 +4487,7 @@ hashfn_user_defined (h, key)
   args[1] = key;
   hash = Ffuncall (2, args);
   if (!INTEGERP (hash))
-    Fsignal (Qerror,
-            list2 (build_string ("Invalid hash code returned from \
-user-supplied hash function"),
-                   hash));
+    signal_error ("Invalid hash code returned from user-supplied hash function", hash);
   return XUINT (hash);
 }
 
@@ -5106,6 +5054,12 @@ sxhash_list (list, depth)
        hash = SXHASH_COMBINE (hash, hash2);
       }
 
+  if (!NILP (list))
+    {
+      unsigned hash2 = sxhash (list, depth + 1);
+      hash = SXHASH_COMBINE (hash, hash2);
+    }
+
   return hash;
 }
 
@@ -5289,8 +5243,7 @@ usage: (make-hash-table &rest KEYWORD-ARGS)  */)
 
       prop = Fget (test, Qhash_table_test);
       if (!CONSP (prop) || !CONSP (XCDR (prop)))
-       Fsignal (Qerror, list2 (build_string ("Invalid hash table test"),
-                               test));
+       signal_error ("Invalid hash table test", test);
       user_test = XCAR (prop);
       user_hash = XCAR (XCDR (prop));
     }
@@ -5303,9 +5256,7 @@ usage: (make-hash-table &rest KEYWORD-ARGS)  */)
   if (NILP (size))
     size = make_number (DEFAULT_HASH_SIZE);
   else if (!INTEGERP (size) || XINT (size) < 0)
-    Fsignal (Qerror,
-            list2 (build_string ("Invalid hash table size"),
-                   size));
+    signal_error ("Invalid hash table size", size);
 
   /* Look for `:rehash-size SIZE'.  */
   i = get_key_arg (QCrehash_size, nargs, args, used);
@@ -5313,9 +5264,7 @@ usage: (make-hash-table &rest KEYWORD-ARGS)  */)
   if (!NUMBERP (rehash_size)
       || (INTEGERP (rehash_size) && XINT (rehash_size) <= 0)
       || XFLOATINT (rehash_size) <= 1.0)
-    Fsignal (Qerror,
-            list2 (build_string ("Invalid hash table rehash size"),
-                   rehash_size));
+    signal_error ("Invalid hash table rehash size", rehash_size);
 
   /* Look for `:rehash-threshold THRESHOLD'.  */
   i = get_key_arg (QCrehash_threshold, nargs, args, used);
@@ -5323,9 +5272,7 @@ usage: (make-hash-table &rest KEYWORD-ARGS)  */)
   if (!FLOATP (rehash_threshold)
       || XFLOATINT (rehash_threshold) <= 0.0
       || XFLOATINT (rehash_threshold) > 1.0)
-    Fsignal (Qerror,
-            list2 (build_string ("Invalid hash table rehash threshold"),
-                   rehash_threshold));
+    signal_error ("Invalid hash table rehash threshold", rehash_threshold);
 
   /* Look for `:weakness WEAK'.  */
   i = get_key_arg (QCweakness, nargs, args, used);
@@ -5337,14 +5284,12 @@ usage: (make-hash-table &rest KEYWORD-ARGS)  */)
       && !EQ (weak, Qvalue)
       && !EQ (weak, Qkey_or_value)
       && !EQ (weak, Qkey_and_value))
-    Fsignal (Qerror, list2 (build_string ("Invalid hash table weakness"),
-                           weak));
+    signal_error ("Invalid hash table weakness", weak);
 
   /* Now, all args should have been used up, or there's a problem.  */
   for (i = 0; i < nargs; ++i)
     if (!used[i])
-      Fsignal (Qerror,
-              list2 (build_string ("Invalid argument list"), args[i]));
+      signal_error ("Invalid argument list", args[i]);
 
   return make_hash_table (test, size, rehash_size, rehash_threshold, weak,
                          user_test, user_hash);
@@ -5486,7 +5431,7 @@ DEFUN ("remhash", Fremhash, Sremhash, 2, 2, 0,
 
 DEFUN ("maphash", Fmaphash, Smaphash, 2, 2, 0,
        doc: /* Call FUNCTION for all entries in hash table TABLE.
-FUNCTION is called with 2 arguments KEY and VALUE.  */)
+FUNCTION is called with two arguments, KEY and VALUE.  */)
      (function, table)
      Lisp_Object function, table;
 {
@@ -5595,8 +5540,7 @@ guesswork fails.  Normally, an error is signaled in such case.  */)
          if (!NILP (noerror))
            coding_system = Qraw_text;
          else
-           while (1)
-             Fsignal (Qcoding_system_error, Fcons (coding_system, Qnil));
+           xsignal1 (Qcoding_system_error, coding_system);
        }
 
       if (STRING_MULTIBYTE (object))
@@ -5730,8 +5674,7 @@ guesswork fails.  Normally, an error is signaled in such case.  */)
              if (!NILP (noerror))
                coding_system = Qraw_text;
              else
-               while (1)
-                 Fsignal (Qcoding_system_error, Fcons (coding_system, Qnil));
+               xsignal1 (Qcoding_system_error, coding_system);
            }
        }
 
@@ -5832,7 +5775,7 @@ syms_of_fns ()
   DEFVAR_LISP ("features", &Vfeatures,
     doc: /* A list of symbols which are the features of the executing emacs.
 Used by `featurep' and `require', and altered by `provide'.  */);
-  Vfeatures = Qnil;
+  Vfeatures = Fcons (intern ("emacs"), Qnil);
   Qsubfeatures = intern ("subfeatures");
   staticpro (&Qsubfeatures);