Fix comment; indent-tabs-mode was a bad example,
[bpt/emacs.git] / src / lread.c
index 858a936..5418d82 100644 (file)
@@ -27,6 +27,7 @@ Boston, MA 02110-1301, USA.  */
 #include <sys/stat.h>
 #include <sys/file.h>
 #include <errno.h>
+#include <setjmp.h>
 #include "lisp.h"
 #include "intervals.h"
 #include "buffer.h"
@@ -34,6 +35,7 @@ Boston, MA 02110-1301, USA.  */
 #include <epaths.h>
 #include "commands.h"
 #include "keyboard.h"
+#include "frame.h"
 #include "termhooks.h"
 #include "coding.h"
 #include "blockinput.h"
@@ -447,8 +449,6 @@ static void substitute_in_interval P_ ((INTERVAL, Lisp_Object));
 \f
 /* Get a character from the tty.  */
 
-extern Lisp_Object read_char ();
-
 /* Read input events until we get one that's acceptable for our purposes.
 
    If NO_SWITCH_FRAME is non-zero, switch-frame events are stashed
@@ -500,10 +500,12 @@ read_filtered_event (no_switch_frame, ascii_required, error_nonascii,
       EMACS_ADD_TIME (end_time, end_time, wait_time);
     }
 
-  /* Read until we get an acceptable event.  */
+/* Read until we get an acceptable event.  */
  retry:
-  val = read_char (0, 0, 0, (input_method ? Qnil : Qt), 0,
-                  NUMBERP (seconds) ? &end_time : NULL);
+  do
+    val = read_char (0, 0, 0, (input_method ? Qnil : Qt), 0,
+                    NUMBERP (seconds) ? &end_time : NULL);
+  while (INTEGERP (val) && XINT (val) == -2); /* wrong_kboard_jmpbuf */
 
   if (BUFFERP (val))
     goto retry;
@@ -643,7 +645,7 @@ DEFUN ("get-file-char", Fget_file_char, Sget_file_char, 0, 0, 0,
 
 
 \f
-/* Value is non-zero if the file asswociated with file descriptor FD
+/* Value is non-zero 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.  Files compiled with XEmacs can lead
    to a crash in Fbyte_code because of an incompatible change in the
@@ -706,7 +708,7 @@ load_warn_old_style_backquotes (file)
   if (!NILP (Vold_style_backquotes))
     {
       Lisp_Object args[2];
-      args[0] = build_string ("!! File %s uses old-style backquotes !!");
+      args[0] = build_string ("Loading `%s': old-style backquotes detected!");
       args[1] = file;
       Fmessage (2, args);
     }
@@ -739,7 +741,7 @@ DEFUN ("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
-determined by  `load-suffixes').  Environment variable references in
+determined by `load-suffixes').  Environment variable references in
 FILE are replaced with their values by calling `substitute-in-file-name'.
 This function searches the directories in `load-path'.
 
@@ -910,7 +912,7 @@ Return t if the file exists and loads successfully.  */)
                                    tmp))
                     : found) ;
 
-  /* Check fore the presence of old-style quotes and warn about them.  */
+  /* Check for the presence of old-style quotes and warn about them.  */
   specbind (Qold_style_backquotes, Qnil);
   record_unwind_protect (load_warn_old_style_backquotes, file);
 
@@ -1217,7 +1219,7 @@ openp (path, str, suffixes, storeptr, predicate)
        fn = (char *) alloca (fn_size = 100 + want_size);
 
       /* Loop over suffixes.  */
