1 /* Lisp parsing and input streams.
2 Copyright (C) 1985, 86, 87, 88, 89, 93, 94, 95, 97, 1998
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 (! NILP (inbuffer
->enable_multibyte_characters
))
215 XMARKER (readcharfun
)->bytepos
= bytepos
;
216 XMARKER (readcharfun
)->charpos
++;
218 readchar_backlog
= bytepos
- orig_bytepos
;
221 return *(BUF_BEG_ADDR (inbuffer
) + XMARKER (readcharfun
)->bytepos
222 - readchar_backlog
--);
224 if (EQ (readcharfun
, Qget_file_char
))
228 /* Interrupted reads have been observed while reading over the network */
229 while (c
== EOF
&& ferror (instream
) && errno
== EINTR
)
238 if (STRINGP (readcharfun
))
241 /* This used to be return of a conditional expression,
242 but that truncated -1 to a char on VMS. */
243 if (read_from_string_index
< read_from_string_limit
)
244 c
= XSTRING (readcharfun
)->data
[read_from_string_index
++];
251 tem
= call0 (readcharfun
);
258 /* Unread the character C in the way appropriate for the stream READCHARFUN.
259 If the stream is a user function, call it with the char as argument. */
262 unreadchar (readcharfun
, c
)
263 Lisp_Object readcharfun
;
267 /* Don't back up the pointer if we're unreading the end-of-input mark,
268 since readchar didn't advance it when we read it. */
270 else if (BUFFERP (readcharfun
))
272 if (!SINGLE_BYTE_CHAR_P (c
))
276 struct buffer
*b
= XBUFFER (readcharfun
);
277 int bytepos
= BUF_PT_BYTE (b
);
280 if (! NILP (b
->enable_multibyte_characters
))
281 BUF_DEC_POS (b
, bytepos
);
285 BUF_PT_BYTE (b
) = bytepos
;
288 else if (MARKERP (readcharfun
))
290 if (!SINGLE_BYTE_CHAR_P (c
))
294 struct buffer
*b
= XMARKER (readcharfun
)->buffer
;
295 int bytepos
= XMARKER (readcharfun
)->bytepos
;
297 XMARKER (readcharfun
)->charpos
--;
298 if (! NILP (b
->enable_multibyte_characters
))
299 BUF_DEC_POS (b
, bytepos
);
303 XMARKER (readcharfun
)->bytepos
= bytepos
;
306 else if (STRINGP (readcharfun
))
307 read_from_string_index
--;
308 else if (EQ (readcharfun
, Qget_file_char
))
309 ungetc (c
, instream
);
311 call1 (readcharfun
, make_number (c
));
314 static Lisp_Object
read0 (), read1 (), read_list (), read_vector ();
315 static int read_multibyte ();
317 /* get a character from the tty */
319 extern Lisp_Object
read_char ();
321 /* Read input events until we get one that's acceptable for our purposes.
323 If NO_SWITCH_FRAME is non-zero, switch-frame events are stashed
324 until we get a character we like, and then stuffed into
327 If ASCII_REQUIRED is non-zero, we check function key events to see
328 if the unmodified version of the symbol has a Qascii_character
329 property, and use that character, if present.
331 If ERROR_NONASCII is non-zero, we signal an error if the input we
332 get isn't an ASCII character with modifiers. If it's zero but
333 ASCII_REQUIRED is non-zero, we just re-read until we get an ASCII
337 read_filtered_event (no_switch_frame
, ascii_required
, error_nonascii
)
338 int no_switch_frame
, ascii_required
, error_nonascii
;
341 return make_number (getchar ());
343 register Lisp_Object val
, delayed_switch_frame
;
345 delayed_switch_frame
= Qnil
;
347 /* Read until we get an acceptable event. */
349 val
= read_char (0, 0, 0, Qnil
, 0);
354 /* switch-frame events are put off until after the next ASCII
355 character. This is better than signaling an error just because
356 the last characters were typed to a separate minibuffer frame,
357 for example. Eventually, some code which can deal with
358 switch-frame events will read it and process it. */
360 && EVENT_HAS_PARAMETERS (val
)
361 && EQ (EVENT_HEAD (val
), Qswitch_frame
))
363 delayed_switch_frame
= val
;
369 /* Convert certain symbols to their ASCII equivalents. */
372 Lisp_Object tem
, tem1
, tem2
;
373 tem
= Fget (val
, Qevent_symbol_element_mask
);
376 tem1
= Fget (Fcar (tem
), Qascii_character
);
377 /* Merge this symbol's modifier bits
378 with the ASCII equivalent of its basic code. */
380 XSETFASTINT (val
, XINT (tem1
) | XINT (Fcar (Fcdr (tem
))));
384 /* If we don't have a character now, deal with it appropriately. */
389 Vunread_command_events
= Fcons (val
, Qnil
);
390 error ("Non-character input-event");
397 if (! NILP (delayed_switch_frame
))
398 unread_switch_frame
= delayed_switch_frame
;
404 DEFUN ("read-char", Fread_char
, Sread_char
, 0, 0, 0,
405 "Read a character from the command input (keyboard or macro).\n\
406 It is returned as a number.\n\
407 If the user generates an event which is not a character (i.e. a mouse\n\
408 click or function key event), `read-char' signals an error. As an\n\
409 exception, switch-frame events are put off until non-ASCII events can\n\
411 If you want to read non-character events, or ignore them, call\n\
412 `read-event' or `read-char-exclusive' instead.")
415 return read_filtered_event (1, 1, 1);
418 DEFUN ("read-event", Fread_event
, Sread_event
, 0, 0, 0,
419 "Read an event object from the input stream.")
422 return read_filtered_event (0, 0, 0);
425 DEFUN ("read-char-exclusive", Fread_char_exclusive
, Sread_char_exclusive
, 0, 0, 0,
426 "Read a character from the command input (keyboard or macro).\n\
427 It is returned as a number. Non-character events are ignored.")
430 return read_filtered_event (1, 1, 0);
433 DEFUN ("get-file-char", Fget_file_char
, Sget_file_char
, 0, 0, 0,
434 "Don't use this yourself.")
437 register Lisp_Object val
;
438 XSETINT (val
, getc (instream
));
442 static void readevalloop ();
443 static Lisp_Object
load_unwind ();
444 static Lisp_Object
load_descriptor_unwind ();
446 DEFUN ("load", Fload
, Sload
, 1, 5, 0,
447 "Execute a file of Lisp code named FILE.\n\
448 First try FILE with `.elc' appended, then try with `.el',\n\
449 then try FILE unmodified.\n\
450 This function searches the directories in `load-path'.\n\
451 If optional second arg NOERROR is non-nil,\n\
452 report no error if FILE doesn't exist.\n\
453 Print messages at start and end of loading unless\n\
454 optional third arg NOMESSAGE is non-nil.\n\
455 If optional fourth arg NOSUFFIX is non-nil, don't try adding\n\
456 suffixes `.elc' or `.el' to the specified name FILE.\n\
457 If optional fifth arg MUST-SUFFIX is non-nil, insist on\n\
458 the suffix `.elc' or `.el'; don't accept just FILE unless\n\
459 it ends in one of those suffixes or includes a directory name.\n\
460 Return t if file exists.")
461 (file
, noerror
, nomessage
, nosuffix
, must_suffix
)
462 Lisp_Object file
, noerror
, nomessage
, nosuffix
, must_suffix
;
464 register FILE *stream
;
465 register int fd
= -1;
466 register Lisp_Object lispstream
;
467 int count
= specpdl_ptr
- specpdl
;
471 /* 1 means we printed the ".el is newer" message. */
473 /* 1 means we are loading a compiled file. */
477 char *dosmode
= "rt";
480 CHECK_STRING (file
, 0);
482 /* If file name is magic, call the handler. */
483 handler
= Ffind_file_name_handler (file
, Qload
);
485 return call5 (handler
, Qload
, file
, noerror
, nomessage
, nosuffix
);
487 /* Do this after the handler to avoid
488 the need to gcpro noerror, nomessage and nosuffix.
489 (Below here, we care only whether they are nil or not.) */
490 file
= Fsubstitute_in_file_name (file
);
492 /* Avoid weird lossage with null string as arg,
493 since it would try to load a directory as a Lisp file */
494 if (XSTRING (file
)->size
> 0)
496 int size
= XSTRING (file
)->size
;
500 if (! NILP (must_suffix
))
502 /* Don't insist on adding a suffix if FILE already ends with one. */
504 && !strcmp (XSTRING (file
)->data
+ size
- 3, ".el"))
507 && !strcmp (XSTRING (file
)->data
+ size
- 4, ".elc"))
509 /* Don't insist on adding a suffix
510 if the argument includes a directory name. */
511 else if (! NILP (Ffile_name_directory (file
)))
515 fd
= openp (Vload_path
, file
,
516 (!NILP (nosuffix
) ? ""
517 : ! NILP (must_suffix
) ? ".elc:.el"
527 Fsignal (Qfile_error
, Fcons (build_string ("Cannot open load file"),
528 Fcons (file
, Qnil
)));
533 /* If FD is 0, that means openp found a remote file. */
536 handler
= Ffind_file_name_handler (found
, Qload
);
537 return call5 (handler
, Qload
, found
, noerror
, nomessage
, Qt
);
540 if (!bcmp (&(XSTRING (found
)->data
[XSTRING (found
)->size
- 4]),
551 stat ((char *)XSTRING (found
)->data
, &s1
);
552 XSTRING (found
)->data
[XSTRING (found
)->size
- 1] = 0;
553 result
= stat ((char *)XSTRING (found
)->data
, &s2
);
554 if (result
>= 0 && (unsigned) s1
.st_mtime
< (unsigned) s2
.st_mtime
)
556 /* Make the progress messages mention that source is newer. */
559 /* If we won't print another message, mention this anyway. */
560 if (! NILP (nomessage
))
561 message_with_string ("Source file `%s' newer than byte-compiled file",
564 XSTRING (found
)->data
[XSTRING (found
)->size
- 1] = 'c';
568 /* We are loading a source file (*.el). */
569 if (!NILP (Vload_source_file_function
))
572 return call4 (Vload_source_file_function
, found
, file
,
573 NILP (noerror
) ? Qnil
: Qt
,
574 NILP (nomessage
) ? Qnil
: Qt
);
580 stream
= fopen ((char *) XSTRING (found
)->data
, dosmode
);
581 #else /* not DOS_NT */
582 stream
= fdopen (fd
, "r");
583 #endif /* not DOS_NT */
587 error ("Failure to create stdio stream for %s", XSTRING (file
)->data
);
590 if (! NILP (Vpurify_flag
))
591 Vpreloaded_file_list
= Fcons (file
, Vpreloaded_file_list
);
593 if (NILP (nomessage
))
596 message_with_string ("Loading %s (source)...", file
, 1);
598 message_with_string ("Loading %s (compiled; note, source file is newer)...",
600 else /* The typical case; compiled file newer than source file. */
601 message_with_string ("Loading %s...", file
, 1);
605 lispstream
= Fcons (Qnil
, Qnil
);
606 XSETFASTINT (XCONS (lispstream
)->car
, (EMACS_UINT
)stream
>> 16);
607 XSETFASTINT (XCONS (lispstream
)->cdr
, (EMACS_UINT
)stream
& 0xffff);
608 record_unwind_protect (load_unwind
, lispstream
);
609 record_unwind_protect (load_descriptor_unwind
, load_descriptor_list
);
610 specbind (Qload_file_name
, found
);
611 specbind (Qinhibit_file_name_operation
, Qnil
);
613 = Fcons (make_number (fileno (stream
)), load_descriptor_list
);
615 readevalloop (Qget_file_char
, stream
, file
, Feval
, 0);
616 unbind_to (count
, Qnil
);
618 /* Run any load-hooks for this file. */
619 temp
= Fassoc (file
, Vafter_load_alist
);
621 Fprogn (Fcdr (temp
));
624 if (saved_doc_string
)
625 free (saved_doc_string
);
626 saved_doc_string
= 0;
627 saved_doc_string_size
= 0;
629 if (!noninteractive
&& NILP (nomessage
))
632 message_with_string ("Loading %s (source)...done", file
, 1);
634 message_with_string ("Loading %s (compiled; note, source file is newer)...done",
636 else /* The typical case; compiled file newer than source file. */
637 message_with_string ("Loading %s...done", file
, 1);
643 load_unwind (stream
) /* used as unwind-protect function in load */
646 fclose ((FILE *) (XFASTINT (XCONS (stream
)->car
) << 16
647 | XFASTINT (XCONS (stream
)->cdr
)));
648 if (--load_in_progress
< 0) load_in_progress
= 0;
653 load_descriptor_unwind (oldlist
)
656 load_descriptor_list
= oldlist
;
660 /* Close all descriptors in use for Floads.
661 This is used when starting a subprocess. */
668 for (tail
= load_descriptor_list
; !NILP (tail
); tail
= XCONS (tail
)->cdr
)
669 close (XFASTINT (XCONS (tail
)->car
));
674 complete_filename_p (pathname
)
675 Lisp_Object pathname
;
677 register unsigned char *s
= XSTRING (pathname
)->data
;
678 return (IS_DIRECTORY_SEP (s
[0])
679 || (XSTRING (pathname
)->size
> 2
680 && IS_DEVICE_SEP (s
[1]) && IS_DIRECTORY_SEP (s
[2]))
690 /* Search for a file whose name is STR, looking in directories
691 in the Lisp list PATH, and trying suffixes from SUFFIX.
692 SUFFIX is a string containing possible suffixes separated by colons.
693 On success, returns a file descriptor. On failure, returns -1.
695 EXEC_ONLY nonzero means don't open the files,
696 just look for one that is executable. In this case,
697 returns 1 on success.
699 If STOREPTR is nonzero, it points to a slot where the name of
700 the file actually found should be stored as a Lisp string.
701 nil is stored there on failure.
703 If the file we find is remote, return 0
704 but store the found remote file name in *STOREPTR.
705 We do not check for remote files if EXEC_ONLY is nonzero. */
708 openp (path
, str
, suffix
, storeptr
, exec_only
)
709 Lisp_Object path
, str
;
711 Lisp_Object
*storeptr
;
717 register char *fn
= buf
;
720 Lisp_Object filename
;
728 if (complete_filename_p (str
))
731 for (; !NILP (path
); path
= Fcdr (path
))
735 filename
= Fexpand_file_name (str
, Fcar (path
));
736 if (!complete_filename_p (filename
))
737 /* If there are non-absolute elts in PATH (eg ".") */
738 /* Of course, this could conceivably lose if luser sets
739 default-directory to be something non-absolute... */
741 filename
= Fexpand_file_name (filename
, current_buffer
->directory
);
742 if (!complete_filename_p (filename
))
743 /* Give up on this path element! */
747 /* Calculate maximum size of any filename made from
748 this path element/specified file name and any possible suffix. */
749 want_size
= strlen (suffix
) + XSTRING (filename
)->size
+ 1;
750 if (fn_size
< want_size
)
751 fn
= (char *) alloca (fn_size
= 100 + want_size
);
755 /* Loop over suffixes. */
758 char *esuffix
= (char *) index (nsuffix
, ':');
759 int lsuffix
= esuffix
? esuffix
- nsuffix
: strlen (nsuffix
);
762 /* Concatenate path element/specified name with the suffix.
763 If the directory starts with /:, remove that. */
764 if (XSTRING (filename
)->size
> 2
765 && XSTRING (filename
)->data
[0] == '/'
766 && XSTRING (filename
)->data
[1] == ':')
768 strncpy (fn
, XSTRING (filename
)->data
+ 2,
769 XSTRING (filename
)->size
- 2);
770 fn
[XSTRING (filename
)->size
- 2] = 0;
774 strncpy (fn
, XSTRING (filename
)->data
, XSTRING (filename
)->size
);
775 fn
[XSTRING (filename
)->size
] = 0;
778 if (lsuffix
!= 0) /* Bug happens on CCI if lsuffix is 0. */
779 strncat (fn
, nsuffix
, lsuffix
);
781 /* Check that the file exists and is not a directory. */
785 handler
= Ffind_file_name_handler (filename
, Qfile_exists_p
);
786 if (! NILP (handler
) && ! exec_only
)
791 string
= build_string (fn
);
792 exists
= ! NILP (exec_only
? Ffile_executable_p (string
)
793 : Ffile_readable_p (string
));
795 && ! NILP (Ffile_directory_p (build_string (fn
))))
800 /* We succeeded; return this descriptor and filename. */
802 *storeptr
= build_string (fn
);
809 int exists
= (stat (fn
, &st
) >= 0
810 && (st
.st_mode
& S_IFMT
) != S_IFDIR
);
813 /* Check that we can access or open it. */
815 fd
= (access (fn
, X_OK
) == 0) ? 1 : -1;
817 fd
= open (fn
, O_RDONLY
, 0);
821 /* We succeeded; return this descriptor and filename. */
823 *storeptr
= build_string (fn
);
830 /* Advance to next suffix. */
833 nsuffix
+= lsuffix
+ 1;
844 /* Merge the list we've accumulated of globals from the current input source
845 into the load_history variable. The details depend on whether
846 the source has an associated file name or not. */
849 build_load_history (stream
, source
)
853 register Lisp_Object tail
, prev
, newelt
;
854 register Lisp_Object tem
, tem2
;
855 register int foundit
, loading
;
857 /* Don't bother recording anything for preloaded files. */
858 if (!NILP (Vpurify_flag
))
861 loading
= stream
|| !NARROWED
;
863 tail
= Vload_history
;
870 /* Find the feature's previous assoc list... */
871 if (!NILP (Fequal (source
, Fcar (tem
))))
875 /* If we're loading, remove it. */
879 Vload_history
= Fcdr (tail
);
881 Fsetcdr (prev
, Fcdr (tail
));
884 /* Otherwise, cons on new symbols that are not already members. */
887 tem2
= Vcurrent_load_list
;
891 newelt
= Fcar (tem2
);
893 if (NILP (Fmemq (newelt
, tem
)))
894 Fsetcar (tail
, Fcons (Fcar (tem
),
895 Fcons (newelt
, Fcdr (tem
))));
908 /* If we're loading, cons the new assoc onto the front of load-history,
909 the most-recently-loaded position. Also do this if we didn't find
910 an existing member for the current source. */
911 if (loading
|| !foundit
)
912 Vload_history
= Fcons (Fnreverse (Vcurrent_load_list
),
917 unreadpure () /* Used as unwind-protect function in readevalloop */
924 readevalloop (readcharfun
, stream
, sourcename
, evalfun
, printflag
)
925 Lisp_Object readcharfun
;
927 Lisp_Object sourcename
;
928 Lisp_Object (*evalfun
) ();
932 register Lisp_Object val
;
933 int count
= specpdl_ptr
- specpdl
;
935 struct buffer
*b
= 0;
937 if (BUFFERP (readcharfun
))
938 b
= XBUFFER (readcharfun
);
939 else if (MARKERP (readcharfun
))
940 b
= XMARKER (readcharfun
)->buffer
;
942 specbind (Qstandard_input
, readcharfun
);
943 specbind (Qcurrent_load_list
, Qnil
);
945 readchar_backlog
= 0;
949 LOADHIST_ATTACH (sourcename
);
953 if (b
!= 0 && NILP (b
->name
))
954 error ("Reading from killed buffer");
960 while ((c
= READCHAR
) != '\n' && c
!= -1);
965 /* Ignore whitespace here, so we can detect eof. */
966 if (c
== ' ' || c
== '\t' || c
== '\n' || c
== '\f' || c
== '\r')
969 if (!NILP (Vpurify_flag
) && c
== '(')
971 int count1
= specpdl_ptr
- specpdl
;
972 record_unwind_protect (unreadpure
, Qnil
);
973 val
= read_list (-1, readcharfun
);
974 unbind_to (count1
, Qnil
);
980 if (NILP (Vload_read_function
))
981 val
= read0 (readcharfun
);
983 val
= call1 (Vload_read_function
, readcharfun
);
986 val
= (*evalfun
) (val
);
989 Vvalues
= Fcons (val
, Vvalues
);
990 if (EQ (Vstandard_output
, Qt
))
997 build_load_history (stream
, sourcename
);
1000 unbind_to (count
, Qnil
);
1005 DEFUN ("eval-buffer", Feval_buffer
, Seval_buffer
, 0, 3, "",
1006 "Execute the current buffer as Lisp code.\n\
1007 Programs can pass two arguments, BUFFER and PRINTFLAG.\n\
1008 BUFFER is the buffer to evaluate (nil means use current buffer).\n\
1009 PRINTFLAG controls printing of output:\n\
1010 nil means discard it; anything else is stream for print.\n\
1012 If the optional third argument FILENAME is non-nil,\n\
1013 it specifies the file name to use for `load-history'.\n\
1015 This function preserves the position of point.")
1016 (buffer
, printflag
, filename
)
1017 Lisp_Object buffer
, printflag
, filename
;
1019 int count
= specpdl_ptr
- specpdl
;
1020 Lisp_Object tem
, buf
;
1023 buf
= Fcurrent_buffer ();
1025 buf
= Fget_buffer (buffer
);
1027 error ("No such buffer");
1029 if (NILP (printflag
))
1034 if (NILP (filename
))
1035 filename
= XBUFFER (buf
)->filename
;
1037 specbind (Qstandard_output
, tem
);
1038 record_unwind_protect (save_excursion_restore
, save_excursion_save ());
1039 BUF_SET_PT (XBUFFER (buf
), BUF_BEGV (XBUFFER (buf
)));
1040 readevalloop (buf
, 0, filename
, Feval
, !NILP (printflag
));
1041 unbind_to (count
, Qnil
);
1047 XDEFUN ("eval-current-buffer", Feval_current_buffer
, Seval_current_buffer
, 0, 1, "",
1048 "Execute the current buffer as Lisp code.\n\
1049 Programs can pass argument PRINTFLAG which controls printing of output:\n\
1050 nil means discard it; anything else is stream for print.\n\
1052 If there is no error, point does not move. If there is an error,\n\
1053 point remains at the end of the last character read from the buffer.")
1055 Lisp_Object printflag
;
1057 int count
= specpdl_ptr
- specpdl
;
1058 Lisp_Object tem
, cbuf
;
1060 cbuf
= Fcurrent_buffer ()
1062 if (NILP (printflag
))
1066 specbind (Qstandard_output
, tem
);
1067 record_unwind_protect (save_excursion_restore
, save_excursion_save ());
1069 readevalloop (cbuf
, 0, XBUFFER (cbuf
)->filename
, Feval
, !NILP (printflag
));
1070 return unbind_to (count
, Qnil
);
1074 DEFUN ("eval-region", Feval_region
, Seval_region
, 2, 3, "r",
1075 "Execute the region as Lisp code.\n\
1076 When called from programs, expects two arguments,\n\
1077 giving starting and ending indices in the current buffer\n\
1078 of the text to be executed.\n\
1079 Programs can pass third argument PRINTFLAG which controls output:\n\
1080 nil means discard it; anything else is stream for printing it.\n\
1082 This function does not move point.")
1083 (start
, end
, printflag
)
1084 Lisp_Object start
, end
, printflag
;
1086 int count
= specpdl_ptr
- specpdl
;
1087 Lisp_Object tem
, cbuf
;
1089 cbuf
= Fcurrent_buffer ();
1091 if (NILP (printflag
))
1095 specbind (Qstandard_output
, tem
);
1097 if (NILP (printflag
))
1098 record_unwind_protect (save_excursion_restore
, save_excursion_save ());
1099 record_unwind_protect (save_restriction_restore
, save_restriction_save ());
1101 /* This both uses start and checks its type. */
1103 Fnarrow_to_region (make_number (BEGV
), end
);
1104 readevalloop (cbuf
, 0, XBUFFER (cbuf
)->filename
, Feval
, !NILP (printflag
));
1106 return unbind_to (count
, Qnil
);
1109 #endif /* standalone */
1111 DEFUN ("read", Fread
, Sread
, 0, 1, 0,
1112 "Read one Lisp expression as text from STREAM, return as Lisp object.\n\
1113 If STREAM is nil, use the value of `standard-input' (which see).\n\
1114 STREAM or the value of `standard-input' may be:\n\
1115 a buffer (read from point and advance it)\n\
1116 a marker (read from where it points and advance it)\n\
1117 a function (call it with no arguments for each character,\n\
1118 call it with a char as argument to push a char back)\n\
1119 a string (takes text from string, starting at the beginning)\n\
1120 t (read text line using minibuffer and use it).")
1124 extern Lisp_Object
Fread_minibuffer ();
1127 stream
= Vstandard_input
;
1128 if (EQ (stream
, Qt
))
1129 stream
= Qread_char
;
1131 readchar_backlog
= 0;
1132 new_backquote_flag
= 0;
1133 read_objects
= Qnil
;
1136 if (EQ (stream
, Qread_char
))
1137 return Fread_minibuffer (build_string ("Lisp expression: "), Qnil
);
1140 if (STRINGP (stream
))
1141 return Fcar (Fread_from_string (stream
, Qnil
, Qnil
));
1143 return read0 (stream
);
1146 DEFUN ("read-from-string", Fread_from_string
, Sread_from_string
, 1, 3, 0,
1147 "Read one Lisp expression which is represented as text by STRING.\n\
1148 Returns a cons: (OBJECT-READ . FINAL-STRING-INDEX).\n\
1149 START and END optionally delimit a substring of STRING from which to read;\n\
1150 they default to 0 and (length STRING) respectively.")
1151 (string
, start
, end
)
1152 Lisp_Object string
, start
, end
;
1154 int startval
, endval
;
1157 CHECK_STRING (string
,0);
1160 endval
= XSTRING (string
)->size_byte
;
1163 CHECK_NUMBER (end
, 2);
1164 endval
= string_char_to_byte (string
, XINT (end
));
1165 if (endval
< 0 || endval
> XSTRING (string
)->size_byte
)
1166 args_out_of_range (string
, end
);
1173 CHECK_NUMBER (start
, 1);
1174 startval
= string_char_to_byte (string
, XINT (start
));
1175 if (startval
< 0 || startval
> endval
)
1176 args_out_of_range (string
, start
);
1179 read_from_string_index
= startval
;
1180 read_from_string_limit
= endval
;
1182 new_backquote_flag
= 0;
1183 read_objects
= Qnil
;
1185 tem
= read0 (string
);
1186 endval
= string_byte_to_char (string
,
1187 read_from_string_index
);
1188 return Fcons (tem
, make_number (endval
));
1191 /* Use this for recursive reads, in contexts where internal tokens
1196 Lisp_Object readcharfun
;
1198 register Lisp_Object val
;
1201 val
= read1 (readcharfun
, &c
, 0);
1203 Fsignal (Qinvalid_read_syntax
, Fcons (Fmake_string (make_number (c
),
1210 static int read_buffer_size
;
1211 static char *read_buffer
;
1213 /* Read multibyte form and return it as a character. C is a first
1214 byte of multibyte form, and rest of them are read from
1218 read_multibyte (c
, readcharfun
)
1220 Lisp_Object readcharfun
;
1222 /* We need the actual character code of this multibyte
1224 unsigned char str
[MAX_LENGTH_OF_MULTI_BYTE_FORM
];
1228 while ((c
= READCHAR
) >= 0xA0
1229 && len
< MAX_LENGTH_OF_MULTI_BYTE_FORM
)
1232 return STRING_CHAR (str
, len
);
1235 /* Read a \-escape sequence, assuming we already read the `\'. */
1238 read_escape (readcharfun
, stringp
)
1239 Lisp_Object readcharfun
;
1242 register int c
= READCHAR
;
1246 error ("End of file");
1276 error ("Invalid escape character syntax");
1279 c
= read_escape (readcharfun
, 0);
1280 return c
| meta_modifier
;
1285 error ("Invalid escape character syntax");
1288 c
= read_escape (readcharfun
, 0);
1289 return c
| shift_modifier
;
1294 error ("Invalid escape character syntax");
1297 c
= read_escape (readcharfun
, 0);
1298 return c
| hyper_modifier
;
1303 error ("Invalid escape character syntax");
1306 c
= read_escape (readcharfun
, 0);
1307 return c
| alt_modifier
;
1312 error ("Invalid escape character syntax");
1315 c
= read_escape (readcharfun
, 0);
1316 return c
| super_modifier
;
1321 error ("Invalid escape character syntax");
1325 c
= read_escape (readcharfun
, 0);
1326 if ((c
& 0177) == '?')
1328 /* ASCII control chars are made from letters (both cases),
1329 as well as the non-letters within 0100...0137. */
1330 else if ((c
& 0137) >= 0101 && (c
& 0137) <= 0132)
1331 return (c
& (037 | ~0177));
1332 else if ((c
& 0177) >= 0100 && (c
& 0177) <= 0137)
1333 return (c
& (037 | ~0177));
1335 return c
| ctrl_modifier
;
1345 /* An octal escape, as in ANSI C. */
1347 register int i
= c
- '0';
1348 register int count
= 0;
1351 if ((c
= READCHAR
) >= '0' && c
<= '7')
1366 /* A hex escape, as in ANSI C. */
1372 if (c
>= '0' && c
<= '9')
1377 else if ((c
>= 'a' && c
<= 'f')
1378 || (c
>= 'A' && c
<= 'F'))
1381 if (c
>= 'a' && c
<= 'f')
1396 if (BASE_LEADING_CODE_P (c
))
1397 c
= read_multibyte (c
, readcharfun
);
1402 /* If the next token is ')' or ']' or '.', we store that character
1403 in *PCH and the return value is not interesting. Else, we store
1404 zero in *PCH and we read and return one lisp object.
1406 FIRST_IN_LIST is nonzero if this is the first element of a list. */
1409 read1 (readcharfun
, pch
, first_in_list
)
1410 register Lisp_Object readcharfun
;
1415 int uninterned_symbol
= 0;
1422 if (c
< 0) return Fsignal (Qend_of_file
, Qnil
);
1427 return read_list (0, readcharfun
);
1430 return read_vector (readcharfun
);
1447 tmp
= read_vector (readcharfun
);
1448 if (XVECTOR (tmp
)->size
< CHAR_TABLE_STANDARD_SLOTS
1449 || XVECTOR (tmp
)->size
> CHAR_TABLE_STANDARD_SLOTS
+ 10)
1450 error ("Invalid size char-table");
1451 XSETCHAR_TABLE (tmp
, XCHAR_TABLE (tmp
));
1452 XCHAR_TABLE (tmp
)->top
= Qt
;
1461 tmp
= read_vector (readcharfun
);
1462 if (XVECTOR (tmp
)->size
!= SUB_CHAR_TABLE_STANDARD_SLOTS
)
1463 error ("Invalid size char-table");
1464 XSETCHAR_TABLE (tmp
, XCHAR_TABLE (tmp
));
1465 XCHAR_TABLE (tmp
)->top
= Qnil
;
1468 Fsignal (Qinvalid_read_syntax
,
1469 Fcons (make_string ("#^^", 3), Qnil
));
1471 Fsignal (Qinvalid_read_syntax
, Fcons (make_string ("#^", 2), Qnil
));
1476 length
= read1 (readcharfun
, pch
, first_in_list
);
1480 Lisp_Object tmp
, val
;
1481 int size_in_chars
= ((XFASTINT (length
) + BITS_PER_CHAR
- 1)
1485 tmp
= read1 (readcharfun
, pch
, first_in_list
);
1486 if (size_in_chars
!= XSTRING (tmp
)->size
1487 /* We used to print 1 char too many
1488 when the number of bits was a multiple of 8.
1489 Accept such input in case it came from an old version. */
1490 && ! (XFASTINT (length
)
1491 == (XSTRING (tmp
)->size
- 1) * BITS_PER_CHAR
))
1492 Fsignal (Qinvalid_read_syntax
,
1493 Fcons (make_string ("#&...", 5), Qnil
));
1495 val
= Fmake_bool_vector (length
, Qnil
);
1496 bcopy (XSTRING (tmp
)->data
, XBOOL_VECTOR (val
)->data
,
1500 Fsignal (Qinvalid_read_syntax
, Fcons (make_string ("#&...", 5),
1505 /* Accept compiled functions at read-time so that we don't have to
1506 build them using function calls. */
1508 tmp
= read_vector (readcharfun
);
1509 return Fmake_byte_code (XVECTOR (tmp
)->size
,
1510 XVECTOR (tmp
)->contents
);
1512 #ifdef USE_TEXT_PROPERTIES
1516 struct gcpro gcpro1
;
1519 /* Read the string itself. */
1520 tmp
= read1 (readcharfun
, &ch
, 0);
1521 if (ch
!= 0 || !STRINGP (tmp
))
1522 Fsignal (Qinvalid_read_syntax
, Fcons (make_string ("#", 1), Qnil
));
1524 /* Read the intervals and their properties. */
1527 Lisp_Object beg
, end
, plist
;
1529 beg
= read1 (readcharfun
, &ch
, 0);
1533 end
= read1 (readcharfun
, &ch
, 0);
1535 plist
= read1 (readcharfun
, &ch
, 0);
1537 Fsignal (Qinvalid_read_syntax
,
1538 Fcons (build_string ("invalid string property list"),
1540 Fset_text_properties (beg
, end
, plist
, tmp
);
1546 /* #@NUMBER is used to skip NUMBER following characters.
1547 That's used in .elc files to skip over doc strings
1548 and function definitions. */
1553 /* Read a decimal integer. */
1554 while ((c
= READCHAR
) >= 0
1555 && c
>= '0' && c
<= '9')
1563 #ifndef DOS_NT /* I don't know if filepos works right on MSDOS and Windoze. */
1564 if (load_force_doc_strings
&& EQ (readcharfun
, Qget_file_char
))
1566 /* If we are supposed to force doc strings into core right now,
1567 record the last string that we skipped,
1568 and record where in the file it comes from. */
1569 if (saved_doc_string_size
== 0)
1571 saved_doc_string_size
= nskip
+ 100;
1572 saved_doc_string
= (char *) xmalloc (saved_doc_string_size
);
1574 if (nskip
> saved_doc_string_size
)
1576 saved_doc_string_size
= nskip
+ 100;
1577 saved_doc_string
= (char *) xrealloc (saved_doc_string
,
1578 saved_doc_string_size
);
1581 saved_doc_string_position
= ftell (instream
);
1583 /* Copy that many characters into saved_doc_string. */
1584 for (i
= 0; i
< nskip
&& c
>= 0; i
++)
1585 saved_doc_string
[i
] = c
= READCHAR
;
1587 saved_doc_string_length
= i
;
1590 #endif /* not DOS_NT */
1592 /* Skip that many characters. */
1593 for (i
= 0; i
< nskip
&& c
>= 0; i
++)
1600 return Vload_file_name
;
1602 return Fcons (Qfunction
, Fcons (read0 (readcharfun
), Qnil
));
1603 /* #:foo is the uninterned symbol named foo. */
1606 uninterned_symbol
= 1;
1610 /* Reader forms that can reuse previously read objects. */
1611 if (c
>= '0' && c
<= '9')
1616 /* Read a non-negative integer. */
1617 while (c
>= '0' && c
<= '9')
1623 /* #n=object returns object, but associates it with n for #n#. */
1626 tem
= read0 (readcharfun
);
1627 read_objects
= Fcons (Fcons (make_number (n
), tem
), read_objects
);
1630 /* #n# returns a previously read object. */
1633 tem
= Fassq (make_number (n
), read_objects
);
1636 /* Fall through to error message. */
1638 /* Fall through to error message. */
1642 Fsignal (Qinvalid_read_syntax
, Fcons (make_string ("#", 1), Qnil
));
1645 while ((c
= READCHAR
) >= 0 && c
!= '\n');
1650 return Fcons (Qquote
, Fcons (read0 (readcharfun
), Qnil
));
1660 new_backquote_flag
= 1;
1661 value
= read0 (readcharfun
);
1662 new_backquote_flag
= 0;
1664 return Fcons (Qbackquote
, Fcons (value
, Qnil
));
1668 if (new_backquote_flag
)
1670 Lisp_Object comma_type
= Qnil
;
1675 comma_type
= Qcomma_at
;
1677 comma_type
= Qcomma_dot
;
1680 if (ch
>= 0) UNREAD (ch
);
1681 comma_type
= Qcomma
;
1684 new_backquote_flag
= 0;
1685 value
= read0 (readcharfun
);
1686 new_backquote_flag
= 1;
1687 return Fcons (comma_type
, Fcons (value
, Qnil
));
1694 register Lisp_Object val
;
1697 if (c
< 0) return Fsignal (Qend_of_file
, Qnil
);
1700 c
= read_escape (readcharfun
, 0);
1701 else if (BASE_LEADING_CODE_P (c
))
1702 c
= read_multibyte (c
, readcharfun
);
1704 return make_number (c
);
1709 register char *p
= read_buffer
;
1710 register char *end
= read_buffer
+ read_buffer_size
;
1712 /* Nonzero if we saw an escape sequence specifying
1713 a multibyte character. */
1714 int force_multibyte
= 0;
1715 /* Nonzero if we saw an escape sequence specifying
1716 a single-byte character. */
1717 int force_singlebyte
= 0;
1721 while ((c
= READCHAR
) >= 0
1726 char *new = (char *) xrealloc (read_buffer
, read_buffer_size
*= 2);
1727 p
+= new - read_buffer
;
1728 read_buffer
+= new - read_buffer
;
1729 end
= read_buffer
+ read_buffer_size
;
1733 c
= read_escape (readcharfun
, 1);
1734 if (! SINGLE_BYTE_CHAR_P ((c
& ~CHAR_META
)))
1736 unsigned char workbuf
[4];
1737 unsigned char *str
= workbuf
;
1740 length
= non_ascii_char_to_string (c
, workbuf
, &str
);
1742 force_multibyte
= 1;
1744 if (p
+ length
> end
)
1746 char *new = (char *) xrealloc (read_buffer
, read_buffer_size
*= 2);
1747 p
+= new - read_buffer
;
1748 read_buffer
+= new - read_buffer
;
1749 end
= read_buffer
+ read_buffer_size
;
1752 bcopy (str
, p
, length
);
1756 else if (! ASCII_BYTE_P (c
))
1757 force_singlebyte
= 1;
1760 /* c is -1 if \ newline has just been seen */
1763 if (p
== read_buffer
)
1768 /* Allow `\C- ' and `\C-?'. */
1769 if (c
== (CHAR_CTL
| ' '))
1771 else if (c
== (CHAR_CTL
| '?'))
1775 /* Move the meta bit to the right place for a string. */
1776 c
= (c
& ~CHAR_META
) | 0x80;
1778 error ("Invalid modifier in string");
1783 return Fsignal (Qend_of_file
, Qnil
);
1785 /* If purifying, and string starts with \ newline,
1786 return zero instead. This is for doc strings
1787 that we are really going to find in etc/DOC.nn.nn */
1788 if (!NILP (Vpurify_flag
) && NILP (Vdoc_file_name
) && cancel
)
1789 return make_number (0);
1791 if (force_singlebyte
&& force_multibyte
)
1792 error ("Multibyte and single-byte escapes in one string constant");
1794 if (force_singlebyte
)
1795 nchars
= p
- read_buffer
;
1796 else if (! NILP (buffer_defaults
.enable_multibyte_characters
)
1798 nchars
= chars_in_text (read_buffer
, p
- read_buffer
);
1800 nchars
= p
- read_buffer
;
1803 return make_pure_string (read_buffer
, nchars
, p
- read_buffer
);
1804 return make_multibyte_string (read_buffer
, nchars
, p
- read_buffer
);
1809 #ifdef LISP_FLOAT_TYPE
1810 /* If a period is followed by a number, then we should read it
1811 as a floating point number. Otherwise, it denotes a dotted
1813 int next_char
= READCHAR
;
1816 if (! (next_char
>= '0' && next_char
<= '9'))
1823 /* Otherwise, we fall through! Note that the atom-reading loop
1824 below will now loop at least once, assuring that we will not
1825 try to UNREAD two characters in a row. */
1829 if (c
<= 040) goto retry
;
1831 register char *p
= read_buffer
;
1835 register char *end
= read_buffer
+ read_buffer_size
;
1838 && !(c
== '\"' || c
== '\'' || c
== ';' || c
== '?'
1839 || c
== '(' || c
== ')'
1840 #ifndef LISP_FLOAT_TYPE
1841 /* If we have floating-point support, then we need
1842 to allow <digits><dot><digits>. */
1844 #endif /* not LISP_FLOAT_TYPE */
1845 || c
== '[' || c
== ']' || c
== '#'
1850 register char *new = (char *) xrealloc (read_buffer
, read_buffer_size
*= 2);
1851 p
+= new - read_buffer
;
1852 read_buffer
+= new - read_buffer
;
1853 end
= read_buffer
+ read_buffer_size
;
1868 char *new = (char *) xrealloc (read_buffer
, read_buffer_size
*= 2);
1869 p
+= new - read_buffer
;
1870 read_buffer
+= new - read_buffer
;
1871 /* end = read_buffer + read_buffer_size; */
1878 if (!quoted
&& !uninterned_symbol
)
1881 register Lisp_Object val
;
1883 if (*p1
== '+' || *p1
== '-') p1
++;
1884 /* Is it an integer? */
1887 while (p1
!= p
&& (c
= *p1
) >= '0' && c
<= '9') p1
++;
1888 #ifdef LISP_FLOAT_TYPE
1889 /* Integers can have trailing decimal points. */
1890 if (p1
> read_buffer
&& p1
< p
&& *p1
== '.') p1
++;
1893 /* It is an integer. */
1895 #ifdef LISP_FLOAT_TYPE
1899 if (sizeof (int) == sizeof (EMACS_INT
))
1900 XSETINT (val
, atoi (read_buffer
));
1901 else if (sizeof (long) == sizeof (EMACS_INT
))
1902 XSETINT (val
, atol (read_buffer
));
1908 #ifdef LISP_FLOAT_TYPE
1909 if (isfloat_string (read_buffer
))
1910 return make_float (atof (read_buffer
));
1914 if (uninterned_symbol
)
1915 return make_symbol (read_buffer
);
1917 return intern (read_buffer
);
1922 #ifdef LISP_FLOAT_TYPE
1937 if (*cp
== '+' || *cp
== '-')
1940 if (*cp
>= '0' && *cp
<= '9')
1943 while (*cp
>= '0' && *cp
<= '9')
1951 if (*cp
>= '0' && *cp
<= '9')
1954 while (*cp
>= '0' && *cp
<= '9')
1957 if (*cp
== 'e' || *cp
== 'E')
1961 if (*cp
== '+' || *cp
== '-')
1965 if (*cp
>= '0' && *cp
<= '9')
1968 while (*cp
>= '0' && *cp
<= '9')
1971 return (((*cp
== 0) || (*cp
== ' ') || (*cp
== '\t') || (*cp
== '\n') || (*cp
== '\r') || (*cp
== '\f'))
1972 && (state
== (LEAD_INT
|DOT_CHAR
|TRAIL_INT
)
1973 || state
== (DOT_CHAR
|TRAIL_INT
)
1974 || state
== (LEAD_INT
|E_CHAR
|EXP_INT
)
1975 || state
== (LEAD_INT
|DOT_CHAR
|TRAIL_INT
|E_CHAR
|EXP_INT
)
1976 || state
== (DOT_CHAR
|TRAIL_INT
|E_CHAR
|EXP_INT
)));
1978 #endif /* LISP_FLOAT_TYPE */
1981 read_vector (readcharfun
)
1982 Lisp_Object readcharfun
;
1986 register Lisp_Object
*ptr
;
1987 register Lisp_Object tem
, vector
;
1988 register struct Lisp_Cons
*otem
;
1991 tem
= read_list (1, readcharfun
);
1992 len
= Flength (tem
);
1993 vector
= (read_pure
? make_pure_vector (XINT (len
)) : Fmake_vector (len
, Qnil
));
1996 size
= XVECTOR (vector
)->size
;
1997 ptr
= XVECTOR (vector
)->contents
;
1998 for (i
= 0; i
< size
; i
++)
2000 ptr
[i
] = read_pure
? Fpurecopy (Fcar (tem
)) : Fcar (tem
);
2008 /* FLAG = 1 means check for ] to terminate rather than ) and .
2009 FLAG = -1 means check for starting with defun
2010 and make structure pure. */
2013 read_list (flag
, readcharfun
)
2015 register Lisp_Object readcharfun
;
2017 /* -1 means check next element for defun,
2018 0 means don't check,
2019 1 means already checked and found defun. */
2020 int defunflag
= flag
< 0 ? -1 : 0;
2021 Lisp_Object val
, tail
;
2022 register Lisp_Object elt
, tem
;
2023 struct gcpro gcpro1
, gcpro2
;
2024 /* 0 is the normal case.
2025 1 means this list is a doc reference; replace it with the number 0.
2026 2 means this list is a doc reference; replace it with the doc string. */
2027 int doc_reference
= 0;
2029 /* Initialize this to 1 if we are reading a list. */
2030 int first_in_list
= flag
<= 0;
2039 elt
= read1 (readcharfun
, &ch
, first_in_list
);
2044 /* While building, if the list starts with #$, treat it specially. */
2045 if (EQ (elt
, Vload_file_name
)
2047 && !NILP (Vpurify_flag
))
2049 if (NILP (Vdoc_file_name
))
2050 /* We have not yet called Snarf-documentation, so assume
2051 this file is described in the DOC-MM.NN file
2052 and Snarf-documentation will fill in the right value later.
2053 For now, replace the whole list with 0. */
2056 /* We have already called Snarf-documentation, so make a relative
2057 file name for this file, so it can be found properly
2058 in the installed Lisp directory.
2059 We don't use Fexpand_file_name because that would make
2060 the directory absolute now. */
2061 elt
= concat2 (build_string ("../lisp/"),
2062 Ffile_name_nondirectory (elt
));
2064 else if (EQ (elt
, Vload_file_name
)
2066 && load_force_doc_strings
)
2075 Fsignal (Qinvalid_read_syntax
,
2076 Fcons (make_string (") or . in a vector", 18), Qnil
));
2084 XCONS (tail
)->cdr
= read0 (readcharfun
);
2086 val
= read0 (readcharfun
);
2087 read1 (readcharfun
, &ch
, 0);
2091 if (doc_reference
== 1)
2092 return make_number (0);
2093 if (doc_reference
== 2)
2095 /* Get a doc string from the file we are loading.
2096 If it's in saved_doc_string, get it from there. */
2097 int pos
= XINT (XCONS (val
)->cdr
);
2098 if (pos
>= saved_doc_string_position
2099 && pos
< (saved_doc_string_position
2100 + saved_doc_string_length
))
2102 int start
= pos
- saved_doc_string_position
;
2105 /* Process quoting with ^A,
2106 and find the end of the string,
2107 which is marked with ^_ (037). */
2108 for (from
= start
, to
= start
;
2109 saved_doc_string
[from
] != 037;)
2111 int c
= saved_doc_string
[from
++];
2114 c
= saved_doc_string
[from
++];
2116 saved_doc_string
[to
++] = c
;
2118 saved_doc_string
[to
++] = 0;
2120 saved_doc_string
[to
++] = 037;
2123 saved_doc_string
[to
++] = c
;
2126 return make_string (saved_doc_string
+ start
,
2130 return read_doc_string (val
);
2135 return Fsignal (Qinvalid_read_syntax
, Fcons (make_string (". in wrong context", 18), Qnil
));
2137 return Fsignal (Qinvalid_read_syntax
, Fcons (make_string ("] in a list", 11), Qnil
));
2139 tem
= (read_pure
&& flag
<= 0
2140 ? pure_cons (elt
, Qnil
)
2141 : Fcons (elt
, Qnil
));
2143 XCONS (tail
)->cdr
= tem
;
2148 defunflag
= EQ (elt
, Qdefun
);
2149 else if (defunflag
> 0)
2154 Lisp_Object Vobarray
;
2155 Lisp_Object initial_obarray
;
2157 /* oblookup stores the bucket number here, for the sake of Funintern. */
2159 int oblookup_last_bucket_number
;
2161 static int hash_string ();
2162 Lisp_Object
oblookup ();
2164 /* Get an error if OBARRAY is not an obarray.
2165 If it is one, return it. */
2168 check_obarray (obarray
)
2169 Lisp_Object obarray
;
2171 while (!VECTORP (obarray
) || XVECTOR (obarray
)->size
== 0)
2173 /* If Vobarray is now invalid, force it to be valid. */
2174 if (EQ (Vobarray
, obarray
)) Vobarray
= initial_obarray
;
2176 obarray
= wrong_type_argument (Qvectorp
, obarray
);
2181 /* Intern the C string STR: return a symbol with that name,
2182 interned in the current obarray. */
2189 int len
= strlen (str
);
2190 Lisp_Object obarray
;
2193 if (!VECTORP (obarray
) || XVECTOR (obarray
)->size
== 0)
2194 obarray
= check_obarray (obarray
);
2195 tem
= oblookup (obarray
, str
, len
, len
);
2198 return Fintern (make_string (str
, len
), obarray
);
2201 /* Create an uninterned symbol with name STR. */
2207 int len
= strlen (str
);
2209 return Fmake_symbol ((!NILP (Vpurify_flag
)
2210 ? make_pure_string (str
, len
, len
)
2211 : make_string (str
, len
)));
2214 DEFUN ("intern", Fintern
, Sintern
, 1, 2, 0,
2215 "Return the canonical symbol whose name is STRING.\n\
2216 If there is none, one is created by this function and returned.\n\
2217 A second optional argument specifies the obarray to use;\n\
2218 it defaults to the value of `obarray'.")
2220 Lisp_Object string
, obarray
;
2222 register Lisp_Object tem
, sym
, *ptr
;
2224 if (NILP (obarray
)) obarray
= Vobarray
;
2225 obarray
= check_obarray (obarray
);
2227 CHECK_STRING (string
, 0);
2229 tem
= oblookup (obarray
, XSTRING (string
)->data
,
2230 XSTRING (string
)->size
,
2231 XSTRING (string
)->size_byte
);
2232 if (!INTEGERP (tem
))
2235 if (!NILP (Vpurify_flag
))
2236 string
= Fpurecopy (string
);
2237 sym
= Fmake_symbol (string
);
2238 XSYMBOL (sym
)->obarray
= obarray
;
2240 if (XSTRING (string
)->data
[0] == ':')
2241 XSYMBOL (sym
)->value
= sym
;
2243 ptr
= &XVECTOR (obarray
)->contents
[XINT (tem
)];
2245 XSYMBOL (sym
)->next
= XSYMBOL (*ptr
);
2247 XSYMBOL (sym
)->next
= 0;
2252 DEFUN ("intern-soft", Fintern_soft
, Sintern_soft
, 1, 2, 0,
2253 "Return the canonical symbol whose name is STRING, or nil if none exists.\n\
2254 A second optional argument specifies the obarray to use;\n\
2255 it defaults to the value of `obarray'.")
2257 Lisp_Object string
, obarray
;
2259 register Lisp_Object tem
;
2261 if (NILP (obarray
)) obarray
= Vobarray
;
2262 obarray
= check_obarray (obarray
);
2264 CHECK_STRING (string
, 0);
2266 tem
= oblookup (obarray
, XSTRING (string
)->data
,
2267 XSTRING (string
)->size
,
2268 XSTRING (string
)->size_byte
);
2269 if (!INTEGERP (tem
))
2274 DEFUN ("unintern", Funintern
, Sunintern
, 1, 2, 0,
2275 "Delete the symbol named NAME, if any, from OBARRAY.\n\
2276 The value is t if a symbol was found and deleted, nil otherwise.\n\
2277 NAME may be a string or a symbol. If it is a symbol, that symbol\n\
2278 is deleted, if it belongs to OBARRAY--no other symbol is deleted.\n\
2279 OBARRAY defaults to the value of the variable `obarray'.")
2281 Lisp_Object name
, obarray
;
2283 register Lisp_Object string
, tem
;
2286 if (NILP (obarray
)) obarray
= Vobarray
;
2287 obarray
= check_obarray (obarray
);
2290 XSETSTRING (string
, XSYMBOL (name
)->name
);
2293 CHECK_STRING (name
, 0);
2297 tem
= oblookup (obarray
, XSTRING (string
)->data
,
2298 XSTRING (string
)->size
,
2299 XSTRING (string
)->size_byte
);
2302 /* If arg was a symbol, don't delete anything but that symbol itself. */
2303 if (SYMBOLP (name
) && !EQ (name
, tem
))
2306 hash
= oblookup_last_bucket_number
;
2308 if (EQ (XVECTOR (obarray
)->contents
[hash
], tem
))
2310 if (XSYMBOL (tem
)->next
)
2311 XSETSYMBOL (XVECTOR (obarray
)->contents
[hash
], XSYMBOL (tem
)->next
);
2313 XSETINT (XVECTOR (obarray
)->contents
[hash
], 0);
2317 Lisp_Object tail
, following
;
2319 for (tail
= XVECTOR (obarray
)->contents
[hash
];
2320 XSYMBOL (tail
)->next
;
2323 XSETSYMBOL (following
, XSYMBOL (tail
)->next
);
2324 if (EQ (following
, tem
))
2326 XSYMBOL (tail
)->next
= XSYMBOL (following
)->next
;
2335 /* Return the symbol in OBARRAY whose names matches the string
2336 of SIZE characters (SIZE_BYTE bytes) at PTR.
2337 If there is no such symbol in OBARRAY, return nil.
2339 Also store the bucket number in oblookup_last_bucket_number. */
2342 oblookup (obarray
, ptr
, size
, size_byte
)
2343 Lisp_Object obarray
;
2345 int size
, size_byte
;
2349 register Lisp_Object tail
;
2350 Lisp_Object bucket
, tem
;
2352 if (!VECTORP (obarray
)
2353 || (obsize
= XVECTOR (obarray
)->size
) == 0)
2355 obarray
= check_obarray (obarray
);
2356 obsize
= XVECTOR (obarray
)->size
;
2358 /* This is sometimes needed in the middle of GC. */
2359 obsize
&= ~ARRAY_MARK_FLAG
;
2360 /* Combining next two lines breaks VMS C 2.3. */
2361 hash
= hash_string (ptr
, size_byte
);
2363 bucket
= XVECTOR (obarray
)->contents
[hash
];
2364 oblookup_last_bucket_number
= hash
;
2365 if (XFASTINT (bucket
) == 0)
2367 else if (!SYMBOLP (bucket
))
2368 error ("Bad data in guts of obarray"); /* Like CADR error message */
2370 for (tail
= bucket
; ; XSETSYMBOL (tail
, XSYMBOL (tail
)->next
))
2372 if (XSYMBOL (tail
)->name
->size_byte
== size_byte
2373 && XSYMBOL (tail
)->name
->size
== size
2374 && !bcmp (XSYMBOL (tail
)->name
->data
, ptr
, size_byte
))
2376 else if (XSYMBOL (tail
)->next
== 0)
2379 XSETINT (tem
, hash
);
2384 hash_string (ptr
, len
)
2388 register unsigned char *p
= ptr
;
2389 register unsigned char *end
= p
+ len
;
2390 register unsigned char c
;
2391 register int hash
= 0;
2396 if (c
>= 0140) c
-= 40;
2397 hash
= ((hash
<<3) + (hash
>>28) + c
);
2399 return hash
& 07777777777;
2403 map_obarray (obarray
, fn
, arg
)
2404 Lisp_Object obarray
;
2405 void (*fn
) P_ ((Lisp_Object
, Lisp_Object
));
2409 register Lisp_Object tail
;
2410 CHECK_VECTOR (obarray
, 1);
2411 for (i
= XVECTOR (obarray
)->size
- 1; i
>= 0; i
--)
2413 tail
= XVECTOR (obarray
)->contents
[i
];
2418 if (XSYMBOL (tail
)->next
== 0)
2420 XSETSYMBOL (tail
, XSYMBOL (tail
)->next
);
2426 mapatoms_1 (sym
, function
)
2427 Lisp_Object sym
, function
;
2429 call1 (function
, sym
);
2432 DEFUN ("mapatoms", Fmapatoms
, Smapatoms
, 1, 2, 0,
2433 "Call FUNCTION on every symbol in OBARRAY.\n\
2434 OBARRAY defaults to the value of `obarray'.")
2436 Lisp_Object function
, obarray
;
2440 if (NILP (obarray
)) obarray
= Vobarray
;
2441 obarray
= check_obarray (obarray
);
2443 map_obarray (obarray
, mapatoms_1
, function
);
2447 #define OBARRAY_SIZE 1511
2452 Lisp_Object oblength
;
2456 XSETFASTINT (oblength
, OBARRAY_SIZE
);
2458 Qnil
= Fmake_symbol (make_pure_string ("nil", 3, 3));
2459 Vobarray
= Fmake_vector (oblength
, make_number (0));
2460 initial_obarray
= Vobarray
;
2461 staticpro (&initial_obarray
);
2462 /* Intern nil in the obarray */
2463 XSYMBOL (Qnil
)->obarray
= Vobarray
;
2464 /* These locals are to kludge around a pyramid compiler bug. */
2465 hash
= hash_string ("nil", 3);
2466 /* Separate statement here to avoid VAXC bug. */
2467 hash
%= OBARRAY_SIZE
;
2468 tem
= &XVECTOR (Vobarray
)->contents
[hash
];
2471 Qunbound
= Fmake_symbol (make_pure_string ("unbound", 7, 7));
2472 XSYMBOL (Qnil
)->function
= Qunbound
;
2473 XSYMBOL (Qunbound
)->value
= Qunbound
;
2474 XSYMBOL (Qunbound
)->function
= Qunbound
;
2477 XSYMBOL (Qnil
)->value
= Qnil
;
2478 XSYMBOL (Qnil
)->plist
= Qnil
;
2479 XSYMBOL (Qt
)->value
= Qt
;
2481 /* Qt is correct even if CANNOT_DUMP. loadup.el will set to nil at end. */
2484 Qvariable_documentation
= intern ("variable-documentation");
2485 staticpro (&Qvariable_documentation
);
2487 read_buffer_size
= 100;
2488 read_buffer
= (char *) malloc (read_buffer_size
);
2493 struct Lisp_Subr
*sname
;
2496 sym
= intern (sname
->symbol_name
);
2497 XSETSUBR (XSYMBOL (sym
)->function
, sname
);
2500 #ifdef NOTDEF /* use fset in subr.el now */
2502 defalias (sname
, string
)
2503 struct Lisp_Subr
*sname
;
2507 sym
= intern (string
);
2508 XSETSUBR (XSYMBOL (sym
)->function
, sname
);
2512 /* Define an "integer variable"; a symbol whose value is forwarded
2513 to a C variable of type int. Sample call: */
2514 /* DEFVAR_INT ("indent-tabs-mode", &indent_tabs_mode, "Documentation"); */
2516 defvar_int (namestring
, address
)
2520 Lisp_Object sym
, val
;
2521 sym
= intern (namestring
);
2522 val
= allocate_misc ();
2523 XMISCTYPE (val
) = Lisp_Misc_Intfwd
;
2524 XINTFWD (val
)->intvar
= address
;
2525 XSYMBOL (sym
)->value
= val
;
2528 /* Similar but define a variable whose value is T if address contains 1,
2529 NIL if address contains 0 */
2531 defvar_bool (namestring
, address
)
2535 Lisp_Object sym
, val
;
2536 sym
= intern (namestring
);
2537 val
= allocate_misc ();
2538 XMISCTYPE (val
) = Lisp_Misc_Boolfwd
;
2539 XBOOLFWD (val
)->boolvar
= address
;
2540 XSYMBOL (sym
)->value
= val
;
2543 /* Similar but define a variable whose value is the Lisp Object stored
2544 at address. Two versions: with and without gc-marking of the C
2545 variable. The nopro version is used when that variable will be
2546 gc-marked for some other reason, since marking the same slot twice
2547 can cause trouble with strings. */
2549 defvar_lisp_nopro (namestring
, address
)
2551 Lisp_Object
*address
;
2553 Lisp_Object sym
, val
;
2554 sym
= intern (namestring
);
2555 val
= allocate_misc ();
2556 XMISCTYPE (val
) = Lisp_Misc_Objfwd
;
2557 XOBJFWD (val
)->objvar
= address
;
2558 XSYMBOL (sym
)->value
= val
;
2562 defvar_lisp (namestring
, address
)
2564 Lisp_Object
*address
;
2566 defvar_lisp_nopro (namestring
, address
);
2567 staticpro (address
);
2572 /* Similar but define a variable whose value is the Lisp Object stored in
2573 the current buffer. address is the address of the slot in the buffer
2574 that is current now. */
2577 defvar_per_buffer (namestring
, address
, type
, doc
)
2579 Lisp_Object
*address
;
2583 Lisp_Object sym
, val
;
2585 extern struct buffer buffer_local_symbols
;
2587 sym
= intern (namestring
);
2588 val
= allocate_misc ();
2589 offset
= (char *)address
- (char *)current_buffer
;
2591 XMISCTYPE (val
) = Lisp_Misc_Buffer_Objfwd
;
2592 XBUFFER_OBJFWD (val
)->offset
= offset
;
2593 XSYMBOL (sym
)->value
= val
;
2594 *(Lisp_Object
*)(offset
+ (char *)&buffer_local_symbols
) = sym
;
2595 *(Lisp_Object
*)(offset
+ (char *)&buffer_local_types
) = type
;
2596 if (XINT (*(Lisp_Object
*)(offset
+ (char *)&buffer_local_flags
)) == 0)
2597 /* Did a DEFVAR_PER_BUFFER without initializing the corresponding
2598 slot of buffer_local_flags */
2602 #endif /* standalone */
2604 /* Similar but define a variable whose value is the Lisp Object stored
2605 at a particular offset in the current kboard object. */
2608 defvar_kboard (namestring
, offset
)
2612 Lisp_Object sym
, val
;
2613 sym
= intern (namestring
);
2614 val
= allocate_misc ();
2615 XMISCTYPE (val
) = Lisp_Misc_Kboard_Objfwd
;
2616 XKBOARD_OBJFWD (val
)->offset
= offset
;
2617 XSYMBOL (sym
)->value
= val
;
2620 /* Record the value of load-path used at the start of dumping
2621 so we can see if the site changed it later during dumping. */
2622 static Lisp_Object dump_path
;
2628 int turn_off_warning
= 0;
2630 #ifdef HAVE_SETLOCALE
2631 /* Make sure numbers are parsed as we expect. */
2632 setlocale (LC_NUMERIC
, "C");
2633 #endif /* HAVE_SETLOCALE */
2635 /* Compute the default load-path. */
2637 normal
= PATH_LOADSEARCH
;
2638 Vload_path
= decode_env_path (0, normal
);
2640 if (NILP (Vpurify_flag
))
2641 normal
= PATH_LOADSEARCH
;
2643 normal
= PATH_DUMPLOADSEARCH
;
2645 /* In a dumped Emacs, we normally have to reset the value of
2646 Vload_path from PATH_LOADSEARCH, since the value that was dumped
2647 uses ../lisp, instead of the path of the installed elisp
2648 libraries. However, if it appears that Vload_path was changed
2649 from the default before dumping, don't override that value. */
2652 if (! NILP (Fequal (dump_path
, Vload_path
)))
2654 Vload_path
= decode_env_path (0, normal
);
2655 if (!NILP (Vinstallation_directory
))
2657 /* Add to the path the lisp subdir of the
2658 installation dir, if it exists. */
2659 Lisp_Object tem
, tem1
;
2660 tem
= Fexpand_file_name (build_string ("lisp"),
2661 Vinstallation_directory
);
2662 tem1
= Ffile_exists_p (tem
);
2665 if (NILP (Fmember (tem
, Vload_path
)))
2667 turn_off_warning
= 1;
2668 Vload_path
= nconc2 (Vload_path
, Fcons (tem
, Qnil
));
2672 /* That dir doesn't exist, so add the build-time
2673 Lisp dirs instead. */
2674 Vload_path
= nconc2 (Vload_path
, dump_path
);
2676 /* Add leim under the installation dir, if it exists. */
2677 tem
= Fexpand_file_name (build_string ("leim"),
2678 Vinstallation_directory
);
2679 tem1
= Ffile_exists_p (tem
);
2682 if (NILP (Fmember (tem
, Vload_path
)))
2683 Vload_path
= nconc2 (Vload_path
, Fcons (tem
, Qnil
));
2686 /* Add site-list under the installation dir, if it exists. */
2687 tem
= Fexpand_file_name (build_string ("site-lisp"),
2688 Vinstallation_directory
);
2689 tem1
= Ffile_exists_p (tem
);
2692 if (NILP (Fmember (tem
, Vload_path
)))
2693 Vload_path
= nconc2 (Vload_path
, Fcons (tem
, Qnil
));
2696 /* If Emacs was not built in the source directory,
2697 and it is run from where it was built, add to load-path
2698 the lisp, leim and site-lisp dirs under that directory. */
2700 if (NILP (Fequal (Vinstallation_directory
, Vsource_directory
)))
2704 tem
= Fexpand_file_name (build_string ("src/Makefile"),
2705 Vinstallation_directory
);
2706 tem1
= Ffile_exists_p (tem
);
2708 /* Don't be fooled if they moved the entire source tree
2709 AFTER dumping Emacs. If the build directory is indeed
2710 different from the source dir, src/Makefile.in and
2711 src/Makefile will not be found together. */
2712 tem
= Fexpand_file_name (build_string ("src/Makefile.in"),
2713 Vinstallation_directory
);
2714 tem2
= Ffile_exists_p (tem
);
2715 if (!NILP (tem1
) && NILP (tem2
))
2717 tem
= Fexpand_file_name (build_string ("lisp"),
2720 if (NILP (Fmember (tem
, Vload_path
)))
2721 Vload_path
= nconc2 (Vload_path
, Fcons (tem
, Qnil
));
2723 tem
= Fexpand_file_name (build_string ("leim"),
2726 if (NILP (Fmember (tem
, Vload_path
)))
2727 Vload_path
= nconc2 (Vload_path
, Fcons (tem
, Qnil
));
2729 tem
= Fexpand_file_name (build_string ("site-lisp"),
2732 if (NILP (Fmember (tem
, Vload_path
)))
2733 Vload_path
= nconc2 (Vload_path
, Fcons (tem
, Qnil
));
2741 /* NORMAL refers to the lisp dir in the source directory. */
2742 /* We used to add ../lisp at the front here, but
2743 that caused trouble because it was copied from dump_path
2744 into Vload_path, aboe, when Vinstallation_directory was non-nil.
2745 It should be unnecessary. */
2746 Vload_path
= decode_env_path (0, normal
);
2747 dump_path
= Vload_path
;
2752 /* When Emacs is invoked over network shares on NT, PATH_LOADSEARCH is
2753 almost never correct, thereby causing a warning to be printed out that
2754 confuses users. Since PATH_LOADSEARCH is always overridden by the
2755 EMACSLOADPATH environment variable below, disable the warning on NT. */
2757 /* Warn if dirs in the *standard* path don't exist. */
2758 if (!turn_off_warning
)
2760 Lisp_Object path_tail
;
2762 for (path_tail
= Vload_path
;
2764 path_tail
= XCONS (path_tail
)->cdr
)
2766 Lisp_Object dirfile
;
2767 dirfile
= Fcar (path_tail
);
2768 if (STRINGP (dirfile
))
2770 dirfile
= Fdirectory_file_name (dirfile
);
2771 if (access (XSTRING (dirfile
)->data
, 0) < 0)
2772 dir_warning ("Warning: Lisp directory `%s' does not exist.\n",
2773 XCONS (path_tail
)->car
);
2777 #endif /* WINDOWSNT */
2779 /* If the EMACSLOADPATH environment variable is set, use its value.
2780 This doesn't apply if we're dumping. */
2782 if (NILP (Vpurify_flag
)
2783 && egetenv ("EMACSLOADPATH"))
2785 Vload_path
= decode_env_path ("EMACSLOADPATH", normal
);
2789 load_in_progress
= 0;
2790 Vload_file_name
= Qnil
;
2792 load_descriptor_list
= Qnil
;
2795 /* Print a warning, using format string FORMAT, that directory DIRNAME
2796 does not exist. Print it on stderr and put it in *Message*. */
2799 dir_warning (format
, dirname
)
2801 Lisp_Object dirname
;
2804 = (char *) alloca (XSTRING (dirname
)->size
+ strlen (format
) + 5);
2806 fprintf (stderr
, format
, XSTRING (dirname
)->data
);
2807 sprintf (buffer
, format
, XSTRING (dirname
)->data
);
2808 message_dolog (buffer
, strlen (buffer
), 0, STRING_MULTIBYTE (dirname
));
2815 defsubr (&Sread_from_string
);
2817 defsubr (&Sintern_soft
);
2818 defsubr (&Sunintern
);
2820 defsubr (&Seval_buffer
);
2821 defsubr (&Seval_region
);
2822 defsubr (&Sread_char
);
2823 defsubr (&Sread_char_exclusive
);
2824 defsubr (&Sread_event
);
2825 defsubr (&Sget_file_char
);
2826 defsubr (&Smapatoms
);
2828 DEFVAR_LISP ("obarray", &Vobarray
,
2829 "Symbol table for use by `intern' and `read'.\n\
2830 It is a vector whose length ought to be prime for best results.\n\
2831 The vector's contents don't make sense if examined from Lisp programs;\n\
2832 to find all the symbols in an obarray, use `mapatoms'.");
2834 DEFVAR_LISP ("values", &Vvalues
,
2835 "List of values of all expressions which were read, evaluated and printed.\n\
2836 Order is reverse chronological.");
2838 DEFVAR_LISP ("standard-input", &Vstandard_input
,
2839 "Stream for read to get input from.\n\
2840 See documentation of `read' for possible values.");
2841 Vstandard_input
= Qt
;
2843 DEFVAR_LISP ("load-path", &Vload_path
,
2844 "*List of directories to search for files to load.\n\
2845 Each element is a string (directory name) or nil (try default directory).\n\
2846 Initialized based on EMACSLOADPATH environment variable, if any,\n\
2847 otherwise to default specified by file `paths.h' when Emacs was built.");
2849 DEFVAR_BOOL ("load-in-progress", &load_in_progress
,
2850 "Non-nil iff inside of `load'.");
2852 DEFVAR_LISP ("after-load-alist", &Vafter_load_alist
,
2853 "An alist of expressions to be evalled when particular files are loaded.\n\
2854 Each element looks like (FILENAME FORMS...).\n\
2855 When `load' is run and the file-name argument is FILENAME,\n\
2856 the FORMS in the corresponding element are executed at the end of loading.\n\n\
2857 FILENAME must match exactly! Normally FILENAME is the name of a library,\n\
2858 with no directory specified, since that is how `load' is normally called.\n\
2859 An error in FORMS does not undo the load,\n\
2860 but does prevent execution of the rest of the FORMS.");
2861 Vafter_load_alist
= Qnil
;
2863 DEFVAR_LISP ("load-history", &Vload_history
,
2864 "Alist mapping source file names to symbols and features.\n\
2865 Each alist element is a list that starts with a file name,\n\
2866 except for one element (optional) that starts with nil and describes\n\
2867 definitions evaluated from buffers not visiting files.\n\
2868 The remaining elements of each list are symbols defined as functions\n\
2869 or variables, and cons cells `(provide . FEATURE)' and `(require . FEATURE)'.");
2870 Vload_history
= Qnil
;
2872 DEFVAR_LISP ("load-file-name", &Vload_file_name
,
2873 "Full name of file being loaded by `load'.");
2874 Vload_file_name
= Qnil
;
2876 DEFVAR_LISP ("current-load-list", &Vcurrent_load_list
,
2877 "Used for internal purposes by `load'.");
2878 Vcurrent_load_list
= Qnil
;
2880 DEFVAR_LISP ("load-read-function", &Vload_read_function
,
2881 "Function used by `load' and `eval-region' for reading expressions.\n\
2882 The default is nil, which means use the function `read'.");
2883 Vload_read_function
= Qnil
;
2885 DEFVAR_LISP ("load-source-file-function", &Vload_source_file_function
,
2886 "Function called in `load' for loading an Emacs lisp source file.\n\
2887 This function is for doing code conversion before reading the source file.\n\
2888 If nil, loading is done without any code conversion.\n\
2889 Arguments are FULLNAME, FILE, NOERROR, NOMESSAGE, where\n\
2890 FULLNAME is the full name of FILE.\n\
2891 See `load' for the meaning of the remaining arguments.");
2892 Vload_source_file_function
= Qnil
;
2894 DEFVAR_BOOL ("load-force-doc-strings", &load_force_doc_strings
,
2895 "Non-nil means `load' should force-load all dynamic doc strings.\n\
2896 This is useful when the file being loaded is a temporary copy.");
2897 load_force_doc_strings
= 0;
2899 DEFVAR_LISP ("source-directory", &Vsource_directory
,
2900 "Directory in which Emacs sources were found when Emacs was built.\n\
2901 You cannot count on them to still be there!");
2903 = Fexpand_file_name (build_string ("../"),
2904 Fcar (decode_env_path (0, PATH_DUMPLOADSEARCH
)));
2906 DEFVAR_LISP ("preloaded-file-list", &Vpreloaded_file_list
,
2907 "List of files that were preloaded (when dumping Emacs).");
2908 Vpreloaded_file_list
= Qnil
;
2910 /* Vsource_directory was initialized in init_lread. */
2912 load_descriptor_list
= Qnil
;
2913 staticpro (&load_descriptor_list
);
2915 Qcurrent_load_list
= intern ("current-load-list");
2916 staticpro (&Qcurrent_load_list
);
2918 Qstandard_input
= intern ("standard-input");
2919 staticpro (&Qstandard_input
);
2921 Qread_char
= intern ("read-char");
2922 staticpro (&Qread_char
);
2924 Qget_file_char
= intern ("get-file-char");
2925 staticpro (&Qget_file_char
);
2927 Qbackquote
= intern ("`");
2928 staticpro (&Qbackquote
);
2929 Qcomma
= intern (",");
2930 staticpro (&Qcomma
);
2931 Qcomma_at
= intern (",@");
2932 staticpro (&Qcomma_at
);
2933 Qcomma_dot
= intern (",.");
2934 staticpro (&Qcomma_dot
);
2936 Qinhibit_file_name_operation
= intern ("inhibit-file-name-operation");
2937 staticpro (&Qinhibit_file_name_operation
);
2939 Qascii_character
= intern ("ascii-character");
2940 staticpro (&Qascii_character
);
2942 Qfunction
= intern ("function");
2943 staticpro (&Qfunction
);
2945 Qload
= intern ("load");
2948 Qload_file_name
= intern ("load-file-name");
2949 staticpro (&Qload_file_name
);
2951 staticpro (&dump_path
);
2953 staticpro (&read_objects
);
2954 read_objects
= Qnil
;