Make Emacs functions such as Fatom 'static' by default.
[bpt/emacs.git] / src / lread.c
index 66b1a80..7d12f5a 100644 (file)
@@ -1,7 +1,6 @@
 /* Lisp parsing and input streams.
-   Copyright (C) 1985, 1986, 1987, 1988, 1989, 1993, 1994, 1995,
-                 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
-                 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+
+Copyright (C) 1985-1989, 1993-1995, 1997-2011  Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -44,10 +43,7 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #include "msdos.h"
 #endif
 
-#ifdef HAVE_UNISTD_H
 #include <unistd.h>
-#endif
-
 #include <math.h>
 
 #ifdef HAVE_SETLOCALE
@@ -72,11 +68,12 @@ Lisp_Object Qrehash_size;
 Lisp_Object Qrehash_threshold;
 
 Lisp_Object Qread_char, Qget_file_char, Qstandard_input, Qcurrent_load_list;
-Lisp_Object Qvariable_documentation, Vvalues, Vstandard_input, Vafter_load_alist;
+Lisp_Object Qvariable_documentation;
 Lisp_Object Qascii_character, Qload, Qload_file_name;
 Lisp_Object Qbackquote, Qcomma, Qcomma_at, Qcomma_dot, Qfunction;
 Lisp_Object Qinhibit_file_name_operation;
-Lisp_Object Qeval_buffer_list, Veval_buffer_list;
+Lisp_Object Qeval_buffer_list;
+Lisp_Object Qlexical_binding;
 Lisp_Object Qfile_truename, Qdo_after_load_evaluation; /* ACM 2006/5/16 */
 
 /* Used instead of Qget_file_char while loading *.elc files compiled
@@ -85,37 +82,9 @@ static Lisp_Object Qget_emacs_mule_file_char;
 
 static Lisp_Object Qload_force_doc_strings;
 
-/* non-zero if inside `load' */
-int load_in_progress;
-static Lisp_Object Qload_in_progress;
-
-/* Directory in which the sources were found.  */
-Lisp_Object Vsource_directory;
-
-/* Search path and suffixes for files to be loaded. */
-Lisp_Object Vload_path, Vload_suffixes, Vload_file_rep_suffixes;
-
-/* File name of user's init file.  */
-Lisp_Object Vuser_init_file;
-
-/* This is the user-visible association list that maps features to
-   lists of defs in their load files. */
-Lisp_Object Vload_history;
+extern Lisp_Object Qinternal_interpreter_environment;
 
-/* This is used to build the load history. */
-Lisp_Object Vcurrent_load_list;
-
-/* List of files that were preloaded.  */
-Lisp_Object Vpreloaded_file_list;
-
-/* Name of file actually being read by `load'.  */
-Lisp_Object Vload_file_name;
-
-/* Function to use for reading, in `load' and friends.  */
-Lisp_Object Vload_read_function;
-
-/* Non-nil means read recursive structures using #n= and #n# syntax.  */
-Lisp_Object Vread_circle;
+static Lisp_Object Qload_in_progress;
 
 /* The association list of objects read with the #n=object form.
    Each member of the list has the form (n . object), and is used to
@@ -123,31 +92,11 @@ Lisp_Object Vread_circle;
    It must be set to nil before all top-level calls to read0.  */
 Lisp_Object read_objects;
 
-/* Nonzero means load should forcibly load all dynamic doc strings.  */
-static int load_force_doc_strings;
-
-/* Nonzero means read should convert strings to unibyte.  */
-static int load_convert_to_unibyte;
-
 /* Nonzero means READCHAR should read bytes one by one (not character)
    when READCHARFUN is Qget_file_char or Qget_emacs_mule_file_char.
    This is set to 1 by read1 temporarily while handling #@NUMBER.  */
 static int load_each_byte;
 
-/* Function to use for loading an Emacs Lisp source file (not
-   compiled) instead of readevalloop.  */
-Lisp_Object Vload_source_file_function;
-
-/* List of all DEFVAR_BOOL variables.  Used by the byte optimizer.  */
-Lisp_Object Vbyte_boolean_vars;
-
-/* Whether or not to add a `read-positions' property to symbols
-   read. */
-Lisp_Object Vread_with_symbol_positions;
-
-/* List of (SYMBOL . POSITION) accumulated so far. */
-Lisp_Object Vread_symbol_positions_list;
-
 /* List of descriptors now open for Fload.  */
 static Lisp_Object load_descriptor_list;
 
@@ -191,30 +140,17 @@ static file_offset prev_saved_doc_string_position;
    Fread initializes this to zero, so we need not specbind it
    or worry about what happens to it when there is an error.  */
 static int new_backquote_flag;
-static Lisp_Object Vold_style_backquotes, Qold_style_backquotes;
+static Lisp_Object Qold_style_backquotes;
 
 /* A list of file names for files being loaded in Fload.  Used to
    check for recursive loads.  */
 
 static Lisp_Object Vloads_in_progress;
 
-/* Non-zero means load dangerous compiled Lisp files.  */
-
-int load_dangerous_libraries;
-
-/* Non-zero means force printing messages when loading Lisp files.  */
-
-int force_load_messages;
-
-/* A regular expression used to detect files compiled with Emacs.  */
-
-static Lisp_Object Vbytecomp_version_regexp;
-
 static int read_emacs_mule_char (int, int (*) (int, Lisp_Object),
                                  Lisp_Object);
 
