1 /* Lisp parsing and input streams.
2 Copyright (C) 1985, 86, 87, 88, 89, 93, 94, 95, 1997
3 Free Software Foundation, Inc.
5 This file is part of GNU Emacs.
7 GNU Emacs is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 GNU Emacs is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU Emacs; see the file COPYING. If not, write to
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
25 #include <sys/types.h>
37 #include "termhooks.h"
41 #include <sys/inode.h>
46 #include <unistd.h> /* to get X_OK */
55 #ifdef LISP_FLOAT_TYPE
61 #endif /* LISP_FLOAT_TYPE */
65 #endif /* HAVE_SETLOCALE */
73 Lisp_Object Qread_char
, Qget_file_char
, Qstandard_input
, Qcurrent_load_list
;
74 Lisp_Object Qvariable_documentation
, Vvalues
, Vstandard_input
, Vafter_load_alist
;
75 Lisp_Object Qascii_character
, Qload
, Qload_file_name
;
76 Lisp_Object Qbackquote
, Qcomma
, Qcomma_at
, Qcomma_dot
, Qfunction
;
77 Lisp_Object Qinhibit_file_name_operation
;
79 extern Lisp_Object Qevent_symbol_element_mask
;
80 extern Lisp_Object Qfile_exists_p
;
82 /* non-zero if inside `load' */
85 /* Directory in which the sources were found. */
86 Lisp_Object Vsource_directory
;
88 /* Search path for files to be loaded. */
89 Lisp_Object Vload_path
;
91 /* This is the user-visible association list that maps features to
92 lists of defs in their load files. */
93 Lisp_Object Vload_history
;
95 /* This is used to build the load history. */
96 Lisp_Object Vcurrent_load_list
;
98 /* List of files that were preloaded. */
99 Lisp_Object Vpreloaded_file_list
;
101 /* Name of file actually being read by `load'. */
102 Lisp_Object Vload_file_name
;
104 /* Function to use for reading, in `load' and friends. */
105 Lisp_Object Vload_read_function
;
107 /* The association list of objects read with the #n=object form.
108 Each member of the list has the form (n . object), and is used to
109 look up the object for the corresponding #n# construct.
110 It must be set to nil before all top-level calls to read0. */
111 Lisp_Object read_objects
;
113 /* Nonzero means load should forcibly load all dynamic doc strings. */
114 static int load_force_doc_strings
;
116 /* Function to use for loading an Emacs lisp source file (not
117 compiled) instead of readevalloop. */
118 Lisp_Object Vload_source_file_function
;
120 /* List of descriptors now open for Fload. */
121 static Lisp_Object load_descriptor_list
;
123 /* File for get_file_char to read from. Use by load. */
124 static FILE *instream
;
126 /* When nonzero, read conses in pure space */
127 static int read_pure
;
129 /* For use within read-from-string (this reader is non-reentrant!!) */
130 static int read_from_string_index
;
131 static int read_from_string_limit
;
133 /* Number of bytes left to read in the buffer character
134 that `readchar' has already advanced over. */
135 static int readchar_backlog
;
137 /* This contains the last string skipped with #@, but only on some systems.
138 On other systems we can't put the string here. */
139 static char *saved_doc_string
;
140 /* Length of buffer allocated in saved_doc_string. */
141 static int saved_doc_string_size
;
142 /* Length of actual data in saved_doc_string. */
143 static int saved_doc_string_length
;
144 /* This is the file position that string came from. */
145 static int saved_doc_string_position
;
147 /* Nonzero means inside a new-style backquote
148 with no surrounding parentheses.
149 Fread initializes this to zero, so we need not specbind it
150 or worry about what happens to it when there is an error. */
151 static int new_backquote_flag
;
153 /* Handle unreading and rereading of characters.
154 Write READCHAR to read a character,
155 UNREAD(c) to unread c to be read again.
157 These macros actually read/unread a byte code, multibyte characters
158 are not handled here. The caller should manage them if necessary.
161 #define READCHAR readchar (readcharfun)
162 #define UNREAD(c) unreadchar (readcharfun, c)
165 readchar (readcharfun
)
166 Lisp_Object readcharfun
;
169 register struct buffer
*inbuffer
;
170 register int c
, mpos
;
172 if (BUFFERP (readcharfun
))
174 inbuffer
= XBUFFER (readcharfun
);
176 if (readchar_backlog
== 0)
178 int pt_byte
= BUF_PT_BYTE (inbuffer
);
179 int orig_pt_byte
= pt_byte
;
181 if (pt_byte
>= BUF_ZV_BYTE (inbuffer
))
184 if (! NILP (inbuffer
->enable_multibyte_characters
))
185 BUF_INC_POS (inbuffer
, pt_byte
);
188 SET_BUF_PT_BOTH (inbuffer
, BUF_PT (inbuffer
) + 1, pt_byte
);
189 readchar_backlog
= pt_byte
- orig_pt_byte
;
192 /* We get the address of the byte just passed,
193 which is the last byte of the character.
194 The other bytes in this character are consecutive with it,
195 because the gap can't be in the middle of a character. */
196 return *(BUF_BYTE_ADDRESS (inbuffer
, BUF_PT_BYTE (inbuffer
) - 1)
197 - --readchar_backlog
);
199 if (MARKERP (readcharfun
))
201 inbuffer
= XMARKER (readcharfun
)->buffer
;
203 if (readchar_backlog
== 0)
205 int bytepos
= marker_byte_position (readcharfun
);
206 int orig_bytepos
= bytepos
;
208 if (bytepos
>= BUF_ZV_BYTE (inbuffer
))
211 if (XMARKER (readcharfun
)->bufpos
== BUF_GPT_BYTE (inbuffer
))
212 XMARKER (readcharfun
)->bufpos
+= BUF_GAP_SIZE (inbuffer
);
214 if (! NILP (inbuffer
->enable_multibyte_characters
))
218 XMARKER (readcharfun
)->bufpos
+= bytepos
- orig_bytepos
;
219 XMARKER (readcharfun
)->charpos
++;
221 readchar_backlog
= bytepos
- orig_bytepos
;
224 /* Because we move ->bufpos across the gap before we advance it,
225 the gap never comes between the previous character and ->bufpos. */
226 return *(BUF_BEG_ADDR (inbuffer
) + XMARKER (readcharfun
)->bufpos
227 - readchar_backlog
--);
229 if (EQ (readcharfun
, Qget_file_char
))
233 /* Interrupted reads have been observed while reading over the network */
234 while (c
== EOF
&& ferror (instream
) && errno
== EINTR
)
243 if (STRINGP (readcharfun
))
246 /* This used to be return of a conditional expression,
247 but that truncated -1 to a char on VMS. */
248 if (read_from_string_index
< read_from_string_limit
)
249 c
= XSTRING (readcharfun
)->data
[read_from_string_index
++];
256 tem
= call0 (readcharfun
);
263 /* Unread the character C in the way appropriate for the stream READCHARFUN.
264 If the stream is a user function, call it with the char as argument. */
267 unreadchar (readcharfun
, c
)
268 Lisp_Object readcharfun
;
272 /* Don't back up the pointer if we're unreading the end-of-input mark,
273 since readchar didn't advance it when we read it. */
275 else if (BUFFERP (readcharfun
))
277 else if (MARKERP (readcharfun
))
279 else if (STRINGP (readcharfun
))
280 read_from_string_index
--;
281 else if (EQ (readcharfun
, Qget_file_char
))
282 ungetc (c
, instream
);
284 call1 (readcharfun
, make_number (c
));
287 static Lisp_Object
read0 (), read1 (), read_list (), read_vector ();
288 static int read_multibyte ();
290 /* get a character from the tty */
292 extern Lisp_Object
read_char ();
294 /* Read input events until we get one that's acceptable for our purposes.
296 If NO_SWITCH_FRAME is non-zero, switch-frame events are stashed
297 until we get a character we like, and then stuffed into
300 If ASCII_REQUIRED is non-zero, we check function key events to see
301 if the unmodified version of the symbol has a Qascii_character
302 property, and use that character, if present.
304 If ERROR_NONASCII is non-zero, we signal an error if the input we
305 get isn't an ASCII character with modifiers. If it's zero but
306 ASCII_REQUIRED is non-zero, we just re-read until we get an ASCII
310 read_filtered_event (no_switch_frame
, ascii_required
, error_nonascii
)
311 int no_switch_frame
, ascii_required
, error_nonascii
;
314 return make_number (getchar ());
316 register Lisp_Object val
, delayed_switch_frame
;
318 delayed_switch_frame
= Qnil
;
320 /* Read until we get an acceptable event. */
322 val
= read_char (0, 0, 0, Qnil
, 0);
327 /* switch-frame events are put off until after the next ASCII
328 character. This is better than signaling an error just because
329 the last characters were typed to a separate minibuffer frame,
330 for example. Eventually, some code which can deal with
331 switch-frame events will read it and process it. */
333 && EVENT_HAS_PARAMETERS (val
)
334 && EQ (EVENT_HEAD (val
), Qswitch_frame
))
336 delayed_switch_frame
= val
;
342 /* Convert certain symbols to their ASCII equivalents. */
345 Lisp_Object tem
, tem1
, tem2
;
346 tem
= Fget (val
, Qevent_symbol_element_mask
);
349 tem1
= Fget (Fcar (tem
), Qascii_character
);
350 /* Merge this symbol's modifier bits
351 with the ASCII equivalent of its basic code. */
353 XSETFASTINT (val
, XINT (tem1
) | XINT (Fcar (Fcdr (tem
))));
357 /* If we don't have a character now, deal with it appropriately. */
362 Vunread_command_events
= Fcons (val
, Qnil
);
363 error ("Non-character input-event");
370 if (! NILP (delayed_switch_frame
))
371 unread_switch_frame
= delayed_switch_frame
;
377 DEFUN ("read-char", Fread_char
, Sread_char
, 0, 0, 0,
378 "Read a character from the command input (keyboard or macro).\n\
379 It is returned as a number.\n\
380 If the user generates an event which is not a character (i.e. a mouse\n\
381 click or function key event), `read-char' signals an error. As an\n\
382 exception, switch-frame events are put off until non-ASCII events can\n\
384 If you want to read non-character events, or ignore them, call\n\
385 `read-event' or `read-char-exclusive' instead.")
388 return read_filtered_event (1, 1, 1);
391 DEFUN ("read-event", Fread_event
, Sread_event
, 0, 0, 0,
392 "Read an event object from the input stream.")
395 return read_filtered_event (0, 0, 0);
398 DEFUN ("read-char-exclusive", Fread_char_exclusive
, Sread_char_exclusive
, 0, 0, 0,
399 "Read a character from the command input (keyboard or macro).\n\
400 It is returned as a number. Non-character events are ignored.")
403 return read_filtered_event (1, 1, 0);
406 DEFUN ("get-file-char", Fget_file_char
, Sget_file_char
, 0, 0, 0,
407 "Don't use this yourself.")
410 register Lisp_Object val
;
411 XSETINT (val
, getc (instream
));
415 static void readevalloop ();
416 static Lisp_Object
load_unwind ();
417 static Lisp_Object
load_descriptor_unwind ();
419 DEFUN ("load", Fload
, Sload
, 1, 5, 0,
420 "Execute a file of Lisp code named FILE.\n\
421 First try FILE with `.elc' appended, then try with `.el',\n\
422 then try FILE unmodified.\n\
423 This function searches the directories in `load-path'.\n\
424 If optional second arg NOERROR is non-nil,\n\
425 report no error if FILE doesn't exist.\n\
426 Print messages at start and end of loading unless\n\
427 optional third arg NOMESSAGE is non-nil.\n\
428 If optional fourth arg NOSUFFIX is non-nil, don't try adding\n\
429 suffixes `.elc' or `.el' to the specified name FILE.\n\
430 If optional fifth arg MUST-SUFFIX is non-nil, insist on\n\
431 the suffix `.elc' or `.el'; don't accept just FILE unless\n\
432 it ends in one of those suffixes or includes a directory name.\n\
433 Return t if file exists.")
434 (file
, noerror
, nomessage
, nosuffix
, must_suffix
)
435 Lisp_Object file
, noerror
, nomessage
, nosuffix
, must_suffix
;
437 register FILE *stream
;
438 register int fd
= -1;
439 register Lisp_Object lispstream
;
440 int count
= specpdl_ptr
- specpdl
;
444 /* 1 means we printed the ".el is newer" message. */
446 /* 1 means we are loading a compiled file. */
450 char *dosmode
= "rt";
453 CHECK_STRING (file
, 0);
455 /* If file name is magic, call the handler. */
456 handler
= Ffind_file_name_handler (file
, Qload
);
458 return call5 (handler
, Qload
, file
, noerror
, nomessage
, nosuffix
);
460 /* Do this after the handler to avoid
461 the need to gcpro noerror, nomessage and nosuffix.
462 (Below here, we care only whether they are nil or not.) */
463 file
= Fsubstitute_in_file_name (file
);
465 /* Avoid weird lossage with null string as arg,
466 since it would try to load a directory as a Lisp file */
467 if (XSTRING (file
)->size
> 0)
469 int size
= XSTRING (file
)->size
;
473 if (! NILP (must_suffix
))
475 /* Don't insist on adding a suffix if FILE already ends with one. */
477 && !strcmp (XSTRING (file
)->data
+ size
- 3, ".el"))
480 && !strcmp (XSTRING (file
)->data
+ size
- 4, ".elc"))
482 /* Don't insist on adding a suffix
483 if the argument includes a directory name. */
484 else if (! NILP (Ffile_name_directory (file
)))
488 fd
= openp (Vload_path
, file
,
489 (!NILP (nosuffix
) ? ""
490 : ! NILP (must_suffix
) ? ".elc:.el"
500 Fsignal (Qfile_error
, Fcons (build_string ("Cannot open load file"),
501 Fcons (file
, Qnil
)));
506 /* If FD is 0, that means openp found a remote file. */
509 handler
= Ffind_file_name_handler (found
, Qload
);
510 return call5 (handler
, Qload
, found
, noerror
, nomessage
, Qt
);
513 if (!bcmp (&(XSTRING (found
)->data
[XSTRING (found
)->size
- 4]),
524 stat ((char *)XSTRING (found
)->data
, &s1
);
525 XSTRING (found
)->data
[XSTRING (found
)->size
- 1] = 0;
526 result
= stat ((char *)XSTRING (found
)->data
, &s2
);
527 if (result
>= 0 && (unsigned) s1
.st_mtime
< (unsigned) s2
.st_mtime
)
529 /* Make the progress messages mention that source is newer. */
532 /* If we won't print another message, mention this anyway. */
533 if (! NILP (nomessage
))
534 message ("Source file `%s' newer than byte-compiled file",
535 XSTRING (found
)->data
);
537 XSTRING (found
)->data
[XSTRING (found
)->size
- 1] = 'c';
541 /* We are loading a source file (*.el). */
542 if (!NILP (Vload_source_file_function
))
545 return call4 (Vload_source_file_function
, found
, file
,
546 NILP (noerror
) ? Qnil
: Qt
,
547 NILP (nomessage
) ? Qnil
: Qt
);
553 stream
= fopen ((char *) XSTRING (found
)->data
, dosmode
);
554 #else /* not DOS_NT */
555 stream
= fdopen (fd
, "r");
556 #endif /* not DOS_NT */
560 error ("Failure to create stdio stream for %s", XSTRING (file
)->data
);
563 if (! NILP (Vpurify_flag
))
564 Vpreloaded_file_list
= Fcons (file
, Vpreloaded_file_list
);
566 if (NILP (nomessage
))
569 message ("Loading %s (source)...", XSTRING (file
)->data
);
571 message ("Loading %s (compiled; note, source file is newer)...",
572 XSTRING (file
)->data
);
573 else /* The typical case; compiled file newer than source file. */
574 message ("Loading %s...", XSTRING (file
)->data
);
578 lispstream
= Fcons (Qnil
, Qnil
);
579 XSETFASTINT (XCONS (lispstream
)->car
, (EMACS_UINT
)stream
>> 16);
580 XSETFASTINT (XCONS (lispstream
)->cdr
, (EMACS_UINT
)stream
& 0xffff);
581 record_unwind_protect (load_unwind
, lispstream
);
582 record_unwind_protect (load_descriptor_unwind
, load_descriptor_list
);
583 specbind (Qload_file_name
, found
);
584 specbind (Qinhibit_file_name_operation
, Qnil
);
586 = Fcons (make_number (fileno (stream
)), load_descriptor_list
);
588 readevalloop (Qget_file_char
, stream
, file
, Feval
, 0);
589 unbind_to (count
, Qnil
);
591 /* Run any load-hooks for this file. */
592 temp
= Fassoc (file
, Vafter_load_alist
);
594 Fprogn (Fcdr (temp
));
597 if (saved_doc_string
)
598 free (saved_doc_string
);
599 saved_doc_string
= 0;
600 saved_doc_string_size
= 0;
602 if (!noninteractive
&& NILP (nomessage
))
605 message ("Loading %s (source)...done", XSTRING (file
)->data
);
607 message ("Loading %s (compiled; note, source file is newer)...done",
608 XSTRING (file
)->data
);
609 else /* The typical case; compiled file newer than source file. */
610 message ("Loading %s...done", XSTRING (file
)->data
);
616 load_unwind (stream
) /* used as unwind-protect function in load */
619 fclose ((FILE *) (XFASTINT (XCONS (stream
)->car
) << 16
620 | XFASTINT (XCONS (stream
)->cdr
)));
621 if (--load_in_progress
< 0) load_in_progress
= 0;
626 load_descriptor_unwind (oldlist
)
629 load_descriptor_list
= oldlist
;
633 /* Close all descriptors in use for Floads.
634 This is used when starting a subprocess. */
641 for (tail
= load_descriptor_list
; !NILP (tail
); tail
= XCONS (tail
)->cdr
)
642 close (XFASTINT (XCONS (tail
)->car
));
647 complete_filename_p (pathname
)
648 Lisp_Object pathname
;
650 register unsigned char *s
= XSTRING (pathname
)->data
;
651 return (IS_DIRECTORY_SEP (s
[0])
652 || (XSTRING (pathname
)->size
> 2
653 && IS_DEVICE_SEP (s
[1]) && IS_DIRECTORY_SEP (s
[2]))
663 /* Search for a file whose name is STR, looking in directories
664 in the Lisp list PATH, and trying suffixes from SUFFIX.
665 SUFFIX is a string containing possible suffixes separated by colons.
666 On success, returns a file descriptor. On failure, returns -1.
668 EXEC_ONLY nonzero means don't open the files,
669 just look for one that is executable. In this case,
670 returns 1 on success.
672 If STOREPTR is nonzero, it points to a slot where the name of
673 the file actually found should be stored as a Lisp string.
674 nil is stored there on failure.
676 If the file we find is remote, return 0
677 but store the found remote file name in *STOREPTR.
678 We do not check for remote files if EXEC_ONLY is nonzero. */
681 openp (path
, str
, suffix
, storeptr
, exec_only
)
682 Lisp_Object path
, str
;
684 Lisp_Object
*storeptr
;
690 register char *fn
= buf
;
693 Lisp_Object filename
;
701 if (complete_filename_p (str
))
704 for (; !NILP (path
); path
= Fcdr (path
))
708 filename
= Fexpand_file_name (str
, Fcar (path
));
709 if (!complete_filename_p (filename
))
710 /* If there are non-absolute elts in PATH (eg ".") */
711 /* Of course, this could conceivably lose if luser sets
712 default-directory to be something non-absolute... */
714 filename
= Fexpand_file_name (filename
, current_buffer
->directory
);
715 if (!complete_filename_p (filename
))
716 /* Give up on this path element! */
720 /* Calculate maximum size of any filename made from
721 this path element/specified file name and any possible suffix. */
722 want_size
= strlen (suffix
) + XSTRING (filename
)->size
+ 1;
723 if (fn_size
< want_size
)
724 fn
= (char *) alloca (fn_size
= 100 + want_size
);
728 /* Loop over suffixes. */
731 char *esuffix
= (char *) index (nsuffix
, ':');
732 int lsuffix
= esuffix
? esuffix
- nsuffix
: strlen (nsuffix
);
735 /* Concatenate path element/specified name with the suffix.
736 If the directory starts with /:, remove that. */
737 if (XSTRING (filename
)->size
> 2
738 && XSTRING (filename
)->data
[0] == '/'
739 && XSTRING (filename
)->data
[1] == ':')
741 strncpy (fn
, XSTRING (filename
)->data
+ 2,
742 XSTRING (filename
)->size
- 2);
743 fn
[XSTRING (filename
)->size
- 2] = 0;
747 strncpy (fn
, XSTRING (filename
)->data
, XSTRING (filename
)->size
);
748 fn
[XSTRING (filename
)->size
] = 0;
751 if (lsuffix
!= 0) /* Bug happens on CCI if lsuffix is 0. */
752 strncat (fn
, nsuffix
, lsuffix
);
754 /* Check that the file exists and is not a directory. */
758 handler
= Ffind_file_name_handler (filename
, Qfile_exists_p
);
759 if (! NILP (handler
) && ! exec_only
)
764 string
= build_string (fn
);
765 exists
= ! NILP (exec_only
? Ffile_executable_p (string
)
766 : Ffile_readable_p (string
));
768 && ! NILP (Ffile_directory_p (build_string (fn
))))
773 /* We succeeded; return this descriptor and filename. */
775 *storeptr
= build_string (fn
);
782 int exists
= (stat (fn
, &st
) >= 0
783 && (st
.st_mode
& S_IFMT
) != S_IFDIR
);
786 /* Check that we can access or open it. */
788 fd
= (access (fn
, X_OK
) == 0) ? 1 : -1;
790 fd
= open (fn
, O_RDONLY
, 0);
794 /* We succeeded; return this descriptor and filename. */
796 *storeptr
= build_string (fn
);
803 /* Advance to next suffix. */
806 nsuffix
+= lsuffix
+ 1;
817 /* Merge the list we've accumulated of globals from the current input source
818 into the load_history variable. The details depend on whether
819 the source has an associated file name or not. */
822 build_load_history (stream
, source
)
826 register Lisp_Object tail
, prev
, newelt
;
827 register Lisp_Object tem
, tem2
;
828 register int foundit
, loading
;
830 /* Don't bother recording anything for preloaded files. */
831 if (!NILP (Vpurify_flag
))
834 loading
= stream
|| !NARROWED
;
836 tail
= Vload_history
;
843 /* Find the feature's previous assoc list... */
844 if (!NILP (Fequal (source
, Fcar (tem
))))
848 /* If we're loading, remove it. */
852 Vload_history
= Fcdr (tail
);
854 Fsetcdr (prev
, Fcdr (tail
));
857 /* Otherwise, cons on new symbols that are not already members. */
860 tem2
= Vcurrent_load_list
;
864 newelt
= Fcar (tem2
);
866 if (NILP (Fmemq (newelt
, tem
)))
867 Fsetcar (tail
, Fcons (Fcar (tem
),
868 Fcons (newelt
, Fcdr (tem
))));
881 /* If we're loading, cons the new assoc onto the front of load-history,
882 the most-recently-loaded position. Also do this if we didn't find
883 an existing member for the current source. */
884 if (loading
|| !foundit
)
885 Vload_history
= Fcons (Fnreverse (Vcurrent_load_list
),
890 unreadpure () /* Used as unwind-protect function in readevalloop */
897 readevalloop (readcharfun
, stream
, sourcename
, evalfun
, printflag
)
898 Lisp_Object readcharfun
;
900 Lisp_Object sourcename
;
901 Lisp_Object (*evalfun
) ();
905 register Lisp_Object val
;
906 int count
= specpdl_ptr
- specpdl
;
908 struct buffer
*b
= 0;
910 if (BUFFERP (readcharfun
))
911 b
= XBUFFER (readcharfun
);
912 else if (MARKERP (readcharfun
))
913 b
= XMARKER (readcharfun
)->buffer
;
915 specbind (Qstandard_input
, readcharfun
);
916 specbind (Qcurrent_load_list
, Qnil
);
918 readchar_backlog
= 0;
922 LOADHIST_ATTACH (sourcename
);
926 if (b
!= 0 && NILP (b
->name
))
927 error ("Reading from killed buffer");
933 while ((c
= READCHAR
) != '\n' && c
!= -1);
938 /* Ignore whitespace here, so we can detect eof. */
939 if (c
== ' ' || c
== '\t' || c
== '\n' || c
== '\f' || c
== '\r')
942 if (!NILP (Vpurify_flag
) && c
== '(')
944 int count1
= specpdl_ptr
- specpdl
;
945 record_unwind_protect (unreadpure
, Qnil
);
946 val
= read_list (-1, readcharfun
);
947 unbind_to (count1
, Qnil
);
953 if (NILP (Vload_read_function
))
954 val
= read0 (readcharfun
);
956 val
= call1 (Vload_read_function
, readcharfun
);
959 val
= (*evalfun
) (val
);
962 Vvalues
= Fcons (val
, Vvalues
);
963 if (EQ (Vstandard_output
, Qt
))
970 build_load_history (stream
, sourcename
);
973 unbind_to (count
, Qnil
);
978 DEFUN ("eval-buffer", Feval_buffer
, Seval_buffer
, 0, 3, "",
979 "Execute the current buffer as Lisp code.\n\
980 Programs can pass two arguments, BUFFER and PRINTFLAG.\n\
981 BUFFER is the buffer to evaluate (nil means use current buffer).\n\
982 PRINTFLAG controls printing of output:\n\
983 nil means discard it; anything else is stream for print.\n\
985 If the optional third argument FILENAME is non-nil,\n\
986 it specifies the file name to use for `load-history'.\n\
988 This function preserves the position of point.")
989 (buffer
, printflag
, filename
)
990 Lisp_Object buffer
, printflag
, filename
;
992 int count
= specpdl_ptr
- specpdl
;
993 Lisp_Object tem
, buf
;
996 buf
= Fcurrent_buffer ();
998 buf
= Fget_buffer (buffer
);
1000 error ("No such buffer");
1002 if (NILP (printflag
))
1007 if (NILP (filename
))
1008 filename
= XBUFFER (buf
)->filename
;
1010 specbind (Qstandard_output
, tem
);
1011 record_unwind_protect (save_excursion_restore
, save_excursion_save ());
1012 BUF_SET_PT (XBUFFER (buf
), BUF_BEGV (XBUFFER (buf
)));
1013 readevalloop (buf
, 0, filename
, Feval
, !NILP (printflag
));
1014 unbind_to (count
, Qnil
);
1020 XDEFUN ("eval-current-buffer", Feval_current_buffer
, Seval_current_buffer
, 0, 1, "",
1021 "Execute the current buffer as Lisp code.\n\
1022 Programs can pass argument PRINTFLAG which controls printing of output:\n\
1023 nil means discard it; anything else is stream for print.\n\
1025 If there is no error, point does not move. If there is an error,\n\
1026 point remains at the end of the last character read from the buffer.")
1028 Lisp_Object printflag
;
1030 int count
= specpdl_ptr
- specpdl
;
1031 Lisp_Object tem
, cbuf
;
1033 cbuf
= Fcurrent_buffer ()
1035 if (NILP (printflag
))
1039 specbind (Qstandard_output
, tem
);
1040 record_unwind_protect (save_excursion_restore
, save_excursion_save ());
1042 readevalloop (cbuf
, 0, XBUFFER (cbuf
)->filename
, Feval
, !NILP (printflag
));
1043 return unbind_to (count
, Qnil
);
1047 DEFUN ("eval-region", Feval_region
, Seval_region
, 2, 3, "r",
1048 "Execute the region as Lisp code.\n\
1049 When called from programs, expects two arguments,\n\
1050 giving starting and ending indices in the current buffer\n\
1051 of the text to be executed.\n\
1052 Programs can pass third argument PRINTFLAG which controls output:\n\
1053 nil means discard it; anything else is stream for printing it.\n\
1055 This function does not move point.")
1056 (start
, end
, printflag
)
1057 Lisp_Object start
, end
, printflag
;
1059 int count
= specpdl_ptr
- specpdl
;
1060 Lisp_Object tem
, cbuf
;
1062 cbuf
= Fcurrent_buffer ();
1064 if (NILP (printflag
))
1068 specbind (Qstandard_output
, tem
);
1070 if (NILP (printflag
))
1071 record_unwind_protect (save_excursion_restore
, save_excursion_save ());
1072 record_unwind_protect (save_restriction_restore
, save_restriction_save ());
1074 /* This both uses start and checks its type. */
1076 Fnarrow_to_region (make_number (BEGV
), end
);
1077 readevalloop (cbuf
, 0, XBUFFER (cbuf
)->filename
, Feval
, !NILP (printflag
));
1079 return unbind_to (count
, Qnil
);
1082 #endif /* standalone */
1084 DEFUN ("read", Fread
, Sread
, 0, 1, 0,
1085 "Read one Lisp expression as text from STREAM, return as Lisp object.\n\
1086 If STREAM is nil, use the value of `standard-input' (which see).\n\
1087 STREAM or the value of `standard-input' may be:\n\
1088 a buffer (read from point and advance it)\n\
1089 a marker (read from where it points and advance it)\n\
1090 a function (call it with no arguments for each character,\n\
1091 call it with a char as argument to push a char back)\n\
1092 a string (takes text from string, starting at the beginning)\n\
1093 t (read text line using minibuffer and use it).")
1097 extern Lisp_Object
Fread_minibuffer ();
1100 stream
= Vstandard_input
;
1101 if (EQ (stream
, Qt
))
1102 stream
= Qread_char
;
1104 readchar_backlog
= 0;
1105 new_backquote_flag
= 0;
1106 read_objects
= Qnil
;
1109 if (EQ (stream
, Qread_char
))
1110 return Fread_minibuffer (build_string ("Lisp expression: "), Qnil
);
1113 if (STRINGP (stream
))
1114 return Fcar (Fread_from_string (stream
, Qnil
, Qnil
));
1116 return read0 (stream
);
1119 DEFUN ("read-from-string", Fread_from_string
, Sread_from_string
, 1, 3, 0,
1120 "Read one Lisp expression which is represented as text by STRING.\n\
1121 Returns a cons: (OBJECT-READ . FINAL-STRING-INDEX).\n\
1122 START and END optionally delimit a substring of STRING from which to read;\n\
1123 they default to 0 and (length STRING) respectively.")
1124 (string
, start
, end
)
1125 Lisp_Object string
, start
, end
;
1127 int startval
, endval
;
1130 CHECK_STRING (string
,0);
1133 endval
= XSTRING (string
)->size
;
1135 { CHECK_NUMBER (end
,2);
1136 endval
= XINT (end
);
1137 if (endval
< 0 || endval
> XSTRING (string
)->size
)
1138 args_out_of_range (string
, end
);
1144 { CHECK_NUMBER (start
,1);
1145 startval
= XINT (start
);
1146 if (startval
< 0 || startval
> endval
)
1147 args_out_of_range (string
, start
);
1150 read_from_string_index
= startval
;
1151 read_from_string_limit
= endval
;
1153 new_backquote_flag
= 0;
1154 read_objects
= Qnil
;
1156 tem
= read0 (string
);
1157 return Fcons (tem
, make_number (read_from_string_index
));
1160 /* Use this for recursive reads, in contexts where internal tokens
1164 Lisp_Object readcharfun
;
1166 register Lisp_Object val
;
1169 val
= read1 (readcharfun
, &c
, 0);
1171 Fsignal (Qinvalid_read_syntax
, Fcons (make_string (&c
, 1), Qnil
));
1176 static int read_buffer_size
;
1177 static char *read_buffer
;
1179 /* Read multibyte form and return it as a character. C is a first
1180 byte of multibyte form, and rest of them are read from
1184 read_multibyte (c
, readcharfun
)
1186 Lisp_Object readcharfun
;
1188 /* We need the actual character code of this multibyte
1190 unsigned char str
[MAX_LENGTH_OF_MULTI_BYTE_FORM
];
1194 while ((c
= READCHAR
) >= 0xA0
1195 && len
< MAX_LENGTH_OF_MULTI_BYTE_FORM
)
1198 return STRING_CHAR (str
, len
);
1201 /* Read a \-escape sequence, assuming we already read the `\'. */
1204 read_escape (readcharfun
)
1205 Lisp_Object readcharfun
;
1207 register int c
= READCHAR
;
1211 error ("End of file");
1237 error ("Invalid escape character syntax");
1240 c
= read_escape (readcharfun
);
1241 return c
| meta_modifier
;
1246 error ("Invalid escape character syntax");
1249 c
= read_escape (readcharfun
);
1250 return c
| shift_modifier
;
1255 error ("Invalid escape character syntax");
1258 c
= read_escape (readcharfun
);
1259 return c
| hyper_modifier
;
1264 error ("Invalid escape character syntax");
1267 c
= read_escape (readcharfun
);
1268 return c
| alt_modifier
;
1273 error ("Invalid escape character syntax");
1276 c
= read_escape (readcharfun
);
1277 return c
| super_modifier
;
1282 error ("Invalid escape character syntax");
1286 c
= read_escape (readcharfun
);
1287 if ((c
& 0177) == '?')
1289 /* ASCII control chars are made from letters (both cases),
1290 as well as the non-letters within 0100...0137. */
1291 else if ((c
& 0137) >= 0101 && (c
& 0137) <= 0132)
1292 return (c
& (037 | ~0177));
1293 else if ((c
& 0177) >= 0100 && (c
& 0177) <= 0137)
1294 return (c
& (037 | ~0177));
1296 return c
| ctrl_modifier
;
1306 /* An octal escape, as in ANSI C. */
1308 register int i
= c
- '0';
1309 register int count
= 0;
1312 if ((c
= READCHAR
) >= '0' && c
<= '7')
1327 /* A hex escape, as in ANSI C. */
1333 if (c
>= '0' && c
<= '9')
1338 else if ((c
>= 'a' && c
<= 'f')
1339 || (c
>= 'A' && c
<= 'F'))
1342 if (c
>= 'a' && c
<= 'f')
1357 if (BASE_LEADING_CODE_P (c
))
1358 c
= read_multibyte (c
, readcharfun
);
1363 /* If the next token is ')' or ']' or '.', we store that character
1364 in *PCH and the return value is not interesting. Else, we store
1365 zero in *PCH and we read and return one lisp object.
1367 FIRST_IN_LIST is nonzero if this is the first element of a list. */
1370 read1 (readcharfun
, pch
, first_in_list
)
1371 register Lisp_Object readcharfun
;
1376 int uninterned_symbol
= 0;
1383 if (c
< 0) return Fsignal (Qend_of_file
, Qnil
);
1388 return read_list (0, readcharfun
);
1391 return read_vector (readcharfun
);
1408 tmp
= read_vector (readcharfun
);
1409 if (XVECTOR (tmp
)->size
< CHAR_TABLE_STANDARD_SLOTS
1410 || XVECTOR (tmp
)->size
> CHAR_TABLE_STANDARD_SLOTS
+ 10)
1411 error ("Invalid size char-table");
1412 XSETCHAR_TABLE (tmp
, XCHAR_TABLE (tmp
));
1413 XCHAR_TABLE (tmp
)->top
= Qt
;
1422 tmp
= read_vector (readcharfun
);
1423 if (XVECTOR (tmp
)->size
!= SUB_CHAR_TABLE_STANDARD_SLOTS
)
1424 error ("Invalid size char-table");
1425 XSETCHAR_TABLE (tmp
, XCHAR_TABLE (tmp
));
1426 XCHAR_TABLE (tmp
)->top
= Qnil
;
1429 Fsignal (Qinvalid_read_syntax
,
1430 Fcons (make_string ("#^^", 3), Qnil
));
1432 Fsignal (Qinvalid_read_syntax
, Fcons (make_string ("#^", 2), Qnil
));
1437 length
= read1 (readcharfun
, pch
, first_in_list
);
1441 Lisp_Object tmp
, val
;
1442 int size_in_chars
= ((XFASTINT (length
) + BITS_PER_CHAR
- 1)
1446 tmp
= read1 (readcharfun
, pch
, first_in_list
);
1447 if (size_in_chars
!= XSTRING (tmp
)->size
1448 /* We used to print 1 char too many
1449 when the number of bits was a multiple of 8.
1450 Accept such input in case it came from an old version. */
1451 && ! (XFASTINT (length
)
1452 == (XSTRING (tmp
)->size
- 1) * BITS_PER_CHAR
))
1453 Fsignal (Qinvalid_read_syntax
,
1454 Fcons (make_string ("#&...", 5), Qnil
));
1456 val
= Fmake_bool_vector (length
, Qnil
);
1457 bcopy (XSTRING (tmp
)->data
, XBOOL_VECTOR (val
)->data
,
1461 Fsignal (Qinvalid_read_syntax
, Fcons (make_string ("#&...", 5),
1466 /* Accept compiled functions at read-time so that we don't have to
1467 build them using function calls. */
1469 tmp
= read_vector (readcharfun
);
1470 return Fmake_byte_code (XVECTOR (tmp
)->size
,
1471 XVECTOR (tmp
)->contents
);
1473 #ifdef USE_TEXT_PROPERTIES
1477 struct gcpro gcpro1
;
1480 /* Read the string itself. */
1481 tmp
= read1 (readcharfun
, &ch
, 0);
1482 if (ch
!= 0 || !STRINGP (tmp
))
1483 Fsignal (Qinvalid_read_syntax
, Fcons (make_string ("#", 1), Qnil
));
1485 /* Read the intervals and their properties. */
1488 Lisp_Object beg
, end
, plist
;
1490 beg
= read1 (readcharfun
, &ch
, 0);
1494 end
= read1 (readcharfun
, &ch
, 0);
1496 plist
= read1 (readcharfun
, &ch
, 0);
1498 Fsignal (Qinvalid_read_syntax
,
1499 Fcons (build_string ("invalid string property list"),
1501 Fset_text_properties (beg
, end
, plist
, tmp
);
1507 /* #@NUMBER is used to skip NUMBER following characters.
1508 That's used in .elc files to skip over doc strings
1509 and function definitions. */
1514 /* Read a decimal integer. */
1515 while ((c
= READCHAR
) >= 0
1516 && c
>= '0' && c
<= '9')
1524 #ifndef DOS_NT /* I don't know if filepos works right on MSDOS and Windoze. */
1525 if (load_force_doc_strings
&& EQ (readcharfun
, Qget_file_char
))
1527 /* If we are supposed to force doc strings into core right now,
1528 record the last string that we skipped,
1529 and record where in the file it comes from. */
1530 if (saved_doc_string_size
== 0)
1532 saved_doc_string_size
= nskip
+ 100;
1533 saved_doc_string
= (char *) xmalloc (saved_doc_string_size
);
1535 if (nskip
> saved_doc_string_size
)
1537 saved_doc_string_size
= nskip
+ 100;
1538 saved_doc_string
= (char *) xrealloc (saved_doc_string
,
1539 saved_doc_string_size
);
1542 saved_doc_string_position
= ftell (instream
);
1544 /* Copy that many characters into saved_doc_string. */
1545 for (i
= 0; i
< nskip
&& c
>= 0; i
++)
1546 saved_doc_string
[i
] = c
= READCHAR
;
1548 saved_doc_string_length
= i
;
1551 #endif /* not DOS_NT */
1553 /* Skip that many characters. */
1554 for (i
= 0; i
< nskip
&& c
>= 0; i
++)
1561 return Vload_file_name
;
1563 return Fcons (Qfunction
, Fcons (read0 (readcharfun
), Qnil
));
1564 /* #:foo is the uninterned symbol named foo. */
1567 uninterned_symbol
= 1;
1571 /* Reader forms that can reuse previously read objects. */
1572 if (c
>= '0' && c
<= '9')
1577 /* Read a non-negative integer. */
1578 while (c
>= '0' && c
<= '9')
1584 /* #n=object returns object, but associates it with n for #n#. */
1587 tem
= read0 (readcharfun
);
1588 read_objects
= Fcons (Fcons (make_number (n
), tem
), read_objects
);
1591 /* #n# returns a previously read object. */
1594 tem
= Fassq (make_number (n
), read_objects
);
1597 /* Fall through to error message. */
1599 /* Fall through to error message. */
1603 Fsignal (Qinvalid_read_syntax
, Fcons (make_string ("#", 1), Qnil
));
1606 while ((c
= READCHAR
) >= 0 && c
!= '\n');
1611 return Fcons (Qquote
, Fcons (read0 (readcharfun
), Qnil
));
1621 new_backquote_flag
= 1;
1622 value
= read0 (readcharfun
);
1623 new_backquote_flag
= 0;
1625 return Fcons (Qbackquote
, Fcons (value
, Qnil
));
1629 if (new_backquote_flag
)
1631 Lisp_Object comma_type
= Qnil
;
1636 comma_type
= Qcomma_at
;
1638 comma_type
= Qcomma_dot
;
1641 if (ch
>= 0) UNREAD (ch
);
1642 comma_type
= Qcomma
;
1645 new_backquote_flag
= 0;
1646 value
= read0 (readcharfun
);
1647 new_backquote_flag
= 1;
1648 return Fcons (comma_type
, Fcons (value
, Qnil
));
1655 register Lisp_Object val
;
1658 if (c
< 0) return Fsignal (Qend_of_file
, Qnil
);
1661 c
= read_escape (readcharfun
);
1662 else if (BASE_LEADING_CODE_P (c
))
1663 c
= read_multibyte (c
, readcharfun
);
1665 return make_number (c
);
1670 register char *p
= read_buffer
;
1671 register char *end
= read_buffer
+ read_buffer_size
;
1675 while ((c
= READCHAR
) >= 0
1680 char *new = (char *) xrealloc (read_buffer
, read_buffer_size
*= 2);
1681 p
+= new - read_buffer
;
1682 read_buffer
+= new - read_buffer
;
1683 end
= read_buffer
+ read_buffer_size
;
1687 c
= read_escape (readcharfun
);
1688 if (! SINGLE_BYTE_CHAR_P ((c
& ~CHAR_META
)))
1690 unsigned char workbuf
[4];
1691 unsigned char *str
= workbuf
;
1694 length
= non_ascii_char_to_string (c
, workbuf
, &str
);
1696 if (p
+ length
> end
)
1698 char *new = (char *) xrealloc (read_buffer
, read_buffer_size
*= 2);
1699 p
+= new - read_buffer
;
1700 read_buffer
+= new - read_buffer
;
1701 end
= read_buffer
+ read_buffer_size
;
1704 bcopy (str
, p
, length
);
1710 /* c is -1 if \ newline has just been seen */
1713 if (p
== read_buffer
)
1718 /* Allow `\C- ' and `\C-?'. */
1719 if (c
== (CHAR_CTL
| ' '))
1721 else if (c
== (CHAR_CTL
| '?'))
1725 /* Move the meta bit to the right place for a string. */
1726 c
= (c
& ~CHAR_META
) | 0x80;
1728 error ("Invalid modifier in string");
1733 return Fsignal (Qend_of_file
, Qnil
);
1735 /* If purifying, and string starts with \ newline,
1736 return zero instead. This is for doc strings
1737 that we are really going to find in etc/DOC.nn.nn */
1738 if (!NILP (Vpurify_flag
) && NILP (Vdoc_file_name
) && cancel
)
1739 return make_number (0);
1742 return make_pure_string (read_buffer
, p
- read_buffer
);
1744 return make_string (read_buffer
, p
- read_buffer
);
1749 #ifdef LISP_FLOAT_TYPE
1750 /* If a period is followed by a number, then we should read it
1751 as a floating point number. Otherwise, it denotes a dotted
1753 int next_char
= READCHAR
;
1756 if (! (next_char
>= '0' && next_char
<= '9'))
1763 /* Otherwise, we fall through! Note that the atom-reading loop
1764 below will now loop at least once, assuring that we will not
1765 try to UNREAD two characters in a row. */
1769 if (c
<= 040) goto retry
;
1771 register char *p
= read_buffer
;
1775 register char *end
= read_buffer
+ read_buffer_size
;
1778 && !(c
== '\"' || c
== '\'' || c
== ';' || c
== '?'
1779 || c
== '(' || c
== ')'
1780 #ifndef LISP_FLOAT_TYPE
1781 /* If we have floating-point support, then we need
1782 to allow <digits><dot><digits>. */
1784 #endif /* not LISP_FLOAT_TYPE */
1785 || c
== '[' || c
== ']' || c
== '#'
1790 register char *new = (char *) xrealloc (read_buffer
, read_buffer_size
*= 2);
1791 p
+= new - read_buffer
;
1792 read_buffer
+= new - read_buffer
;
1793 end
= read_buffer
+ read_buffer_size
;
1808 char *new = (char *) xrealloc (read_buffer
, read_buffer_size
*= 2);
1809 p
+= new - read_buffer
;
1810 read_buffer
+= new - read_buffer
;
1811 /* end = read_buffer + read_buffer_size; */
1818 if (!quoted
&& !uninterned_symbol
)
1821 register Lisp_Object val
;
1823 if (*p1
== '+' || *p1
== '-') p1
++;
1824 /* Is it an integer? */
1827 while (p1
!= p
&& (c
= *p1
) >= '0' && c
<= '9') p1
++;
1828 #ifdef LISP_FLOAT_TYPE
1829 /* Integers can have trailing decimal points. */
1830 if (p1
> read_buffer
&& p1
< p
&& *p1
== '.') p1
++;
1833 /* It is an integer. */
1835 #ifdef LISP_FLOAT_TYPE
1839 if (sizeof (int) == sizeof (EMACS_INT
))
1840 XSETINT (val
, atoi (read_buffer
));
1841 else if (sizeof (long) == sizeof (EMACS_INT
))
1842 XSETINT (val
, atol (read_buffer
));
1848 #ifdef LISP_FLOAT_TYPE
1849 if (isfloat_string (read_buffer
))
1850 return make_float (atof (read_buffer
));
1854 if (uninterned_symbol
)
1855 return make_symbol (read_buffer
);
1857 return intern (read_buffer
);
1862 #ifdef LISP_FLOAT_TYPE
1877 if (*cp
== '+' || *cp
== '-')
1880 if (*cp
>= '0' && *cp
<= '9')
1883 while (*cp
>= '0' && *cp
<= '9')
1891 if (*cp
>= '0' && *cp
<= '9')
1894 while (*cp
>= '0' && *cp
<= '9')
1897 if (*cp
== 'e' || *cp
== 'E')
1901 if (*cp
== '+' || *cp
== '-')
1905 if (*cp
>= '0' && *cp
<= '9')
1908 while (*cp
>= '0' && *cp
<= '9')
1911 return (((*cp
== 0) || (*cp
== ' ') || (*cp
== '\t') || (*cp
== '\n') || (*cp
== '\r') || (*cp
== '\f'))
1912 && (state
== (LEAD_INT
|DOT_CHAR
|TRAIL_INT
)
1913 || state
== (DOT_CHAR
|TRAIL_INT
)
1914 || state
== (LEAD_INT
|E_CHAR
|EXP_INT
)
1915 || state
== (LEAD_INT
|DOT_CHAR
|TRAIL_INT
|E_CHAR
|EXP_INT
)
1916 || state
== (DOT_CHAR
|TRAIL_INT
|E_CHAR
|EXP_INT
)));
1918 #endif /* LISP_FLOAT_TYPE */
1921 read_vector (readcharfun
)
1922 Lisp_Object readcharfun
;
1926 register Lisp_Object
*ptr
;
1927 register Lisp_Object tem
, vector
;
1928 register struct Lisp_Cons
*otem
;
1931 tem
= read_list (1, readcharfun
);
1932 len
= Flength (tem
);
1933 vector
= (read_pure
? make_pure_vector (XINT (len
)) : Fmake_vector (len
, Qnil
));
1936 size
= XVECTOR (vector
)->size
;
1937 ptr
= XVECTOR (vector
)->contents
;
1938 for (i
= 0; i
< size
; i
++)
1940 ptr
[i
] = read_pure
? Fpurecopy (Fcar (tem
)) : Fcar (tem
);
1948 /* FLAG = 1 means check for ] to terminate rather than ) and .
1949 FLAG = -1 means check for starting with defun
1950 and make structure pure. */
1953 read_list (flag
, readcharfun
)
1955 register Lisp_Object readcharfun
;
1957 /* -1 means check next element for defun,
1958 0 means don't check,
1959 1 means already checked and found defun. */
1960 int defunflag
= flag
< 0 ? -1 : 0;
1961 Lisp_Object val
, tail
;
1962 register Lisp_Object elt
, tem
;
1963 struct gcpro gcpro1
, gcpro2
;
1964 /* 0 is the normal case.
1965 1 means this list is a doc reference; replace it with the number 0.
1966 2 means this list is a doc reference; replace it with the doc string. */
1967 int doc_reference
= 0;
1969 /* Initialize this to 1 if we are reading a list. */
1970 int first_in_list
= flag
<= 0;
1979 elt
= read1 (readcharfun
, &ch
, first_in_list
);
1984 /* While building, if the list starts with #$, treat it specially. */
1985 if (EQ (elt
, Vload_file_name
)
1987 && !NILP (Vpurify_flag
))
1989 if (NILP (Vdoc_file_name
))
1990 /* We have not yet called Snarf-documentation, so assume
1991 this file is described in the DOC-MM.NN file
1992 and Snarf-documentation will fill in the right value later.
1993 For now, replace the whole list with 0. */
1996 /* We have already called Snarf-documentation, so make a relative
1997 file name for this file, so it can be found properly
1998 in the installed Lisp directory.
1999 We don't use Fexpand_file_name because that would make
2000 the directory absolute now. */
2001 elt
= concat2 (build_string ("../lisp/"),
2002 Ffile_name_nondirectory (elt
));
2004 else if (EQ (elt
, Vload_file_name
)
2006 && load_force_doc_strings
)
2015 Fsignal (Qinvalid_read_syntax
,
2016 Fcons (make_string (") or . in a vector", 18), Qnil
));
2024 XCONS (tail
)->cdr
= read0 (readcharfun
);
2026 val
= read0 (readcharfun
);
2027 read1 (readcharfun
, &ch
, 0);
2031 if (doc_reference
== 1)
2032 return make_number (0);
2033 if (doc_reference
== 2)
2035 /* Get a doc string from the file we are loading.
2036 If it's in saved_doc_string, get it from there. */
2037 int pos
= XINT (XCONS (val
)->cdr
);
2038 if (pos
>= saved_doc_string_position
2039 && pos
< (saved_doc_string_position
2040 + saved_doc_string_length
))
2042 int start
= pos
- saved_doc_string_position
;
2045 /* Process quoting with ^A,
2046 and find the end of the string,
2047 which is marked with ^_ (037). */
2048 for (from
= start
, to
= start
;
2049 saved_doc_string
[from
] != 037;)
2051 int c
= saved_doc_string
[from
++];
2054 c
= saved_doc_string
[from
++];
2056 saved_doc_string
[to
++] = c
;
2058 saved_doc_string
[to
++] = 0;
2060 saved_doc_string
[to
++] = 037;
2063 saved_doc_string
[to
++] = c
;
2066 return make_string (saved_doc_string
+ start
,
2070 return read_doc_string (val
);
2075 return Fsignal (Qinvalid_read_syntax
, Fcons (make_string (". in wrong context", 18), Qnil
));
2077 return Fsignal (Qinvalid_read_syntax
, Fcons (make_string ("] in a list", 11), Qnil
));
2079 tem
= (read_pure
&& flag
<= 0
2080 ? pure_cons (elt
, Qnil
)
2081 : Fcons (elt
, Qnil
));
2083 XCONS (tail
)->cdr
= tem
;
2088 defunflag
= EQ (elt
, Qdefun
);
2089 else if (defunflag
> 0)
2094 Lisp_Object Vobarray
;
2095 Lisp_Object initial_obarray
;
2097 /* oblookup stores the bucket number here, for the sake of Funintern. */
2099 int oblookup_last_bucket_number
;
2101 static int hash_string ();
2102 Lisp_Object
oblookup ();
2104 /* Get an error if OBARRAY is not an obarray.
2105 If it is one, return it. */
2108 check_obarray (obarray
)
2109 Lisp_Object obarray
;
2111 while (!VECTORP (obarray
) || XVECTOR (obarray
)->size
== 0)
2113 /* If Vobarray is now invalid, force it to be valid. */
2114 if (EQ (Vobarray
, obarray
)) Vobarray
= initial_obarray
;
2116 obarray
= wrong_type_argument (Qvectorp
, obarray
);
2121 /* Intern the C string STR: return a symbol with that name,
2122 interned in the current obarray. */
2129 int len
= strlen (str
);
2130 Lisp_Object obarray
;
2133 if (!VECTORP (obarray
) || XVECTOR (obarray
)->size
== 0)
2134 obarray
= check_obarray (obarray
);
2135 tem
= oblookup (obarray
, str
, len
);
2138 return Fintern (make_string (str
, len
), obarray
);
2141 /* Create an uninterned symbol with name STR. */
2147 int len
= strlen (str
);
2149 return Fmake_symbol ((!NILP (Vpurify_flag
)
2150 ? make_pure_string (str
, len
)
2151 : make_string (str
, len
)));
2154 DEFUN ("intern", Fintern
, Sintern
, 1, 2, 0,
2155 "Return the canonical symbol whose name is STRING.\n\
2156 If there is none, one is created by this function and returned.\n\
2157 A second optional argument specifies the obarray to use;\n\
2158 it defaults to the value of `obarray'.")
2160 Lisp_Object string
, obarray
;
2162 register Lisp_Object tem
, sym
, *ptr
;
2164 if (NILP (obarray
)) obarray
= Vobarray
;
2165 obarray
= check_obarray (obarray
);
2167 CHECK_STRING (string
, 0);
2169 tem
= oblookup (obarray
, XSTRING (string
)->data
, XSTRING (string
)->size
);
2170 if (!INTEGERP (tem
))
2173 if (!NILP (Vpurify_flag
))
2174 string
= Fpurecopy (string
);
2175 sym
= Fmake_symbol (string
);
2176 XSYMBOL (sym
)->obarray
= obarray
;
2178 if (XSTRING (string
)->data
[0] == ':')
2179 XSYMBOL (sym
)->value
= sym
;
2181 ptr
= &XVECTOR (obarray
)->contents
[XINT (tem
)];
2183 XSYMBOL (sym
)->next
= XSYMBOL (*ptr
);
2185 XSYMBOL (sym
)->next
= 0;
2190 DEFUN ("intern-soft", Fintern_soft
, Sintern_soft
, 1, 2, 0,
2191 "Return the canonical symbol whose name is STRING, or nil if none exists.\n\
2192 A second optional argument specifies the obarray to use;\n\
2193 it defaults to the value of `obarray'.")
2195 Lisp_Object string
, obarray
;
2197 register Lisp_Object tem
;
2199 if (NILP (obarray
)) obarray
= Vobarray
;
2200 obarray
= check_obarray (obarray
);
2202 CHECK_STRING (string
, 0);
2204 tem
= oblookup (obarray
, XSTRING (string
)->data
, XSTRING (string
)->size
);
2205 if (!INTEGERP (tem
))
2210 DEFUN ("unintern", Funintern
, Sunintern
, 1, 2, 0,
2211 "Delete the symbol named NAME, if any, from OBARRAY.\n\
2212 The value is t if a symbol was found and deleted, nil otherwise.\n\
2213 NAME may be a string or a symbol. If it is a symbol, that symbol\n\
2214 is deleted, if it belongs to OBARRAY--no other symbol is deleted.\n\
2215 OBARRAY defaults to the value of the variable `obarray'.")
2217 Lisp_Object name
, obarray
;
2219 register Lisp_Object string
, tem
;
2222 if (NILP (obarray
)) obarray
= Vobarray
;
2223 obarray
= check_obarray (obarray
);
2226 XSETSTRING (string
, XSYMBOL (name
)->name
);
2229 CHECK_STRING (name
, 0);
2233 tem
= oblookup (obarray
, XSTRING (string
)->data
, XSTRING (string
)->size
);
2236 /* If arg was a symbol, don't delete anything but that symbol itself. */
2237 if (SYMBOLP (name
) && !EQ (name
, tem
))
2240 hash
= oblookup_last_bucket_number
;
2242 if (EQ (XVECTOR (obarray
)->contents
[hash
], tem
))
2244 if (XSYMBOL (tem
)->next
)
2245 XSETSYMBOL (XVECTOR (obarray
)->contents
[hash
], XSYMBOL (tem
)->next
);
2247 XSETINT (XVECTOR (obarray
)->contents
[hash
], 0);
2251 Lisp_Object tail
, following
;
2253 for (tail
= XVECTOR (obarray
)->contents
[hash
];
2254 XSYMBOL (tail
)->next
;
2257 XSETSYMBOL (following
, XSYMBOL (tail
)->next
);
2258 if (EQ (following
, tem
))
2260 XSYMBOL (tail
)->next
= XSYMBOL (following
)->next
;
2269 /* Return the symbol in OBARRAY whose names matches the string
2270 of SIZE characters at PTR. If there is no such symbol in OBARRAY,
2273 Also store the bucket number in oblookup_last_bucket_number. */
2276 oblookup (obarray
, ptr
, size
)
2277 Lisp_Object obarray
;
2283 register Lisp_Object tail
;
2284 Lisp_Object bucket
, tem
;
2286 if (!VECTORP (obarray
)
2287 || (obsize
= XVECTOR (obarray
)->size
) == 0)
2289 obarray
= check_obarray (obarray
);
2290 obsize
= XVECTOR (obarray
)->size
;
2292 /* This is sometimes needed in the middle of GC. */
2293 obsize
&= ~ARRAY_MARK_FLAG
;
2294 /* Combining next two lines breaks VMS C 2.3. */
2295 hash
= hash_string (ptr
, size
);
2297 bucket
= XVECTOR (obarray
)->contents
[hash
];
2298 oblookup_last_bucket_number
= hash
;
2299 if (XFASTINT (bucket
) == 0)
2301 else if (!SYMBOLP (bucket
))
2302 error ("Bad data in guts of obarray"); /* Like CADR error message */
2304 for (tail
= bucket
; ; XSETSYMBOL (tail
, XSYMBOL (tail
)->next
))
2306 if (XSYMBOL (tail
)->name
->size
== size
2307 && !bcmp (XSYMBOL (tail
)->name
->data
, ptr
, size
))
2309 else if (XSYMBOL (tail
)->next
== 0)
2312 XSETINT (tem
, hash
);
2317 hash_string (ptr
, len
)
2321 register unsigned char *p
= ptr
;
2322 register unsigned char *end
= p
+ len
;
2323 register unsigned char c
;
2324 register int hash
= 0;
2329 if (c
>= 0140) c
-= 40;
2330 hash
= ((hash
<<3) + (hash
>>28) + c
);
2332 return hash
& 07777777777;
2336 map_obarray (obarray
, fn
, arg
)
2337 Lisp_Object obarray
;
2338 void (*fn
) P_ ((Lisp_Object
, Lisp_Object
));
2342 register Lisp_Object tail
;
2343 CHECK_VECTOR (obarray
, 1);
2344 for (i
= XVECTOR (obarray
)->size
- 1; i
>= 0; i
--)
2346 tail
= XVECTOR (obarray
)->contents
[i
];
2351 if (XSYMBOL (tail
)->next
== 0)
2353 XSETSYMBOL (tail
, XSYMBOL (tail
)->next
);
2359 mapatoms_1 (sym
, function
)
2360 Lisp_Object sym
, function
;
2362 call1 (function
, sym
);
2365 DEFUN ("mapatoms", Fmapatoms
, Smapatoms
, 1, 2, 0,
2366 "Call FUNCTION on every symbol in OBARRAY.\n\
2367 OBARRAY defaults to the value of `obarray'.")
2369 Lisp_Object function
, obarray
;
2373 if (NILP (obarray
)) obarray
= Vobarray
;
2374 obarray
= check_obarray (obarray
);
2376 map_obarray (obarray
, mapatoms_1
, function
);
2380 #define OBARRAY_SIZE 1511
2385 Lisp_Object oblength
;
2389 XSETFASTINT (oblength
, OBARRAY_SIZE
);
2391 Qnil
= Fmake_symbol (make_pure_string ("nil", 3));
2392 Vobarray
= Fmake_vector (oblength
, make_number (0));
2393 initial_obarray
= Vobarray
;
2394 staticpro (&initial_obarray
);
2395 /* Intern nil in the obarray */
2396 XSYMBOL (Qnil
)->obarray
= Vobarray
;
2397 /* These locals are to kludge around a pyramid compiler bug. */
2398 hash
= hash_string ("nil", 3);
2399 /* Separate statement here to avoid VAXC bug. */
2400 hash
%= OBARRAY_SIZE
;
2401 tem
= &XVECTOR (Vobarray
)->contents
[hash
];
2404 Qunbound
= Fmake_symbol (make_pure_string ("unbound", 7));
2405 XSYMBOL (Qnil
)->function
= Qunbound
;
2406 XSYMBOL (Qunbound
)->value
= Qunbound
;
2407 XSYMBOL (Qunbound
)->function
= Qunbound
;
2410 XSYMBOL (Qnil
)->value
= Qnil
;
2411 XSYMBOL (Qnil
)->plist
= Qnil
;
2412 XSYMBOL (Qt
)->value
= Qt
;
2414 /* Qt is correct even if CANNOT_DUMP. loadup.el will set to nil at end. */
2417 Qvariable_documentation
= intern ("variable-documentation");
2418 staticpro (&Qvariable_documentation
);
2420 read_buffer_size
= 100;
2421 read_buffer
= (char *) malloc (read_buffer_size
);
2426 struct Lisp_Subr
*sname
;
2429 sym
= intern (sname
->symbol_name
);
2430 XSETSUBR (XSYMBOL (sym
)->function
, sname
);
2433 #ifdef NOTDEF /* use fset in subr.el now */
2435 defalias (sname
, string
)
2436 struct Lisp_Subr
*sname
;
2440 sym
= intern (string
);
2441 XSETSUBR (XSYMBOL (sym
)->function
, sname
);
2445 /* Define an "integer variable"; a symbol whose value is forwarded
2446 to a C variable of type int. Sample call: */
2447 /* DEFVAR_INT ("indent-tabs-mode", &indent_tabs_mode, "Documentation"); */
2449 defvar_int (namestring
, address
)
2453 Lisp_Object sym
, val
;
2454 sym
= intern (namestring
);
2455 val
= allocate_misc ();
2456 XMISCTYPE (val
) = Lisp_Misc_Intfwd
;
2457 XINTFWD (val
)->intvar
= address
;
2458 XSYMBOL (sym
)->value
= val
;
2461 /* Similar but define a variable whose value is T if address contains 1,
2462 NIL if address contains 0 */
2464 defvar_bool (namestring
, address
)
2468 Lisp_Object sym
, val
;
2469 sym
= intern (namestring
);
2470 val
= allocate_misc ();
2471 XMISCTYPE (val
) = Lisp_Misc_Boolfwd
;
2472 XBOOLFWD (val
)->boolvar
= address
;
2473 XSYMBOL (sym
)->value
= val
;
2476 /* Similar but define a variable whose value is the Lisp Object stored
2477 at address. Two versions: with and without gc-marking of the C
2478 variable. The nopro version is used when that variable will be
2479 gc-marked for some other reason, since marking the same slot twice
2480 can cause trouble with strings. */
2482 defvar_lisp_nopro (namestring
, address
)
2484 Lisp_Object
*address
;
2486 Lisp_Object sym
, val
;
2487 sym
= intern (namestring
);
2488 val
= allocate_misc ();
2489 XMISCTYPE (val
) = Lisp_Misc_Objfwd
;
2490 XOBJFWD (val
)->objvar
= address
;
2491 XSYMBOL (sym
)->value
= val
;
2495 defvar_lisp (namestring
, address
)
2497 Lisp_Object
*address
;
2499 defvar_lisp_nopro (namestring
, address
);
2500 staticpro (address
);
2505 /* Similar but define a variable whose value is the Lisp Object stored in
2506 the current buffer. address is the address of the slot in the buffer
2507 that is current now. */
2510 defvar_per_buffer (namestring
, address
, type
, doc
)
2512 Lisp_Object
*address
;
2516 Lisp_Object sym
, val
;
2518 extern struct buffer buffer_local_symbols
;
2520 sym
= intern (namestring
);
2521 val
= allocate_misc ();
2522 offset
= (char *)address
- (char *)current_buffer
;
2524 XMISCTYPE (val
) = Lisp_Misc_Buffer_Objfwd
;
2525 XBUFFER_OBJFWD (val
)->offset
= offset
;
2526 XSYMBOL (sym
)->value
= val
;
2527 *(Lisp_Object
*)(offset
+ (char *)&buffer_local_symbols
) = sym
;
2528 *(Lisp_Object
*)(offset
+ (char *)&buffer_local_types
) = type
;
2529 if (XINT (*(Lisp_Object
*)(offset
+ (char *)&buffer_local_flags
)) == 0)
2530 /* Did a DEFVAR_PER_BUFFER without initializing the corresponding
2531 slot of buffer_local_flags */
2535 #endif /* standalone */
2537 /* Similar but define a variable whose value is the Lisp Object stored
2538 at a particular offset in the current kboard object. */
2541 defvar_kboard (namestring
, offset
)
2545 Lisp_Object sym
, val
;
2546 sym
= intern (namestring
);
2547 val
= allocate_misc ();
2548 XMISCTYPE (val
) = Lisp_Misc_Kboard_Objfwd
;
2549 XKBOARD_OBJFWD (val
)->offset
= offset
;
2550 XSYMBOL (sym
)->value
= val
;
2553 /* Record the value of load-path used at the start of dumping
2554 so we can see if the site changed it later during dumping. */
2555 static Lisp_Object dump_path
;
2561 int turn_off_warning
= 0;
2563 #ifdef HAVE_SETLOCALE
2564 /* Make sure numbers are parsed as we expect. */
2565 setlocale (LC_NUMERIC
, "C");
2566 #endif /* HAVE_SETLOCALE */
2568 /* Compute the default load-path. */
2570 normal
= PATH_LOADSEARCH
;
2571 Vload_path
= decode_env_path (0, normal
);
2573 if (NILP (Vpurify_flag
))
2574 normal
= PATH_LOADSEARCH
;
2576 normal
= PATH_DUMPLOADSEARCH
;
2578 /* In a dumped Emacs, we normally have to reset the value of
2579 Vload_path from PATH_LOADSEARCH, since the value that was dumped
2580 uses ../lisp, instead of the path of the installed elisp
2581 libraries. However, if it appears that Vload_path was changed
2582 from the default before dumping, don't override that value. */
2585 if (! NILP (Fequal (dump_path
, Vload_path
)))
2587 Vload_path
= decode_env_path (0, normal
);
2588 if (!NILP (Vinstallation_directory
))
2590 /* Add to the path the lisp subdir of the
2591 installation dir, if it exists. */
2592 Lisp_Object tem
, tem1
;
2593 tem
= Fexpand_file_name (build_string ("lisp"),
2594 Vinstallation_directory
);
2595 tem1
= Ffile_exists_p (tem
);
2598 if (NILP (Fmember (tem
, Vload_path
)))
2600 turn_off_warning
= 1;
2601 Vload_path
= nconc2 (Vload_path
, Fcons (tem
, Qnil
));
2605 /* That dir doesn't exist, so add the build-time
2606 Lisp dirs instead. */
2607 Vload_path
= nconc2 (Vload_path
, dump_path
);
2609 /* Add leim under the installation dir, if it exists. */
2610 tem
= Fexpand_file_name (build_string ("leim"),
2611 Vinstallation_directory
);
2612 tem1
= Ffile_exists_p (tem
);
2615 if (NILP (Fmember (tem
, Vload_path
)))
2616 Vload_path
= nconc2 (Vload_path
, Fcons (tem
, Qnil
));
2619 /* Add site-list under the installation dir, if it exists. */
2620 tem
= Fexpand_file_name (build_string ("site-lisp"),
2621 Vinstallation_directory
);
2622 tem1
= Ffile_exists_p (tem
);
2625 if (NILP (Fmember (tem
, Vload_path
)))
2626 Vload_path
= nconc2 (Vload_path
, Fcons (tem
, Qnil
));
2629 /* If Emacs was not built in the source directory,
2630 and it is run from where it was built, add to load-path
2631 the lisp, leim and site-lisp dirs under that directory. */
2633 if (NILP (Fequal (Vinstallation_directory
, Vsource_directory
)))
2637 tem
= Fexpand_file_name (build_string ("src/Makefile"),
2638 Vinstallation_directory
);
2639 tem1
= Ffile_exists_p (tem
);
2641 /* Don't be fooled if they moved the entire source tree
2642 AFTER dumping Emacs. If the build directory is indeed
2643 different from the source dir, src/Makefile.in and
2644 src/Makefile will not be found together. */
2645 tem
= Fexpand_file_name (build_string ("src/Makefile.in"),
2646 Vinstallation_directory
);
2647 tem2
= Ffile_exists_p (tem
);
2648 if (!NILP (tem1
) && NILP (tem2
))
2650 tem
= Fexpand_file_name (build_string ("lisp"),
2653 if (NILP (Fmember (tem
, Vload_path
)))
2654 Vload_path
= nconc2 (Vload_path
, Fcons (tem
, Qnil
));
2656 tem
= Fexpand_file_name (build_string ("leim"),
2659 if (NILP (Fmember (tem
, Vload_path
)))
2660 Vload_path
= nconc2 (Vload_path
, Fcons (tem
, Qnil
));
2662 tem
= Fexpand_file_name (build_string ("site-lisp"),
2665 if (NILP (Fmember (tem
, Vload_path
)))
2666 Vload_path
= nconc2 (Vload_path
, Fcons (tem
, Qnil
));
2674 /* NORMAL refers to the lisp dir in the source directory. */
2675 /* We used to add ../lisp at the front here, but
2676 that caused trouble because it was copied from dump_path
2677 into Vload_path, aboe, when Vinstallation_directory was non-nil.
2678 It should be unnecessary. */
2679 Vload_path
= decode_env_path (0, normal
);
2680 dump_path
= Vload_path
;
2685 /* When Emacs is invoked over network shares on NT, PATH_LOADSEARCH is
2686 almost never correct, thereby causing a warning to be printed out that
2687 confuses users. Since PATH_LOADSEARCH is always overridden by the
2688 EMACSLOADPATH environment variable below, disable the warning on NT. */
2690 /* Warn if dirs in the *standard* path don't exist. */
2691 if (!turn_off_warning
)
2693 Lisp_Object path_tail
;
2695 for (path_tail
= Vload_path
;
2697 path_tail
= XCONS (path_tail
)->cdr
)
2699 Lisp_Object dirfile
;
2700 dirfile
= Fcar (path_tail
);
2701 if (STRINGP (dirfile
))
2703 dirfile
= Fdirectory_file_name (dirfile
);
2704 if (access (XSTRING (dirfile
)->data
, 0) < 0)
2705 dir_warning ("Warning: Lisp directory `%s' does not exist.\n",
2706 XCONS (path_tail
)->car
);
2710 #endif /* WINDOWSNT */
2712 /* If the EMACSLOADPATH environment variable is set, use its value.
2713 This doesn't apply if we're dumping. */
2715 if (NILP (Vpurify_flag
)
2716 && egetenv ("EMACSLOADPATH"))
2718 Vload_path
= decode_env_path ("EMACSLOADPATH", normal
);
2722 load_in_progress
= 0;
2723 Vload_file_name
= Qnil
;
2725 load_descriptor_list
= Qnil
;
2728 /* Print a warning, using format string FORMAT, that directory DIRNAME
2729 does not exist. Print it on stderr and put it in *Message*. */
2732 dir_warning (format
, dirname
)
2734 Lisp_Object dirname
;
2737 = (char *) alloca (XSTRING (dirname
)->size
+ strlen (format
) + 5);
2739 fprintf (stderr
, format
, XSTRING (dirname
)->data
);
2740 sprintf (buffer
, format
, XSTRING (dirname
)->data
);
2741 message_dolog (buffer
, strlen (buffer
), 0);
2748 defsubr (&Sread_from_string
);
2750 defsubr (&Sintern_soft
);
2751 defsubr (&Sunintern
);
2753 defsubr (&Seval_buffer
);
2754 defsubr (&Seval_region
);
2755 defsubr (&Sread_char
);
2756 defsubr (&Sread_char_exclusive
);
2757 defsubr (&Sread_event
);
2758 defsubr (&Sget_file_char
);
2759 defsubr (&Smapatoms
);
2761 DEFVAR_LISP ("obarray", &Vobarray
,
2762 "Symbol table for use by `intern' and `read'.\n\
2763 It is a vector whose length ought to be prime for best results.\n\
2764 The vector's contents don't make sense if examined from Lisp programs;\n\
2765 to find all the symbols in an obarray, use `mapatoms'.");
2767 DEFVAR_LISP ("values", &Vvalues
,
2768 "List of values of all expressions which were read, evaluated and printed.\n\
2769 Order is reverse chronological.");
2771 DEFVAR_LISP ("standard-input", &Vstandard_input
,
2772 "Stream for read to get input from.\n\
2773 See documentation of `read' for possible values.");
2774 Vstandard_input
= Qt
;
2776 DEFVAR_LISP ("load-path", &Vload_path
,
2777 "*List of directories to search for files to load.\n\
2778 Each element is a string (directory name) or nil (try default directory).\n\
2779 Initialized based on EMACSLOADPATH environment variable, if any,\n\
2780 otherwise to default specified by file `paths.h' when Emacs was built.");
2782 DEFVAR_BOOL ("load-in-progress", &load_in_progress
,
2783 "Non-nil iff inside of `load'.");
2785 DEFVAR_LISP ("after-load-alist", &Vafter_load_alist
,
2786 "An alist of expressions to be evalled when particular files are loaded.\n\
2787 Each element looks like (FILENAME FORMS...).\n\
2788 When `load' is run and the file-name argument is FILENAME,\n\
2789 the FORMS in the corresponding element are executed at the end of loading.\n\n\
2790 FILENAME must match exactly! Normally FILENAME is the name of a library,\n\
2791 with no directory specified, since that is how `load' is normally called.\n\
2792 An error in FORMS does not undo the load,\n\
2793 but does prevent execution of the rest of the FORMS.");
2794 Vafter_load_alist
= Qnil
;
2796 DEFVAR_LISP ("load-history", &Vload_history
,
2797 "Alist mapping source file names to symbols and features.\n\
2798 Each alist element is a list that starts with a file name,\n\
2799 except for one element (optional) that starts with nil and describes\n\
2800 definitions evaluated from buffers not visiting files.\n\
2801 The remaining elements of each list are symbols defined as functions\n\
2802 or variables, and cons cells `(provide . FEATURE)' and `(require . FEATURE)'.");
2803 Vload_history
= Qnil
;
2805 DEFVAR_LISP ("load-file-name", &Vload_file_name
,
2806 "Full name of file being loaded by `load'.");
2807 Vload_file_name
= Qnil
;
2809 DEFVAR_LISP ("current-load-list", &Vcurrent_load_list
,
2810 "Used for internal purposes by `load'.");
2811 Vcurrent_load_list
= Qnil
;
2813 DEFVAR_LISP ("load-read-function", &Vload_read_function
,
2814 "Function used by `load' and `eval-region' for reading expressions.\n\
2815 The default is nil, which means use the function `read'.");
2816 Vload_read_function
= Qnil
;
2818 DEFVAR_LISP ("load-source-file-function", &Vload_source_file_function
,
2819 "Function called in `load' for loading an Emacs lisp source file.\n\
2820 This function is for doing code conversion before reading the source file.\n\
2821 If nil, loading is done without any code conversion.\n\
2822 Arguments are FULLNAME, FILE, NOERROR, NOMESSAGE, where\n\
2823 FULLNAME is the full name of FILE.\n\
2824 See `load' for the meaning of the remaining arguments.");
2825 Vload_source_file_function
= Qnil
;
2827 DEFVAR_BOOL ("load-force-doc-strings", &load_force_doc_strings
,
2828 "Non-nil means `load' should force-load all dynamic doc strings.\n\
2829 This is useful when the file being loaded is a temporary copy.");
2830 load_force_doc_strings
= 0;
2832 DEFVAR_LISP ("source-directory", &Vsource_directory
,
2833 "Directory in which Emacs sources were found when Emacs was built.\n\
2834 You cannot count on them to still be there!");
2836 = Fexpand_file_name (build_string ("../"),
2837 Fcar (decode_env_path (0, PATH_DUMPLOADSEARCH
)));
2839 DEFVAR_LISP ("preloaded-file-list", &Vpreloaded_file_list
,
2840 "List of files that were preloaded (when dumping Emacs).");
2841 Vpreloaded_file_list
= Qnil
;
2843 /* Vsource_directory was initialized in init_lread. */
2845 load_descriptor_list
= Qnil
;
2846 staticpro (&load_descriptor_list
);
2848 Qcurrent_load_list
= intern ("current-load-list");
2849 staticpro (&Qcurrent_load_list
);
2851 Qstandard_input
= intern ("standard-input");
2852 staticpro (&Qstandard_input
);
2854 Qread_char
= intern ("read-char");
2855 staticpro (&Qread_char
);
2857 Qget_file_char
= intern ("get-file-char");
2858 staticpro (&Qget_file_char
);
2860 Qbackquote
= intern ("`");
2861 staticpro (&Qbackquote
);
2862 Qcomma
= intern (",");
2863 staticpro (&Qcomma
);
2864 Qcomma_at
= intern (",@");
2865 staticpro (&Qcomma_at
);
2866 Qcomma_dot
= intern (",.");
2867 staticpro (&Qcomma_dot
);
2869 Qinhibit_file_name_operation
= intern ("inhibit-file-name-operation");
2870 staticpro (&Qinhibit_file_name_operation
);
2872 Qascii_character
= intern ("ascii-character");
2873 staticpro (&Qascii_character
);
2875 Qfunction
= intern ("function");
2876 staticpro (&Qfunction
);
2878 Qload
= intern ("load");
2881 Qload_file_name
= intern ("load-file-name");
2882 staticpro (&Qload_file_name
);
2884 staticpro (&dump_path
);
2886 staticpro (&read_objects
);
2887 read_objects
= Qnil
;