-      for (tail = NILP (suffixes) ? Fcons (build_string (""), Qnil) : suffixes;
+      for (tail = NILP (suffixes) ? Fcons (empty_unibyte_string, Qnil) : suffixes;
           CONSP (tail); tail = XCDR (tail))
        {
          int lsuffix = SBYTES (XCAR (tail));
@@ -1517,7 +1519,8 @@ readevalloop (readcharfun, stream, sourcename, evalfun,
        }
 
       /* Ignore whitespace here, so we can detect eof.  */
-      if (c == ' ' || c == '\t' || c == '\n' || c == '\f' || c == '\r')
+      if (c == ' ' || c == '\t' || c == '\n' || c == '\f' || c == '\r'
+         || c == 0x8a0)  /* NBSP */
        goto read_next;
 
       if (!NILP (Vpurify_flag) && c == '(')
@@ -1910,7 +1913,7 @@ read_escape (readcharfun, stringp, byterep)
 
     case 's':
       c = READCHAR;
-      if (c != '-')
+      if (stringp || c != '-')
        {
          UNREAD (c);
          return ' ';
@@ -2716,6 +2719,8 @@ read1 (readcharfun, pch, first_in_list)
     default:
     default_label:
       if (c <= 040) goto retry;
+      if (c == 0x8a0) /* NBSP */
+       goto retry;
       {
        char *p = read_buffer;
        int quoted = 0;
@@ -2724,6 +2729,7 @@ read1 (readcharfun, pch, first_in_list)
          char *end = read_buffer + read_buffer_size;
 
          while (c > 040
+                && c != 0x8a0 /* NBSP */
                 && (c >= 0200
                     || (!index ("\"';()[]#", c)
                         && !(!first_in_list && c == '`')
@@ -3666,6 +3672,7 @@ defsubr (sname)
 {
   Lisp_Object sym;
   sym = intern (sname->symbol_name);
+  XSETPVECTYPE (sname, PVEC_SUBR);
   XSETSUBR (XSYMBOL (sym)->function, sname);
 }
 
@@ -3682,8 +3689,8 @@ 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 ("indent-tabs-mode", &indent_tabs_mode, "Documentation");  */
+   to a C variable of type int.  Sample call:
  DEFVAR_INT ("emacs-priority", &emacs_priority, "Documentation");  */
 void
 defvar_int (namestring, address)
      char *namestring;
@@ -3698,7 +3705,7 @@ defvar_int (namestring, address)
 }
 
 /* Similar but define a variable whose value is t if address contains 1,
-   nil if address contains 0 */
+   nil if address contains 0 */
 void
 defvar_bool (namestring, address)
      char *namestring;
@@ -3740,37 +3747,6 @@ defvar_lisp (namestring, address)
   staticpro (address);
 }
 
-/* Similar but define a variable whose value is the Lisp Object stored in
-   the current buffer.  address is the address of the slot in the buffer
-   that is current now. */
-
-void
-defvar_per_buffer (namestring, address, type, doc)
-     char *namestring;
-     Lisp_Object *address;
-     Lisp_Object type;
-     char *doc;
-{
-  Lisp_Object sym, val;
-  int offset;
-
-  sym = intern (namestring);
-  val = allocate_misc ();
-  offset = (char *)address - (char *)current_buffer;
-
-  XMISCTYPE (val) = Lisp_Misc_Buffer_Objfwd;
-  XBUFFER_OBJFWD (val)->offset = offset;
-  SET_SYMBOL_VALUE (sym, val);
-  PER_BUFFER_SYMBOL (offset) = sym;
-  PER_BUFFER_TYPE (offset) = type;
-
-  if (PER_BUFFER_IDX (offset) == 0)
-    /* Did a DEFVAR_PER_BUFFER without initializing the corresponding
-       slot of buffer_local_flags */
-    abort ();
-}
-
-
 /* Similar but define a variable whose value is the Lisp Object stored
    at a particular offset in the current kboard object.  */
 
@@ -3867,7 +3843,7 @@ init_lread ()
                    Vload_path = Fcons (tem, Vload_path);
                }
 
-             /* Add site-list under the installation dir, if it exists.  */
+             /* Add site-lisp under the installation dir, if it exists.  */
              tem = Fexpand_file_name (build_string ("site-lisp"),
                                       Vinstallation_directory);
              tem1 = Ffile_exists_p (tem);
@@ -3927,7 +3903,7 @@ init_lread ()
       /* NORMAL refers to the lisp dir in the source directory.  */
       /* We used to add ../lisp at the front here, but
         that caused trouble because it was copied from dump_path
-        into Vload_path, aboe, when Vinstallation_directory was non-nil.
+        into Vload_path, above, when Vinstallation_directory was non-nil.
         It should be unnecessary.  */
       Vload_path = decode_env_path (0, normal);
       dump_path = Vload_path;
@@ -3986,7 +3962,7 @@ init_lread ()
 }
 
 /* Print a warning, using format string FORMAT, that directory DIRNAME
-   does not exist.  Print it on stderr and put it in *Message*.  */
+   does not exist.  Print it on stderr and put it in *Messages*.  */
 
 void
 dir_warning (format, dirname)
@@ -4092,8 +4068,7 @@ and, if so, which suffixes they should try to append to the file name
 in order to do so.  However, if you want to customize which suffixes
 the loading functions recognize as compression suffixes, you should
 customize `jka-compr-load-suffixes' rather than the present variable.  */);
-  /* We don't use empty_string because it's not initialized yet.  */
-  Vload_file_rep_suffixes = Fcons (build_string (""), Qnil);
+  Vload_file_rep_suffixes = Fcons (empty_unibyte_string, Qnil);
 
   DEFVAR_BOOL ("load-in-progress", &load_in_progress,
               doc: /* Non-nil if inside of `load'.  */);