-static void readevalloop (Lisp_Object, FILE*, Lisp_Object,
-                          Lisp_Object (*) (Lisp_Object), int,
+static void readevalloop (Lisp_Object, FILE*, Lisp_Object, int,
                           Lisp_Object, Lisp_Object,
                           Lisp_Object, Lisp_Object);
 static Lisp_Object load_unwind (Lisp_Object);
@@ -276,7 +212,7 @@ readchar (Lisp_Object readcharfun, int *multibyte)
       if (pt_byte >= BUF_ZV_BYTE (inbuffer))
        return -1;
 
-      if (! NILP (inbuffer->enable_multibyte_characters))
+      if (! NILP (BVAR (inbuffer, enable_multibyte_characters)))
        {
          /* Fetch the character code from the buffer.  */
          unsigned char *p = BUF_BYTE_ADDRESS (inbuffer, pt_byte);
@@ -305,7 +241,7 @@ readchar (Lisp_Object readcharfun, int *multibyte)
       if (bytepos >= BUF_ZV_BYTE (inbuffer))
        return -1;
 
-      if (! NILP (inbuffer->enable_multibyte_characters))
+      if (! NILP (BVAR (inbuffer, enable_multibyte_characters)))
        {
          /* Fetch the character code from the buffer.  */
          unsigned char *p = BUF_BYTE_ADDRESS (inbuffer, bytepos);
@@ -434,15 +370,15 @@ unreadchar (Lisp_Object readcharfun, int c)
   else if (BUFFERP (readcharfun))
     {
       struct buffer *b = XBUFFER (readcharfun);
+      EMACS_INT charpos = BUF_PT (b);
       EMACS_INT bytepos = BUF_PT_BYTE (b);
 
-      BUF_PT (b)--;
-      if (! NILP (b->enable_multibyte_characters))
+      if (! NILP (BVAR (b, enable_multibyte_characters)))
        BUF_DEC_POS (b, bytepos);
       else
        bytepos--;
 
-      BUF_PT_BYTE (b) = bytepos;
+      SET_BUF_PT_BOTH (b, charpos - 1, bytepos);
     }
   else if (MARKERP (readcharfun))
     {
@@ -450,7 +386,7 @@ unreadchar (Lisp_Object readcharfun, int c)
       EMACS_INT bytepos = XMARKER (readcharfun)->bytepos;
 
       XMARKER (readcharfun)->charpos--;
-      if (! NILP (b->enable_multibyte_characters))
+      if (! NILP (BVAR (b, enable_multibyte_characters)))
        BUF_DEC_POS (b, bytepos);
       else
        bytepos--;
@@ -551,8 +487,6 @@ readbyte_from_string (int c, Lisp_Object readcharfun)
    encoded in `emacs-mule' and the first byte is already read in
    C.  */
 
-extern char emacs_mule_bytes[256];
-
 static int
 read_emacs_mule_char (int c, int (*readbyte) (int, Lisp_Object), Lisp_Object readcharfun)
 {
@@ -583,7 +517,7 @@ read_emacs_mule_char (int c, int (*readbyte) (int, Lisp_Object), Lisp_Object rea
 
   if (len == 2)
     {
-      charset = emacs_mule_charset[buf[0]];
+      charset = CHARSET_FROM_ID (emacs_mule_charset[buf[0]]);
       code = buf[1] & 0x7F;
     }
   else if (len == 3)
@@ -591,18 +525,18 @@ read_emacs_mule_char (int c, int (*readbyte) (int, Lisp_Object), Lisp_Object rea
       if (buf[0] == EMACS_MULE_LEADING_CODE_PRIVATE_11
          || buf[0] == EMACS_MULE_LEADING_CODE_PRIVATE_12)
        {
-         charset = emacs_mule_charset[buf[1]];
+         charset = CHARSET_FROM_ID (emacs_mule_charset[buf[1]]);
          code = buf[2] & 0x7F;
        }
       else
        {
-         charset = emacs_mule_charset[buf[0]];
+         charset = CHARSET_FROM_ID (emacs_mule_charset[buf[0]]);
          code = ((buf[1] << 8) | buf[2]) & 0x7F7F;
        }
     }
   else
     {
-      charset = emacs_mule_charset[buf[1]];
+      charset = CHARSET_FROM_ID (emacs_mule_charset[buf[1]]);
       code = ((buf[2] << 8) | buf[3]) & 0x7F7F;
     }
   c = DECODE_CHAR (charset, code);
@@ -651,7 +585,7 @@ static void substitute_in_interval (INTERVAL, Lisp_Object);
    If SECONDS is a number, we wait that many seconds for input, and
    return Qnil if no input arrives within that time.  */
 
-Lisp_Object
+static Lisp_Object
 read_filtered_event (int no_switch_frame, int ascii_required,
                     int error_nonascii, int input_method, Lisp_Object seconds)
 {
@@ -747,7 +681,7 @@ read_filtered_event (int no_switch_frame, int ascii_required,
   return val;
 }
 
-DEFUN ("read-char", Fread_char, Sread_char, 0, 3, 0,
+DEFUE ("read-char", Fread_char, Sread_char, 0, 3, 0,
        doc: /* Read a character from the command input (keyboard or macro).
 It is returned as a number.
 If the character has modifiers, they are resolved and reflected to the
@@ -780,7 +714,7 @@ floating-point value.  */)
          : make_number (char_resolve_modifier_mask (XINT (val))));
 }
 
-DEFUN ("read-event", Fread_event, Sread_event, 0, 3, 0,
+DEFUE ("read-event", Fread_event, Sread_event, 0, 3, 0,
        doc: /* Read an event object from the input stream.
 If the optional argument PROMPT is non-nil, display that as a prompt.
 If the optional argument INHERIT-INPUT-METHOD is non-nil and some
@@ -837,6 +771,115 @@ DEFUN ("get-file-char", Fget_file_char, Sget_file_char, 0, 0, 0,
 
 
 \f
+
+/* Return true if the lisp code read using READCHARFUN defines a non-nil
+   `lexical-binding' file variable.  After returning, the stream is
+   positioned following the first line, if it is a comment, otherwise
+   nothing is read.  */
+
+static int
+lisp_file_lexically_bound_p (Lisp_Object readcharfun)
+{
+  int ch = READCHAR;
+  if (ch != ';')
+    /* The first line isn't a comment, just give up.  */
+    {
+      UNREAD (ch);
+      return 0;
+    }
+  else
+    /* Look for an appropriate file-variable in the first line.  */
+    {
+      int rv = 0;
+      enum {
+       NOMINAL, AFTER_FIRST_DASH, AFTER_ASTERIX,
+      } beg_end_state = NOMINAL;
+      int in_file_vars = 0;
+
+#define UPDATE_BEG_END_STATE(ch)                               \
+  if (beg_end_state == NOMINAL)                                        \
+    beg_end_state = (ch == '-' ? AFTER_FIRST_DASH : NOMINAL);  \
+  else if (beg_end_state == AFTER_FIRST_DASH)                  \
+    beg_end_state = (ch == '*' ? AFTER_ASTERIX : NOMINAL);     \
+  else if (beg_end_state == AFTER_ASTERIX)                     \
+    {                                                          \
+      if (ch == '-')                                           \
+       in_file_vars = !in_file_vars;                           \
+      beg_end_state = NOMINAL;                                 \
+    }
+
+      /* Skip until we get to the file vars, if any.  */
+      do
+       {
+         ch = READCHAR;
+         UPDATE_BEG_END_STATE (ch);
+       }
+      while (!in_file_vars && ch != '\n' && ch != EOF);
+
+      while (in_file_vars)
+       {
+         char var[100], val[100];
+         unsigned i;
+
+         ch = READCHAR;
+
+         /* Read a variable name.  */
+         while (ch == ' ' || ch == '\t')
+           ch = READCHAR;
+
+         i = 0;
+         while (ch != ':' && ch != '\n' && ch != EOF)
+           {
+             if (i < sizeof var - 1)
+               var[i++] = ch;
+             UPDATE_BEG_END_STATE (ch);
+             ch = READCHAR;
+           }
+
+         while (i > 0 && (var[i - 1] == ' ' || var[i - 1] == '\t'))
+           i--;
+         var[i] = '\0';
+
+         if (ch == ':')
+           {
+             /* Read a variable value.  */
+             ch = READCHAR;
+
+             while (ch == ' ' || ch == '\t')
+               ch = READCHAR;
+
+             i = 0;
+             while (ch != ';' && ch != '\n' && ch != EOF && in_file_vars)
+               {
+                 if (i < sizeof val - 1)
+                   val[i++] = ch;
+                 UPDATE_BEG_END_STATE (ch);
+                 ch = READCHAR;
+               }
+             if (! in_file_vars)
+               /* The value was terminated by an end-marker, which
+                  remove.  */
+               i -= 3;
+             while (i > 0 && (val[i - 1] == ' ' || val[i - 1] == '\t'))
+               i--;
+             val[i] = '\0';
+
+             if (strcmp (var, "lexical-binding") == 0)
+               /* This is it...  */
+               {
+                 rv = (strcmp (val, "nil") != 0);
+                 break;
+               }
+           }
+       }
+
+      while (ch != '\n' && ch != EOF)
+       ch = READCHAR;
+
+      return rv;
+    }
+}
+\f
 /* Value is a version number of byte compiled code if the file
    associated with file descriptor FD is a compiled Lisp file that's
    safe to load.  Only files compiled with Emacs are safe to load.
@@ -864,7 +907,7 @@ safe_to_load_p (int fd)
        if (i == 4)
          version = buf[i];
 
-      if (i == nbytes
+      if (i >= nbytes
          || fast_c_string_match_ignore_case (Vbytecomp_version_regexp,
                                              buf + i) < 0)
        safe_p = 0;
@@ -907,7 +950,7 @@ load_warn_old_style_backquotes (Lisp_Object file)
   return Qnil;
 }
 
-DEFUN ("get-load-suffixes", Fget_load_suffixes, Sget_load_suffixes, 0, 0, 0,
+DEFUE ("get-load-suffixes", Fget_load_suffixes, Sget_load_suffixes, 0, 0, 0,
        doc: /* Return the suffixes that `load' should try if a suffix is \
 required.
 This uses the variables `load-suffixes' and `load-file-rep-suffixes'.  */)
@@ -929,7 +972,7 @@ This uses the variables `load-suffixes' and `load-file-rep-suffixes'.  */)
   return Fnreverse (lst);
 }
 
-DEFUN ("load", Fload, Sload, 1, 5, 0,
+DEFUE ("load", Fload, Sload, 1, 5, 0,
        doc: /* Execute a file of Lisp code named FILE.
 First try FILE with `.elc' appended, then try with `.el',
 then try FILE unmodified (the exact suffixes in the exact order are
@@ -965,6 +1008,10 @@ Loading a file records its definitions, and its `provide' and
 `require' calls, in an element of `load-history' whose
 car is the file name loaded.  See `load-history'.
 
+While the file is in the process of being loaded, the variable
+`load-in-progress' is non-nil and the variable `load-file-name'
+is bound to the file's name.
+
 Return t if the file exists and loads successfully.  */)
   (Lisp_Object file, Lisp_Object noerror, Lisp_Object nomessage, Lisp_Object nosuffix, Lisp_Object must_suffix)
 {
@@ -1027,10 +1074,10 @@ Return t if the file exists and loads successfully.  */)
        {
          /* Don't insist on adding a suffix if FILE already ends with one.  */
          if (size > 3
-             && !strcmp (SDATA (file) + size - 3, ".el"))
+             && !strcmp (SSDATA (file) + size - 3, ".el"))
            must_suffix = Qnil;
          else if (size > 4
-                  && !strcmp (SDATA (file) + size - 4, ".elc"))
+                  && !strcmp (SSDATA (file) + size - 4, ".elc"))
            must_suffix = Qnil;
          /* Don't insist on adding a suffix
             if the argument includes a directory name.  */
@@ -1084,10 +1131,10 @@ Return t if the file exists and loads successfully.  */)
      Also, just loading a file recursively is not always an error in
      the general case; the second load may do something different.  */
   {
-    int count = 0;
+    int load_count = 0;
     Lisp_Object tem;
     for (tem = Vloads_in_progress; CONSP (tem); tem = XCDR (tem))
-      if (!NILP (Fequal (found, XCAR (tem))) && (++count > 3))
+      if (!NILP (Fequal (found, XCAR (tem))) && (++load_count > 3))
        {
          if (fd >= 0)
            emacs_close (fd);
@@ -1097,6 +1144,12 @@ Return t if the file exists and loads successfully.  */)
     Vloads_in_progress = Fcons (found, Vloads_in_progress);
   }
 
+  /* All loads are by default dynamic, unless the file itself specifies
+     otherwise using a file-variable in the first line.  This is bound here
+     so that it takes effect whether or not we use
+     Vload_source_file_function.  */
+  specbind (Qlexical_binding, Qnil);
+
   /* Get the name for load-history. */
   hist_file_name = (! NILP (Vpurify_flag)
                     ? Fconcat (2, (tmp[0] = Ffile_name_directory (file),
@@ -1144,9 +1197,9 @@ Return t if the file exists and loads successfully.  */)
 #ifdef DOS_NT
          fmode = "rb";
 #endif /* DOS_NT */
-         stat ((char *)SDATA (efound), &s1);
+         stat (SSDATA (efound), &s1);
          SSET (efound, SBYTES (efound) - 1, 0);
-         result = stat ((char *)SDATA (efound), &s2);
+         result = stat (SSDATA (efound), &s2);
          SSET (efound, SBYTES (efound) - 1, 'c');
 
          if (result >= 0 && (unsigned) s1.st_mtime < (unsigned) s2.st_mtime)
@@ -1187,7 +1240,7 @@ Return t if the file exists and loads successfully.  */)
 #ifdef WINDOWSNT
   emacs_close (fd);
   efound = ENCODE_FILE (found);
-  stream = fopen ((char *) SDATA (efound), fmode);
+  stream = fopen (SSDATA (efound), fmode);
 #else  /* not WINDOWSNT */
   stream = fdopen (fd, fmode);
 #endif /* not WINDOWSNT */
@@ -1221,15 +1274,20 @@ Return t if the file exists and loads successfully.  */)
   load_descriptor_list
     = Fcons (make_number (fileno (stream)), load_descriptor_list);
   specbind (Qload_in_progress, Qt);
+
+  instream = stream;
+  if (lisp_file_lexically_bound_p (Qget_file_char))
+    Fset (Qlexical_binding, Qt);
+
   if (! version || version >= 22)
     readevalloop (Qget_file_char, stream, hist_file_name,
-                 Feval, 0, Qnil, Qnil, Qnil, Qnil);
+                 0, Qnil, Qnil, Qnil, Qnil);
   else
     {
       /* We can't handle a file which was compiled with
         byte-compile-dynamic by older version of Emacs.  */
       specbind (Qload_force_doc_strings, Qt);
-      readevalloop (Qget_emacs_mule_file_char, stream, hist_file_name, Feval,
+      readevalloop (Qget_emacs_mule_file_char, stream, hist_file_name,
                    0, Qnil, Qnil, Qnil, Qnil);
     }
   unbind_to (count, Qnil);
@@ -1314,7 +1372,9 @@ If SUFFIXES is non-nil, it should be a list of suffixes to append to
 file name when searching.
 If non-nil, PREDICATE is used instead of `file-readable-p'.
 PREDICATE can also be an integer to pass to the access(2) function,
-in which case file-name-handlers are ignored.  */)
+in which case file-name-handlers are ignored.
+This function will normally skip directories, so if you want it to find
+directories, make sure the PREDICATE function returns `dir-ok' for them.  */)
   (Lisp_Object filename, Lisp_Object path, Lisp_Object suffixes, Lisp_Object predicate)
 {
   Lisp_Object file;
@@ -1324,6 +1384,7 @@ in which case file-name-handlers are ignored.  */)
   return file;
 }
 
