#ifndef standalone
#include "buffer.h"
+#include "charset.h"
#include <paths.h>
#include "commands.h"
#include "keyboard.h"
/* 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;
/* Nonzero means load should forcibly load all dynamic doc strings. */
static int load_force_doc_strings;
+/* Function to use for loading an Emacs lisp source file (not
+ compiled) instead of readevalloop. */
+Lisp_Object Vload_source_file_function;
+
/* List of descriptors now open for Fload. */
static Lisp_Object load_descriptor_list;
\f
/* Handle unreading and rereading of characters.
Write READCHAR to read a character,
- UNREAD(c) to unread c to be read again. */
+ UNREAD(c) to unread c to be read again.
+
+ These macros actually read/unread a byte code, multibyte characters
+ are not handled here. The caller should manage them if necessary.
+ */
#define READCHAR readchar (readcharfun)
#define UNREAD(c) unreadchar (readcharfun, c)
}
XSTRING (found)->data[XSTRING (found)->size - 1] = 'c';
}
+ else
+ {
+ /* We are loading a source file (*.el). */
+ if (!NILP (Vload_source_file_function))
+ {
+ close (fd);
+ return call4 (Vload_source_file_function, found, file,
+ NILP (noerror) ? Qnil : Qt,
+ NILP (nomessage) ? Qnil : Qt);
+ }
+ }
#ifdef DOS_NT
close (fd);
error ("Failure to create stdio stream for %s", XSTRING (file)->data);
}
+ if (! NILP (Vpurify_flag))
+ Vpreloaded_file_list = Fcons (file, Vpreloaded_file_list);
+
if (NILP (nomessage))
{
if (newer)
PRINTFLAG controls printing of output:\n\
nil means discard it; anything else is stream for print.\n\
\n\
-If there is no error, point does not move. If there is an error,\n\
-point remains at the end of the last character read from the buffer.")
+This function preserves the position of point.")
(buffer, printflag)
Lisp_Object buffer, printflag;
{
static int read_buffer_size;
static char *read_buffer;
+/* Read multibyte form and return it as a character. C is a first
+ byte of multibyte form, and rest of them are read from
+ READCHARFUN. */
+static int
+read_multibyte (c, readcharfun)
+ register int c;
+ Lisp_Object readcharfun;
+{
+ /* We need the actual character code of this multibyte
+ characters. */
+ unsigned char str[MAX_LENGTH_OF_MULTI_BYTE_FORM];
+ int len = 0;
+
+ str[len++] = c;
+ while ((c = READCHAR) >= 0xA0
+ && len < MAX_LENGTH_OF_MULTI_BYTE_FORM)
+ str[len++] = c;
+ UNREAD (c);
+ return STRING_CHAR (str, len);
+}
+
static int
read_escape (readcharfun)
Lisp_Object readcharfun;
}
default:
+ if (BASE_LEADING_CODE_P (c))
+ c = read_multibyte (c, readcharfun);
return c;
}
}
|| XVECTOR (tmp)->size > CHAR_TABLE_STANDARD_SLOTS + 10)
error ("Invalid size char-table");
XSETCHAR_TABLE (tmp, XCHAR_TABLE (tmp));
+ XCHAR_TABLE (tmp)->top = Qt;
return tmp;
}
+ else if (c == '^')
+ {
+ c = READCHAR;
+ if (c == '[')
+ {
+ Lisp_Object tmp;
+ tmp = read_vector (readcharfun);
+ if (XVECTOR (tmp)->size != SUB_CHAR_TABLE_STANDARD_SLOTS)
+ error ("Invalid size char-table");
+ XSETCHAR_TABLE (tmp, XCHAR_TABLE (tmp));
+ XCHAR_TABLE (tmp)->top = Qnil;
+ return tmp;
+ }
+ Fsignal (Qinvalid_read_syntax,
+ Fcons (make_string ("#^^", 3), Qnil));
+ }
Fsignal (Qinvalid_read_syntax, Fcons (make_string ("#^", 2), Qnil));
}
if (c == '&')
if (c < 0) return Fsignal (Qend_of_file, Qnil);
if (c == '\\')
- XSETINT (val, read_escape (readcharfun));
- else
- XSETINT (val, c);
+ c = read_escape (readcharfun);
+ else if (BASE_LEADING_CODE_P (c))
+ c = read_multibyte (c, readcharfun);
+ XSETINT (val, c);
return val;
}
tem = oblookup (obarray, str, len);
if (SYMBOLP (tem))
return tem;
- return Fintern ((!NILP (Vpurify_flag)
- ? make_pure_string (str, len)
- : make_string (str, len)),
- obarray);
+ return Fintern (make_string (str, len), obarray);
}
/* Create an uninterned symbol with name STR. */
sym = Fmake_symbol (string);
XSYMBOL (sym)->obarray = obarray;
+ if (XSTRING (string)->data[0] == ':')
+ XSYMBOL (sym)->value = sym;
+
ptr = &XVECTOR (obarray)->contents[XINT (tem)];
if (SYMBOLP (*ptr))
XSYMBOL (sym)->next = XSYMBOL (*ptr);
Lisp dirs instead. */
Vload_path = nconc2 (Vload_path, dump_path);
+ /* Add leim under the installation dir, if it exists. */
+ tem = Fexpand_file_name (build_string ("leim"),
+ Vinstallation_directory);
+ tem1 = Ffile_exists_p (tem);
+ if (!NILP (tem1))
+ {
+ if (NILP (Fmember (tem, Vload_path)))
+ Vload_path = nconc2 (Vload_path, Fcons (tem, Qnil));
+ }
+
/* Add site-list under the installation dir, if it exists. */
tem = Fexpand_file_name (build_string ("site-lisp"),
Vinstallation_directory);
if (NILP (Fmember (tem, Vload_path)))
Vload_path = nconc2 (Vload_path, Fcons (tem, Qnil));
}
+
+ /* If Emacs was not built in the source directory,
+ and it is run from where it was built, add to load-path
+ the lisp, leim and site-lisp dirs under that directory. */
+
+ if (NILP (Fequal (Vinstallation_directory, Vsource_directory)))
+ {
+ tem = Fexpand_file_name (build_string ("src/Makefile"),
+ Vinstallation_directory);
+ tem1 = Ffile_exists_p (tem);
+ if (!NILP (tem1))
+ {
+ tem = Fexpand_file_name (build_string ("lisp"),
+ Vsource_directory);
+
+ if (NILP (Fmember (tem, Vload_path)))
+ Vload_path = nconc2 (Vload_path, Fcons (tem, Qnil));
+
+ tem = Fexpand_file_name (build_string ("leim"),
+ Vsource_directory);
+
+ if (NILP (Fmember (tem, Vload_path)))
+ Vload_path = nconc2 (Vload_path, Fcons (tem, Qnil));
+
+ tem = Fexpand_file_name (build_string ("site-lisp"),
+ Vsource_directory);
+
+ if (NILP (Fmember (tem, Vload_path)))
+ Vload_path = nconc2 (Vload_path, Fcons (tem, Qnil));
+ }
+ }
}
}
}
else
{
- /* ../lisp refers to the build directory.
- NORMAL refers to the lisp dir in the source directory. */
- Vload_path = Fcons (build_string ("../lisp"),
- decode_env_path (0, normal));
+ /* 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.
+ It should be unnecessary. */
+ Vload_path = decode_env_path (0, normal);
dump_path = Vload_path;
}
#endif
The default is nil, which means use the function `read'.");
Vload_read_function = Qnil;
+ DEFVAR_LISP ("load-source-file-function", &Vload_source_file_function,
+ "Function called in `load' for loading an Emacs lisp source file.\n\
+This function is for doing code conversion before reading the source file.\n\
+If nil, loading is done without any code conversion.\n\
+Arguments are FULLNAME, FILE, NOERROR, NOMESSAGE, where\n\
+ FULLNAME is the full name of FILE.\n\
+See `load' for the meaning of the remaining arguments.");
+ Vload_source_file_function = Qnil;
+
DEFVAR_BOOL ("load-force-doc-strings", &load_force_doc_strings,
"Non-nil means `load' should force-load all dynamic doc strings.\n\
This is useful when the file being loaded is a temporary copy.");
= Fexpand_file_name (build_string ("../"),
Fcar (decode_env_path (0, PATH_DUMPLOADSEARCH)));
+ DEFVAR_LISP ("preloaded-file-list", &Vpreloaded_file_list,
+ "List of files that were preloaded (when dumping Emacs).");
+ Vpreloaded_file_list = Qnil;
+
/* Vsource_directory was initialized in init_lread. */
load_descriptor_list = Qnil;