+static Lisp_Object Qdir_ok;
 
 /* Search for a file whose name is STR, looking in directories
    in the Lisp list PATH, and trying suffixes from SUFFIX.
@@ -1386,7 +1447,7 @@ openp (Lisp_Object path, Lisp_Object str, Lisp_Object suffixes, Lisp_Object *sto
        /* Of course, this could conceivably lose if luser sets
           default-directory to be something non-absolute... */
        {
-         filename = Fexpand_file_name (filename, current_buffer->directory);
+         filename = Fexpand_file_name (filename, BVAR (current_buffer, directory));
          if (!complete_filename_p (filename))
            /* Give up on this path element! */
            continue;
@@ -1412,19 +1473,19 @@ openp (Lisp_Object path, Lisp_Object str, Lisp_Object suffixes, Lisp_Object *sto
              && SREF (filename, 0) == '/'
              && SREF (filename, 1) == ':')
            {
-             strncpy (fn, SDATA (filename) + 2,
+             strncpy (fn, SSDATA (filename) + 2,
                       SBYTES (filename) - 2);
              fn[SBYTES (filename) - 2] = 0;
            }
          else
            {
-             strncpy (fn, SDATA (filename),
+             strncpy (fn, SSDATA (filename),
                       SBYTES (filename));
              fn[SBYTES (filename)] = 0;
            }
 
          if (lsuffix != 0)  /* Bug happens on CCI if lsuffix is 0.  */
-           strncat (fn, SDATA (XCAR (tail)), lsuffix);
+           strncat (fn, SSDATA (XCAR (tail)), lsuffix);
 
          /* Check that the file exists and is not a directory.  */
          /* We used to only check for handlers on non-absolute file names:
@@ -1441,9 +1502,12 @@ openp (Lisp_Object path, Lisp_Object str, Lisp_Object suffixes, Lisp_Object *sto
              if (NILP (predicate))
                exists = !NILP (Ffile_readable_p (string));
              else
-               exists = !NILP (call1 (predicate, string));
-             if (exists && !NILP (Ffile_directory_p (string)))
-               exists = 0;
+               {
+                 Lisp_Object tmp = call1 (predicate, string);
+                 exists = !NILP (tmp)
+                   && (EQ (tmp, Qdir_ok)
+                       || NILP (Ffile_directory_p (string)));
+               }
 
              if (exists)
                {
@@ -1459,9 +1523,8 @@ openp (Lisp_Object path, Lisp_Object str, Lisp_Object suffixes, Lisp_Object *sto
              const char *pfn;
 
              encoded_fn = ENCODE_FILE (string);
-             pfn = SDATA (encoded_fn);
-             exists = (stat (pfn, &st) >= 0
-                       && (st.st_mode & S_IFMT) != S_IFDIR);
+             pfn = SSDATA (encoded_fn);
+             exists = (stat (pfn, &st) == 0 && ! S_ISDIR (st.st_mode));
              if (exists)
                {
                  /* Check that we can access or open it.  */
@@ -1594,7 +1657,6 @@ static void
 readevalloop (Lisp_Object readcharfun,
              FILE *stream,
              Lisp_Object sourcename,
-             Lisp_Object (*evalfun) (Lisp_Object),
              int printflag,
              Lisp_Object unibyte, Lisp_Object readfun,
              Lisp_Object start, Lisp_Object end)
@@ -1605,6 +1667,7 @@ readevalloop (Lisp_Object readcharfun,
   struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
   struct buffer *b = 0;
   int continue_reading_p;
+  Lisp_Object lex_bound;
   /* Nonzero if reading an entire buffer.  */
   int whole_buffer = 0;
   /* 1 on the first time around.  */
@@ -1630,6 +1693,14 @@ readevalloop (Lisp_Object readcharfun,
   record_unwind_protect (readevalloop_1, load_convert_to_unibyte ? Qt : Qnil);
   load_convert_to_unibyte = !NILP (unibyte);
 
+  /* If lexical binding is active (either because it was specified in
+     the file's header, or via a buffer-local variable), create an empty
+     lexical environment, otherwise, turn off lexical binding.  */
+  lex_bound = find_symbol_value (Qlexical_binding);
+  specbind (Qinternal_interpreter_environment,
+           NILP (lex_bound) || EQ (lex_bound, Qunbound)
+           ? Qnil : Fcons (Qt, Qnil));
+
   GCPRO4 (sourcename, readfun, start, end);
 
   /* Try to ensure sourcename is a truename, except whilst preloading. */
@@ -1645,7 +1716,7 @@ readevalloop (Lisp_Object readcharfun,
     {
       int count1 = SPECPDL_INDEX ();
 
-      if (b != 0 && NILP (b->name))
+      if (b != 0 && NILP (BVAR (b, name)))
        error ("Reading from killed buffer");
 
       if (!NILP (start))
@@ -1713,8 +1784,8 @@ readevalloop (Lisp_Object readcharfun,
                 to a different value when evaluated.  */
              if (BUFFERP (readcharfun))
                {
-                 struct buffer *b = XBUFFER (readcharfun);
-                 if (BUF_PT (b) == BUF_ZV (b))
+                 struct buffer *buf = XBUFFER (readcharfun);
+                 if (BUF_PT (buf) == BUF_ZV (buf))
                    continue_reading_p = 0;
                }
            }
@@ -1731,7 +1802,7 @@ readevalloop (Lisp_Object readcharfun,
       unbind_to (count1, Qnil);
 
       /* Now eval what we just read.  */
-      val = (*evalfun) (val);
+      val = eval_sub (val);
 
       if (printflag)
        {
@@ -1785,13 +1856,14 @@ This function preserves the position of point.  */)
     tem = printflag;
 
   if (NILP (filename))
-    filename = XBUFFER (buf)->filename;
+    filename = BVAR (XBUFFER (buf), filename);
 
   specbind (Qeval_buffer_list, Fcons (buf, Veval_buffer_list));
   specbind (Qstandard_output, tem);
   record_unwind_protect (save_excursion_restore, save_excursion_save ());
   BUF_TEMP_SET_PT (XBUFFER (buf), BUF_BEGV (XBUFFER (buf)));
-  readevalloop (buf, 0, filename, Feval,
+  specbind (Qlexical_binding, lisp_file_lexically_bound_p (buf) ? Qt : Qnil);
+  readevalloop (buf, 0, filename,
                !NILP (printflag), unibyte, Qnil, Qnil, Qnil);
   unbind_to (count, Qnil);
 
@@ -1812,6 +1884,7 @@ which is the input stream for reading characters.
 This function does not move point.  */)
   (Lisp_Object start, Lisp_Object end, Lisp_Object printflag, Lisp_Object read_function)
 {
+  /* FIXME: Do the eval-sexp-add-defvars danse!  */
   int count = SPECPDL_INDEX ();
   Lisp_Object tem, cbuf;
 
@@ -1825,7 +1898,7 @@ This function does not move point.  */)
   specbind (Qeval_buffer_list, Fcons (cbuf, Veval_buffer_list));
 
   /* readevalloop calls functions which check the type of start and end.  */
-  readevalloop (cbuf, 0, XBUFFER (cbuf)->filename, Feval,
+  readevalloop (cbuf, 0, BVAR (XBUFFER (cbuf), filename),
                !NILP (printflag), Qnil, read_function,
                start, end);
 
@@ -1833,7 +1906,7 @@ This function does not move point.  */)
 }
 
 \f
-DEFUN ("read", Fread, Sread, 0, 1, 0,
+DEFUE ("read", Fread, Sread, 0, 1, 0,
        doc: /* Read one Lisp expression as text from STREAM, return as Lisp object.
 If STREAM is nil, use the value of `standard-input' (which see).
 STREAM or the value of `standard-input' may be:
@@ -1856,7 +1929,7 @@ STREAM or the value of `standard-input' may be:
   return read_internal_start (stream, Qnil, Qnil);
 }
 
-DEFUN ("read-from-string", Fread_from_string, Sread_from_string, 1, 3, 0,
+DEFUE ("read-from-string", Fread_from_string, Sread_from_string, 1, 3, 0,
        doc: /* Read one Lisp expression which is represented as text by STRING.
 Returns a cons: (OBJECT-READ . FINAL-STRING-INDEX).
 START and END optionally delimit a substring of STRING from which to read;
@@ -2246,7 +2319,7 @@ static Lisp_Object
 read1 (register Lisp_Object readcharfun, int *pch, int first_in_list)
 {
   register int c;
-  int uninterned_symbol = 0;
+  unsigned uninterned_symbol = 0;
   int multibyte;
 
   *pch = 0;
@@ -2634,7 +2707,7 @@ read1 (register Lisp_Object readcharfun, int *pch, int first_in_list)
           old-style.  For Emacs-25, we should completely remove this
           first_in_list exception (old-style can still be obtained via
           "(\`" anyway).  */
-       if (first_in_list && next_char == ' ')
+       if (!new_backquote_flag && first_in_list && next_char == ' ')
          {
            Vold_style_backquotes = Qt;
            goto default_label;
@@ -2651,33 +2724,48 @@ read1 (register Lisp_Object readcharfun, int *pch, int first_in_list)
          }
       }
     case ',':
-      if (new_backquote_flag)
-       {
-         Lisp_Object comma_type = Qnil;
-         Lisp_Object value;
-         int ch = READCHAR;
-
-         if (ch == '@')
-           comma_type = Qcomma_at;
-         else if (ch == '.')
-           comma_type = Qcomma_dot;
-         else
-           {
-             if (ch >= 0) UNREAD (ch);
-             comma_type = Qcomma;
-           }
+      {
+       int next_char = READCHAR;
+       UNREAD (next_char);
+       /* Transition from old-style to new-style:
+           It used to be impossible to have a new-style , other than within
+          a new-style `.  This is sufficient when ` and , are used in the
+          normal way, but ` and , can also appear in args to macros that
+          will not interpret them in the usual way, in which case , may be
+          used without any ` anywhere near.
+          So we now use the same heuristic as for backquote: old-style
+          unquotes are only recognized when first on a list, and when
+          followed by a space.
+          Because it's more difficult to peak 2 chars ahead, a new-style
+          ,@ can still not be used outside of a `, unless it's in the middle
+          of a list.  */
+       if (new_backquote_flag
+           || !first_in_list
+           || (next_char != ' ' && next_char != '@'))
+         {
+           Lisp_Object comma_type = Qnil;
+           Lisp_Object value;
+           int ch = READCHAR;
 
-         new_backquote_flag--;
-         value = read0 (readcharfun);
-         new_backquote_flag++;
-         return Fcons (comma_type, Fcons (value, Qnil));
-       }
-      else
-       {
-         Vold_style_backquotes = Qt;
-         goto default_label;
-       }
+           if (ch == '@')
+             comma_type = Qcomma_at;
+           else if (ch == '.')
+             comma_type = Qcomma_dot;
+           else
+             {
+               if (ch >= 0) UNREAD (ch);
+               comma_type = Qcomma;
+             }
 
+           value = read0 (readcharfun);
+           return Fcons (comma_type, Fcons (value, Qnil));
+         }
+       else
+         {
+           Vold_style_backquotes = Qt;
+           goto default_label;
+         }
+      }
     case '?':
       {
        int modifiers;
@@ -2704,26 +2792,9 @@ read1 (register Lisp_Object readcharfun, int *pch, int first_in_list)
        c |= modifiers;
 
        next_char = READCHAR;
-       if (next_char == '.')
-         {
-           /* Only a dotted-pair dot is valid after a char constant.  */
-           int next_next_char = READCHAR;
-           UNREAD (next_next_char);
-
-           ok = (next_next_char <= 040
-                 || (next_next_char < 0200
-                     && (strchr ("\"';([#?", next_next_char)
-                         || (!first_in_list && next_next_char == '`')
-                         || (new_backquote_flag && next_next_char == ','))));
-         }
-       else
-         {
-           ok = (next_char <= 040
-                 || (next_char < 0200
-                     && (strchr ("\"';()[]#?", next_char)
-                         || (!first_in_list && next_char == '`')
-                         || (new_backquote_flag && next_char == ','))));
-         }
+       ok = (next_char <= 040
+             || (next_char < 0200
+                 && (strchr ("\"';()[]#?`,.", next_char))));
        UNREAD (next_char);
        if (ok)
          return make_number (c);
@@ -2735,7 +2806,7 @@ read1 (register Lisp_Object readcharfun, int *pch, int first_in_list)
       {
        char *p = read_buffer;
        char *end = read_buffer + read_buffer_size;
-       register int c;
+       register int ch;
        /* Nonzero if we saw an escape sequence specifying
           a multibyte character.  */
        int force_multibyte = 0;
@@ -2745,8 +2816,8 @@ read1 (register Lisp_Object readcharfun, int *pch, int first_in_list)
        int cancel = 0;
        int nchars = 0;
 
-       while ((c = READCHAR) >= 0
-              && c != '\"')
+       while ((ch = READCHAR) >= 0
+              && ch != '\"')
          {
            if (end - p < MAX_MULTIBYTE_LENGTH)
              {
@@ -2757,44 +2828,44 @@ read1 (register Lisp_Object readcharfun, int *pch, int first_in_list)
                end = read_buffer + read_buffer_size;
              }
 
-           if (c == '\\')
+           if (ch == '\\')
              {
                int modifiers;
 
-               c = read_escape (readcharfun, 1);
+               ch = read_escape (readcharfun, 1);
 
-               /* C is -1 if \ newline has just been seen */
-               if (c == -1)
+               /* CH is -1 if \ newline has just been seen */
+               if (ch == -1)
                  {
                    if (p == read_buffer)
                      cancel = 1;
                    continue;
                  }
 
-               modifiers = c & CHAR_MODIFIER_MASK;
-               c = c & ~CHAR_MODIFIER_MASK;
+               modifiers = ch & CHAR_MODIFIER_MASK;
+               ch = ch & ~CHAR_MODIFIER_MASK;
 
-               if (CHAR_BYTE8_P (c))
+               if (CHAR_BYTE8_P (ch))
                  force_singlebyte = 1;
-               else if (! ASCII_CHAR_P (c))
+               else if (! ASCII_CHAR_P (ch))
                  force_multibyte = 1;
-               else            /* i.e. ASCII_CHAR_P (c) */
+               else            /* i.e. ASCII_CHAR_P (ch) */
                  {
                    /* Allow `\C- ' and `\C-?'.  */
                    if (modifiers == CHAR_CTL)
                      {
-                       if (c == ' ')
-                         c = 0, modifiers = 0;
-                       else if (c == '?')
-                         c = 127, modifiers = 0;
+                       if (ch == ' ')
+                         ch = 0, modifiers = 0;
+                       else if (ch == '?')
+                         ch = 127, modifiers = 0;
                      }
                    if (modifiers & CHAR_SHIFT)
                      {
                        /* Shift modifier is valid only with [A-Za-z].  */
-                       if (c >= 'A' && c <= 'Z')
+                       if (ch >= 'A' && ch <= 'Z')
                          modifiers &= ~CHAR_SHIFT;
-                       else if (c >= 'a' && c <= 'z')
-                         c -= ('a' - 'A'), modifiers &= ~CHAR_SHIFT;
+                       else if (ch >= 'a' && ch <= 'z')
+                         ch -= ('a' - 'A'), modifiers &= ~CHAR_SHIFT;
                      }
 
                    if (modifiers & CHAR_META)
@@ -2802,7 +2873,7 @@ read1 (register Lisp_Object readcharfun, int *pch, int first_in_list)
                        /* Move the meta bit to the right place for a
                           string.  */
                        modifiers &= ~CHAR_META;
-                       c = BYTE8_TO_CHAR (c | 0x80);
+                       ch = BYTE8_TO_CHAR (ch | 0x80);
                        force_singlebyte = 1;
                      }
                  }
@@ -2810,20 +2881,20 @@ read1 (register Lisp_Object readcharfun, int *pch, int first_in_list)
                /* Any modifiers remaining are invalid.  */
                if (modifiers)
                  error ("Invalid modifier in string");
-               p += CHAR_STRING (c, (unsigned char *) p);
+               p += CHAR_STRING (ch, (unsigned char *) p);
              }
            else
              {
-               p += CHAR_STRING (c, (unsigned char *) p);
-               if (CHAR_BYTE8_P (c))
+               p += CHAR_STRING (ch, (unsigned char *) p);
+               if (CHAR_BYTE8_P (ch))
                  force_singlebyte = 1;
-               else if (! ASCII_CHAR_P (c))
+               else if (! ASCII_CHAR_P (ch))
                  force_multibyte = 1;
              }
            nchars++;
          }
 
-       if (c < 0)
+       if (ch < 0)
          end_of_file_error ();
 
        /* If purifying, and string starts with \ newline,
@@ -2837,12 +2908,14 @@ read1 (register Lisp_Object readcharfun, int *pch, int first_in_list)
          ;
        else if (force_singlebyte)
          {
-           nchars = str_as_unibyte (read_buffer, p - read_buffer);
+           nchars = str_as_unibyte ((unsigned char *) read_buffer,
+                                    p - read_buffer);
            p = read_buffer + nchars;
          }
        else
-         /* Otherwise, READ_BUFFER contains only ASCII.  */
-         ;
+         {
+           /* Otherwise, READ_BUFFER contains only ASCII.  */
+         }
 
        /* We want readchar_count to be the number of characters, not
           bytes.  Hence we adjust for multibyte characters in the
@@ -2865,9 +2938,7 @@ read1 (register Lisp_Object readcharfun, int *pch, int first_in_list)
 
        if (next_char <= 040
            || (next_char < 0200
-               && (strchr ("\"';([#?", next_char)
-                   || (!first_in_list && next_char == '`')
-                   || (new_backquote_flag && next_char == ','))))
+               && (strchr ("\"';([#?`,", next_char))))
          {
            *pch = c;
            return Qnil;
@@ -2889,12 +2960,7 @@ read1 (register Lisp_Object readcharfun, int *pch, int first_in_list)
        {
          char *end = read_buffer + read_buffer_size;
 
-         while (c > 040
-                && c != 0x8a0 /* NBSP */
-                && (c >= 0200
-                    || (!strchr ("\"';()[]#", c)
-                        && !(!first_in_list && c == '`')
-                        && !(new_backquote_flag && c == ','))))
+         do
            {
              if (end - p < MAX_MULTIBYTE_LENGTH)
                {
@@ -2914,11 +2980,14 @@ read1 (register Lisp_Object readcharfun, int *pch, int first_in_list)
                }
 
              if (multibyte)
-               p += CHAR_STRING (c, p);
+               p += CHAR_STRING (c, (unsigned char *) p);
              else
                *p++ = c;
              c = READCHAR;
-           }
+           } while (c > 040
+                    && c != 0x8a0 /* NBSP */
+                    && (c >= 0200
+                        || !(strchr ("\"';()[]#`,", c))));
 
          if (p == end)
            {
@@ -3020,7 +3089,9 @@ read1 (register Lisp_Object readcharfun, int *pch, int first_in_list)
          Lisp_Object name, result;
          EMACS_INT nbytes = p - read_buffer;
          EMACS_INT nchars
-           = (multibyte ? multibyte_chars_in_text (read_buffer, nbytes)
+           = (multibyte
+              ? multibyte_chars_in_text ((unsigned char *) read_buffer,
+                                         nbytes)
               : nbytes);
 
          if (uninterned_symbol && ! NILP (Vpurify_flag))
@@ -3506,14 +3577,13 @@ read_list (int flag, register Lisp_Object readcharfun)
     }
 }
 \f
-Lisp_Object Vobarray;
 Lisp_Object initial_obarray;
 
 /* oblookup stores the bucket number here, for the sake of Funintern.  */
 
 int oblookup_last_bucket_number;
 
-static int hash_string (const unsigned char *ptr, int len);
+static int hash_string (const char *ptr, int len);
 
 /* Get an error if OBARRAY is not an obarray.
    If it is one, return it.  */
@@ -3584,7 +3654,7 @@ make_symbol (const char *str)
                       : make_string (str, len));
 }
 \f
-DEFUN ("intern", Fintern, Sintern, 1, 2, 0,
+DEFUE ("intern", Fintern, Sintern, 1, 2, 0,
        doc: /* Return the canonical symbol whose name is STRING.
 If there is none, one is created by this function and returned.
 A second optional argument specifies the obarray to use;
@@ -3598,7 +3668,7 @@ it defaults to the value of `obarray'.  */)
 
   CHECK_STRING (string);
 
-  tem = oblookup (obarray, SDATA (string),
+  tem = oblookup (obarray, SSDATA (string),
                  SCHARS (string),
                  SBYTES (string));
   if (!INTEGERP (tem))
@@ -3630,7 +3700,7 @@ it defaults to the value of `obarray'.  */)
   return sym;
 }
 
-DEFUN ("intern-soft", Fintern_soft, Sintern_soft, 1, 2, 0,
+DEFUE ("intern-soft", Fintern_soft, Sintern_soft, 1, 2, 0,
        doc: /* Return the canonical symbol named NAME, or nil if none exists.
 NAME may be a string or a symbol.  If it is a symbol, that exact
 symbol is searched for.
@@ -3651,14 +3721,14 @@ it defaults to the value of `obarray'.  */)
   else
     string = SYMBOL_NAME (name);
 
-  tem = oblookup (obarray, SDATA (string), SCHARS (string), SBYTES (string));
+  tem = oblookup (obarray, SSDATA (string), SCHARS (string), SBYTES (string));
   if (INTEGERP (tem) || (SYMBOLP (name) && !EQ (name, tem)))
     return Qnil;
   else
     return tem;
 }
 \f
-DEFUN ("unintern", Funintern, Sunintern, 1, 2, 0,
+DEFUE ("unintern", Funintern, Sunintern, 1, 2, 0,
        doc: /* Delete the symbol named NAME, if any, from OBARRAY.
 The value is t if a symbol was found and deleted, nil otherwise.
 NAME may be a string or a symbol.  If it is a symbol, that symbol
@@ -3680,7 +3750,7 @@ OBARRAY defaults to the value of the variable `obarray'.  */)
       string = name;
     }
 
-  tem = oblookup (obarray, SDATA (string),
+  tem = oblookup (obarray, SSDATA (string),
                  SCHARS (string),
                  SBYTES (string));
   if (INTEGERP (tem))
@@ -3771,10 +3841,10 @@ oblookup (Lisp_Object obarray, register const char *ptr, EMACS_INT size, EMACS_I
 }
 
 static int
-hash_string (const unsigned char *ptr, int len)
+hash_string (const char *ptr, int len)
 {
-  register const unsigned char *p = ptr;
-  register const unsigned char *end = p + len;
+  register const char *p = ptr;
+  register const char *end = p + len;
   register unsigned char c;
   register int hash = 0;
 
@@ -3889,9 +3959,9 @@ defalias (sname, string)
 }
 #endif /* NOTDEF */
 
-/* Define an "integer variable"; a symbol whose value is forwarded
-   to a C variable of type int.  Sample call:
-   DEFVAR_INT ("emacs-priority", &emacs_priority, "Documentation");  */
+/* Define an "integer variable"; a symbol whose value is forwarded to a
+   C variable of type int.  Sample call (munged w "xx" to fool make-docfile):
+   DEFxxVAR_INT ("emacs-priority", &emacs_priority, "Documentation");  */
 void
 defvar_int (struct Lisp_Intfwd *i_fwd,
            const char *namestring, EMACS_INT *address)
@@ -3900,6 +3970,7 @@ defvar_int (struct Lisp_Intfwd *i_fwd,
   sym = intern_c_string (namestring);
   i_fwd->type = Lisp_Fwd_Int;
   i_fwd->intvar = address;
+  XSYMBOL (sym)->declared_special = 1;
   XSYMBOL (sym)->redirect = SYMBOL_FORWARDED;
   SET_SYMBOL_FWD (XSYMBOL (sym), (union Lisp_Fwd *)i_fwd);
 }
@@ -3914,6 +3985,7 @@ defvar_bool (struct Lisp_Boolfwd *b_fwd,
   sym = intern_c_string (namestring);
   b_fwd->type = Lisp_Fwd_Bool;
   b_fwd->boolvar = address;
+  XSYMBOL (sym)->declared_special = 1;
   XSYMBOL (sym)->redirect = SYMBOL_FORWARDED;
   SET_SYMBOL_FWD (XSYMBOL (sym), (union Lisp_Fwd *)b_fwd);
   Vbyte_boolean_vars = Fcons (sym, Vbyte_boolean_vars);
@@ -3932,6 +4004,7 @@ defvar_lisp_nopro (struct Lisp_Objfwd *o_fwd,
   sym = intern_c_string (namestring);
   o_fwd->type = Lisp_Fwd_Obj;
   o_fwd->objvar = address;
+  XSYMBOL (sym)->declared_special = 1;
   XSYMBOL (sym)->redirect = SYMBOL_FORWARDED;
   SET_SYMBOL_FWD (XSYMBOL (sym), (union Lisp_Fwd *)o_fwd);
 }
@@ -3955,6 +4028,7 @@ defvar_kboard (struct Lisp_Kboard_Objfwd *ko_fwd,
   sym = intern_c_string (namestring);
   ko_fwd->type = Lisp_Fwd_Kboard_Obj;
   ko_fwd->offset = offset;
+  XSYMBOL (sym)->declared_special = 1;
   XSYMBOL (sym)->redirect = SYMBOL_FORWARDED;
   SET_SYMBOL_FWD (XSYMBOL (sym), (union Lisp_Fwd *)ko_fwd);
 }
@@ -4089,7 +4163,7 @@ init_lread (void)
                        Vload_path = Fcons (tem, Vload_path);
                    }
                }
-             if (!NILP (sitelisp))
+             if (!NILP (sitelisp) && !no_site_lisp)
                Vload_path = nconc2 (Fnreverse (sitelisp), Vload_path);
            }
        }
@@ -4126,7 +4200,7 @@ init_lread (void)
          if (STRINGP (dirfile))
            {
              dirfile = Fdirectory_file_name (dirfile);
-             if (access (SDATA (dirfile), 0) < 0)
+             if (access (SSDATA (dirfile), 0) < 0)
                dir_warning ("Warning: Lisp directory `%s' does not exist.\n",
                             XCAR (path_tail));
            }
@@ -4188,22 +4262,22 @@ syms_of_lread (void)
   defsubr (&Smapatoms);
   defsubr (&Slocate_file_internal);
 
-  DEFVAR_LISP ("obarray", &Vobarray,
+  DEFVAR_LISP ("obarray", Vobarray,
               doc: /* Symbol table for use by `intern' and `read'.
 It is a vector whose length ought to be prime for best results.
 The vector's contents don't make sense if examined from Lisp programs;
 to find all the symbols in an obarray, use `mapatoms'.  */);
 
-  DEFVAR_LISP ("values", &Vvalues,
+  DEFVAR_LISP ("values", Vvalues,
               doc: /* List of values of all expressions which were read, evaluated and printed.
 Order is reverse chronological.  */);
 
-  DEFVAR_LISP ("standard-input", &Vstandard_input,
+  DEFVAR_LISP ("standard-input", Vstandard_input,
               doc: /* Stream for read to get input from.
 See documentation of `read' for possible values.  */);
   Vstandard_input = Qt;
 
-  DEFVAR_LISP ("read-with-symbol-positions", &Vread_with_symbol_positions,
+  DEFVAR_LISP ("read-with-symbol-positions", Vread_with_symbol_positions,
               doc: /* If non-nil, add position of read symbols to `read-symbol-positions-list'.
 
 If this variable is a buffer, then only forms read from that buffer
@@ -4217,7 +4291,7 @@ The positions are relative to the last call to `read' or
 the toplevel; bind it instead. */);
   Vread_with_symbol_positions = Qnil;
 
-  DEFVAR_LISP ("read-symbol-positions-list", &Vread_symbol_positions_list,
+  DEFVAR_LISP ("read-symbol-positions-list", Vread_symbol_positions_list,
               doc: /* A list mapping read symbols to their positions.
 This variable is modified during calls to `read' or
 `read-from-string', but only when `read-with-symbol-positions' is
@@ -4232,24 +4306,24 @@ read multiple times.  The list is in the same order as the symbols
 were read in. */);
   Vread_symbol_positions_list = Qnil;
 
-  DEFVAR_LISP ("read-circle", &Vread_circle,
+  DEFVAR_LISP ("read-circle", Vread_circle,
               doc: /* Non-nil means read recursive structures using #N= and #N# syntax.  */);
   Vread_circle = Qt;
 
-  DEFVAR_LISP ("load-path", &Vload_path,
+  DEFVAR_LISP ("load-path", Vload_path,
               doc: /* *List of directories to search for files to load.
 Each element is a string (directory name) or nil (try default directory).
 Initialized based on EMACSLOADPATH environment variable, if any,
 otherwise to default specified by file `epaths.h' when Emacs was built.  */);
 
-  DEFVAR_LISP ("load-suffixes", &Vload_suffixes,
+  DEFVAR_LISP ("load-suffixes", Vload_suffixes,
               doc: /* List of suffixes for (compiled or source) Emacs Lisp files.
 This list should not include the empty string.
 `load' and related functions try to append these suffixes, in order,
 to the specified file name if a Lisp suffix is allowed or required.  */);
   Vload_suffixes = Fcons (make_pure_c_string (".elc"),
                          Fcons (make_pure_c_string (".el"), Qnil));
-  DEFVAR_LISP ("load-file-rep-suffixes", &Vload_file_rep_suffixes,
+  DEFVAR_LISP ("load-file-rep-suffixes", Vload_file_rep_suffixes,
               doc: /* List of suffixes that indicate representations of \
 the same file.
 This list should normally start with the empty string.
@@ -4264,12 +4338,12 @@ the loading functions recognize as compression suffixes, you should
 customize `jka-compr-load-suffixes' rather than the present variable.  */);
   Vload_file_rep_suffixes = Fcons (empty_unibyte_string, Qnil);
 
-  DEFVAR_BOOL ("load-in-progress", &load_in_progress,
+  DEFVAR_BOOL ("load-in-progress", load_in_progress,
               doc: /* Non-nil if inside of `load'.  */);
   Qload_in_progress = intern_c_string ("load-in-progress");
   staticpro (&Qload_in_progress);
 
-  DEFVAR_LISP ("after-load-alist", &Vafter_load_alist,
+  DEFVAR_LISP ("after-load-alist", Vafter_load_alist,
               doc: /* An alist of expressions to be evalled when particular files are loaded.
 Each element looks like (REGEXP-OR-FEATURE FORMS...).
 
@@ -4284,7 +4358,7 @@ An error in FORMS does not undo the load, but does prevent execution of
 the rest of the FORMS.  */);
   Vafter_load_alist = Qnil;
 
-  DEFVAR_LISP ("load-history", &Vload_history,
+  DEFVAR_LISP ("load-history", Vload_history,
               doc: /* Alist mapping loaded file names to symbols and features.
 Each alist element should be a list (FILE-NAME ENTRIES...), where
 FILE-NAME is the name of a file that has been loaded into Emacs.
@@ -4304,11 +4378,11 @@ During preloading, the file name recorded is relative to the main Lisp
 directory.  These file names are converted to absolute at startup.  */);
   Vload_history = Qnil;
 
-  DEFVAR_LISP ("load-file-name", &Vload_file_name,
+  DEFVAR_LISP ("load-file-name", Vload_file_name,
               doc: /* Full name of file being loaded by `load'.  */);
   Vload_file_name = Qnil;
 
-  DEFVAR_LISP ("user-init-file", &Vuser_init_file,
+  DEFVAR_LISP ("user-init-file", Vuser_init_file,
               doc: /* File name, including directory, of user's initialization file.
 If the file loaded had extension `.elc', and the corresponding source file
 exists, this variable contains the name of source file, suitable for use
@@ -4317,16 +4391,16 @@ While Emacs loads and evaluates the init file, value is the real name
 of the file, regardless of whether or not it has the `.elc' extension.  */);
   Vuser_init_file = Qnil;
 
-  DEFVAR_LISP ("current-load-list", &Vcurrent_load_list,
+  DEFVAR_LISP ("current-load-list", Vcurrent_load_list,
               doc: /* Used for internal purposes by `load'.  */);
   Vcurrent_load_list = Qnil;
 
-  DEFVAR_LISP ("load-read-function", &Vload_read_function,
+  DEFVAR_LISP ("load-read-function", Vload_read_function,
               doc: /* Function used by `load' and `eval-region' for reading expressions.
 The default is nil, which means use the function `read'.  */);
   Vload_read_function = Qnil;
 
-  DEFVAR_LISP ("load-source-file-function", &Vload_source_file_function,
+  DEFVAR_LISP ("load-source-file-function", Vload_source_file_function,
               doc: /* Function called in `load' for loading an Emacs Lisp source file.
 This function is for doing code conversion before reading the source file.
 If nil, loading is done without any code conversion.
@@ -4335,45 +4409,45 @@ Arguments are FULLNAME, FILE, NOERROR, NOMESSAGE, where
 See `load' for the meaning of the remaining arguments.  */);
   Vload_source_file_function = Qnil;
 
-  DEFVAR_BOOL ("load-force-doc-strings", &load_force_doc_strings,
+  DEFVAR_BOOL ("load-force-doc-strings", load_force_doc_strings,
               doc: /* Non-nil means `load' should force-load all dynamic doc strings.
 This is useful when the file being loaded is a temporary copy.  */);
   load_force_doc_strings = 0;
 
-  DEFVAR_BOOL ("load-convert-to-unibyte", &load_convert_to_unibyte,
+  DEFVAR_BOOL ("load-convert-to-unibyte", load_convert_to_unibyte,
               doc: /* Non-nil means `read' converts strings to unibyte whenever possible.
 This is normally bound by `load' and `eval-buffer' to control `read',
 and is not meant for users to change.  */);
   load_convert_to_unibyte = 0;
 
-  DEFVAR_LISP ("source-directory", &Vsource_directory,
+  DEFVAR_LISP ("source-directory", Vsource_directory,
               doc: /* Directory in which Emacs sources were found when Emacs was built.
 You cannot count on them to still be there!  */);
   Vsource_directory
     = Fexpand_file_name (build_string ("../"),
                         Fcar (decode_env_path (0, PATH_DUMPLOADSEARCH)));
 
-  DEFVAR_LISP ("preloaded-file-list", &Vpreloaded_file_list,
+  DEFVAR_LISP ("preloaded-file-list", Vpreloaded_file_list,
               doc: /* List of files that were preloaded (when dumping Emacs).  */);
   Vpreloaded_file_list = Qnil;
 
-  DEFVAR_LISP ("byte-boolean-vars", &Vbyte_boolean_vars,
+  DEFVAR_LISP ("byte-boolean-vars", Vbyte_boolean_vars,
               doc: /* List of all DEFVAR_BOOL variables, used by the byte code optimizer.  */);
   Vbyte_boolean_vars = Qnil;
 
-  DEFVAR_BOOL ("load-dangerous-libraries", &load_dangerous_libraries,
+  DEFVAR_BOOL ("load-dangerous-libraries", load_dangerous_libraries,
               doc: /* Non-nil means load dangerous compiled Lisp files.
 Some versions of XEmacs use different byte codes than Emacs.  These
 incompatible byte codes can make Emacs crash when it tries to execute
 them.  */);
   load_dangerous_libraries = 0;
 
-  DEFVAR_BOOL ("force-load-messages", &force_load_messages,
+  DEFVAR_BOOL ("force-load-messages", force_load_messages,
               doc: /* Non-nil means force printing messages when loading Lisp files.
 This overrides the value of the NOMESSAGE argument to `load'.  */);
   force_load_messages = 0;
 
-  DEFVAR_LISP ("bytecomp-version-regexp", &Vbytecomp_version_regexp,
+  DEFVAR_LISP ("bytecomp-version-regexp", Vbytecomp_version_regexp,
               doc: /* Regular expression matching safe to load compiled Lisp files.
 When Emacs loads a compiled Lisp file, it reads the first 512 bytes
 from the file, and matches them against this regular expression.
@@ -4382,11 +4456,20 @@ to load.  See also `load-dangerous-libraries'.  */);
   Vbytecomp_version_regexp
     = make_pure_c_string ("^;;;.\\(in Emacs version\\|bytecomp version FSF\\)");
 
-  DEFVAR_LISP ("eval-buffer-list", &Veval_buffer_list,
+  Qlexical_binding = intern ("lexical-binding");
+  staticpro (&Qlexical_binding);
+  DEFVAR_LISP ("lexical-binding", Vlexical_binding,
+              doc: /* If non-nil, use lexical binding when evaluating code.
+This only applies to code evaluated by `eval-buffer' and `eval-region'.
+This variable is automatically set from the file variables of an interpreted
+  Lisp file read using `load'.  */);
+  Fmake_variable_buffer_local (Qlexical_binding);
+
+  DEFVAR_LISP ("eval-buffer-list", Veval_buffer_list,
               doc: /* List of buffers being read from by calls to `eval-buffer' and `eval-region'.  */);
   Veval_buffer_list = Qnil;
 
-  DEFVAR_LISP ("old-style-backquotes", &Vold_style_backquotes,
+  DEFVAR_LISP ("old-style-backquotes", Vold_style_backquotes,
               doc: /* Set to non-nil when `read' encounters an old-style backquote.  */);
   Vold_style_backquotes = Qnil;
   Qold_style_backquotes = intern_c_string ("old-style-backquotes");
@@ -4445,6 +4528,9 @@ to load.  See also `load-dangerous-libraries'.  */);
   Qfile_truename = intern_c_string ("file-truename");
   staticpro (&Qfile_truename) ;
 
+  Qdir_ok = intern_c_string ("dir-ok");
+  staticpro (&Qdir_ok);
+
   Qdo_after_load_evaluation = intern_c_string ("do-after-load-evaluation");
   staticpro (&Qdo_after_load_evaluation) ;
 
@@ -4473,6 +4559,3 @@ to load.  See also `load-dangerous-libraries'.  */);
   Qrehash_threshold = intern_c_string ("rehash-threshold");
   staticpro (&Qrehash_threshold);
 }
-
-/* arch-tag: a0d02733-0f96-4844-a659-9fd53c4f414d
-   (do not change this comment) */