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 /* This contains the last string skipped with #@, but only on some systems.
134 On other systems we can't put the string here. */
135 static char *saved_doc_string
;
136 /* Length of buffer allocated in saved_doc_string. */
137 static int saved_doc_string_size
;
138 /* Length of actual data in saved_doc_string. */
139 static int saved_doc_string_length
;
140 /* This is the file position that string came from. */
141 static int saved_doc_string_position
;
143 /* Nonzero means inside a new-style backquote
144 with no surrounding parentheses.
145 Fread initializes this to zero, so we need not specbind it
146 or worry about what happens to it when there is an error. */
147 static int new_backquote_flag
;
149 /* Handle unreading and rereading of characters.
150 Write READCHAR to read a character,
151 UNREAD(c) to unread c to be read again.
153 These macros actually read/unread a byte code, multibyte characters
154 are not handled here. The caller should manage them if necessary.
157 #define READCHAR readchar (readcharfun)
158 #define UNREAD(c) unreadchar (readcharfun, c)
161 readchar (readcharfun
)
162 Lisp_Object readcharfun
;
165 register struct buffer
*inbuffer
;
166 register int c
, mpos
;
168 if (BUFFERP (readcharfun
))
170 inbuffer
= XBUFFER (readcharfun
);
172 if (BUF_PT (inbuffer
) >= BUF_ZV (inbuffer
))
174 c
= *(unsigned char *) BUF_CHAR_ADDRESS (inbuffer
, BUF_PT (inbuffer
));
175 SET_BUF_PT (inbuffer
, BUF_PT (inbuffer
) + 1);
179 if (MARKERP (readcharfun
))
181 inbuffer
= XMARKER (readcharfun
)->buffer
;
183 mpos
= marker_position (readcharfun
);
185 if (mpos
> BUF_ZV (inbuffer
) - 1)
187 c
= *(unsigned char *) BUF_CHAR_ADDRESS (inbuffer
, mpos
);
188 if (mpos
!= BUF_GPT (inbuffer
))
189 XMARKER (readcharfun
)->bufpos
++;
191 Fset_marker (readcharfun
, make_number (mpos
+ 1),
192 Fmarker_buffer (readcharfun
));
195 if (EQ (readcharfun
, Qget_file_char
))
199 /* Interrupted reads have been observed while reading over the network */
200 while (c
== EOF
&& ferror (instream
) && errno
== EINTR
)
209 if (STRINGP (readcharfun
))
212 /* This used to be return of a conditional expression,
213 but that truncated -1 to a char on VMS. */
214 if (read_from_string_index
< read_from_string_limit
)
215 c
= XSTRING (readcharfun
)->data
[read_from_string_index
++];
221 tem
= call0 (readcharfun
);
228 /* Unread the character C in the way appropriate for the stream READCHARFUN.
229 If the stream is a user function, call it with the char as argument. */
232 unreadchar (readcharfun
, c
)
233 Lisp_Object readcharfun
;
237 /* Don't back up the pointer if we're unreading the end-of-input mark,
238 since readchar didn't advance it when we read it. */
240 else if (BUFFERP (readcharfun
))
242 if (XBUFFER (readcharfun
) == current_buffer
)
245 SET_BUF_PT (XBUFFER (readcharfun
), BUF_PT (XBUFFER (readcharfun
)) - 1);
247 else if (MARKERP (readcharfun
))
248 XMARKER (readcharfun
)->bufpos
--;
249 else if (STRINGP (readcharfun
))
250 read_from_string_index
--;
251 else if (EQ (readcharfun
, Qget_file_char
))
252 ungetc (c
, instream
);
254 call1 (readcharfun
, make_number (c
));
257 static Lisp_Object
read0 (), read1 (), read_list (), read_vector ();
259 /* get a character from the tty */
261 extern Lisp_Object
read_char ();
263 /* Read input events until we get one that's acceptable for our purposes.
265 If NO_SWITCH_FRAME is non-zero, switch-frame events are stashed
266 until we get a character we like, and then stuffed into
269 If ASCII_REQUIRED is non-zero, we check function key events to see
270 if the unmodified version of the symbol has a Qascii_character
271 property, and use that character, if present.
273 If ERROR_NONASCII is non-zero, we signal an error if the input we
274 get isn't an ASCII character with modifiers. If it's zero but
275 ASCII_REQUIRED is non-zero, we just re-read until we get an ASCII
279 read_filtered_event (no_switch_frame
, ascii_required
, error_nonascii
)
280 int no_switch_frame
, ascii_required
, error_nonascii
;
283 return make_number (getchar ());
285 register Lisp_Object val
, delayed_switch_frame
;
287 delayed_switch_frame
= Qnil
;
289 /* Read until we get an acceptable event. */
291 val
= read_char (0, 0, 0, Qnil
, 0);
296 /* switch-frame events are put off until after the next ASCII
297 character. This is better than signaling an error just because
298 the last characters were typed to a separate minibuffer frame,
299 for example. Eventually, some code which can deal with
300 switch-frame events will read it and process it. */
302 && EVENT_HAS_PARAMETERS (val
)
303 && EQ (EVENT_HEAD (val
), Qswitch_frame
))
305 delayed_switch_frame
= val
;
311 /* Convert certain symbols to their ASCII equivalents. */
314 Lisp_Object tem
, tem1
, tem2
;
315 tem
= Fget (val
, Qevent_symbol_element_mask
);
318 tem1
= Fget (Fcar (tem
), Qascii_character
);
319 /* Merge this symbol's modifier bits
320 with the ASCII equivalent of its basic code. */
322 XSETFASTINT (val
, XINT (tem1
) | XINT (Fcar (Fcdr (tem
))));
326 /* If we don't have a character now, deal with it appropriately. */
331 Vunread_command_events
= Fcons (val
, Qnil
);
332 error ("Non-character input-event");
339 if (! NILP (delayed_switch_frame
))
340 unread_switch_frame
= delayed_switch_frame
;
346 DEFUN ("read-char", Fread_char
, Sread_char
, 0, 0, 0,
347 "Read a character from the command input (keyboard or macro).\n\
348 It is returned as a number.\n\
349 If the user generates an event which is not a character (i.e. a mouse\n\
350 click or function key event), `read-char' signals an error. As an\n\
351 exception, switch-frame events are put off until non-ASCII events can\n\
353 If you want to read non-character events, or ignore them, call\n\
354 `read-event' or `read-char-exclusive' instead.")
357 return read_filtered_event (1, 1, 1);
360 DEFUN ("read-event", Fread_event
, Sread_event
, 0, 0, 0,
361 "Read an event object from the input stream.")
364 return read_filtered_event (0, 0, 0);
367 DEFUN ("read-char-exclusive", Fread_char_exclusive
, Sread_char_exclusive
, 0, 0, 0,
368 "Read a character from the command input (keyboard or macro).\n\
369 It is returned as a number. Non-character events are ignored.")
372 return read_filtered_event (1, 1, 0);
375 DEFUN ("get-file-char", Fget_file_char
, Sget_file_char
, 0, 0, 0,
376 "Don't use this yourself.")
379 register Lisp_Object val
;
380 XSETINT (val
, getc (instream
));
384 static void readevalloop ();
385 static Lisp_Object
load_unwind ();
386 static Lisp_Object
load_descriptor_unwind ();
388 DEFUN ("load", Fload
, Sload
, 1, 5, 0,
389 "Execute a file of Lisp code named FILE.\n\
390 First try FILE with `.elc' appended, then try with `.el',\n\
391 then try FILE unmodified.\n\
392 This function searches the directories in `load-path'.\n\
393 If optional second arg NOERROR is non-nil,\n\
394 report no error if FILE doesn't exist.\n\
395 Print messages at start and end of loading unless\n\
396 optional third arg NOMESSAGE is non-nil.\n\
397 If optional fourth arg NOSUFFIX is non-nil, don't try adding\n\
398 suffixes `.elc' or `.el' to the specified name FILE.\n\
399 If optional fifth arg MUST-SUFFIX is non-nil, insist on\n\
400 the suffix `.elc' or `.el'; don't accept just FILE unless\n\
401 it ends in one of those suffixes or includes a directory name.\n\
402 Return t if file exists.")
403 (file
, noerror
, nomessage
, nosuffix
, must_suffix
)
404 Lisp_Object file
, noerror
, nomessage
, nosuffix
, must_suffix
;
406 register FILE *stream
;
407 register int fd
= -1;
408 register Lisp_Object lispstream
;
409 int count
= specpdl_ptr
- specpdl
;
413 /* 1 means we printed the ".el is newer" message. */
415 /* 1 means we are loading a compiled file. */
419 char *dosmode
= "rt";
422 CHECK_STRING (file
, 0);
424 /* If file name is magic, call the handler. */
425 handler
= Ffind_file_name_handler (file
, Qload
);
427 return call5 (handler
, Qload
, file
, noerror
, nomessage
, nosuffix
);
429 /* Do this after the handler to avoid
430 the need to gcpro noerror, nomessage and nosuffix.
431 (Below here, we care only whether they are nil or not.) */
432 file
= Fsubstitute_in_file_name (file
);
434 /* Avoid weird lossage with null string as arg,
435 since it would try to load a directory as a Lisp file */
436 if (XSTRING (file
)->size
> 0)
438 int size
= XSTRING (file
)->size
;
442 if (! NILP (must_suffix
))
444 /* Don't insist on adding a suffix if FILE already ends with one. */
446 && !strcmp (XSTRING (file
)->data
+ size
- 3, ".el"))
449 && !strcmp (XSTRING (file
)->data
+ size
- 4, ".elc"))
451 /* Don't insist on adding a suffix
452 if the argument includes a directory name. */
453 else if (! NILP (Ffile_name_directory (file
)))
457 fd
= openp (Vload_path
, file
,
458 (!NILP (nosuffix
) ? ""
459 : ! NILP (must_suffix
) ? ".elc:.el"
469 Fsignal (Qfile_error
, Fcons (build_string ("Cannot open load file"),
470 Fcons (file
, Qnil
)));
475 /* If FD is 0, that means openp found a remote file. */
478 handler
= Ffind_file_name_handler (found
, Qload
);
479 return call5 (handler
, Qload
, found
, noerror
, nomessage
, Qt
);
482 if (!bcmp (&(XSTRING (found
)->data
[XSTRING (found
)->size
- 4]),
493 stat ((char *)XSTRING (found
)->data
, &s1
);
494 XSTRING (found
)->data
[XSTRING (found
)->size
- 1] = 0;
495 result
= stat ((char *)XSTRING (found
)->data
, &s2
);
496 if (result
>= 0 && (unsigned) s1
.st_mtime
< (unsigned) s2
.st_mtime
)
498 /* Make the progress messages mention that source is newer. */
501 /* If we won't print another message, mention this anyway. */
502 if (! NILP (nomessage
))
503 message ("Source file `%s' newer than byte-compiled file",
504 XSTRING (found
)->data
);
506 XSTRING (found
)->data
[XSTRING (found
)->size
- 1] = 'c';
510 /* We are loading a source file (*.el). */
511 if (!NILP (Vload_source_file_function
))
514 return call4 (Vload_source_file_function
, found
, file
,
515 NILP (noerror
) ? Qnil
: Qt
,
516 NILP (nomessage
) ? Qnil
: Qt
);
522 stream
= fopen ((char *) XSTRING (found
)->data
, dosmode
);
523 #else /* not DOS_NT */
524 stream
= fdopen (fd
, "r");
525 #endif /* not DOS_NT */
529 error ("Failure to create stdio stream for %s", XSTRING (file
)->data
);
532 if (! NILP (Vpurify_flag
))
533 Vpreloaded_file_list
= Fcons (file
, Vpreloaded_file_list
);
535 if (NILP (nomessage
))
538 message ("Loading %s (source)...", XSTRING (file
)->data
);
540 message ("Loading %s (compiled; note, source file is newer)...",
541 XSTRING (file
)->data
);
542 else /* The typical case; compiled file newer than source file. */
543 message ("Loading %s...", XSTRING (file
)->data
);
547 lispstream
= Fcons (Qnil
, Qnil
);
548 XSETFASTINT (XCONS (lispstream
)->car
, (EMACS_UINT
)stream
>> 16);
549 XSETFASTINT (XCONS (lispstream
)->cdr
, (EMACS_UINT
)stream
& 0xffff);
550 record_unwind_protect (load_unwind
, lispstream
);
551 record_unwind_protect (load_descriptor_unwind
, load_descriptor_list
);
552 specbind (Qload_file_name
, found
);
553 specbind (Qinhibit_file_name_operation
, Qnil
);
555 = Fcons (make_number (fileno (stream
)), load_descriptor_list
);
557 readevalloop (Qget_file_char
, stream
, file
, Feval
, 0);
558 unbind_to (count
, Qnil
);
560 /* Run any load-hooks for this file. */
561 temp
= Fassoc (file
, Vafter_load_alist
);
563 Fprogn (Fcdr (temp
));
566 if (saved_doc_string
)
567 free (saved_doc_string
);
568 saved_doc_string
= 0;
569 saved_doc_string_size
= 0;
571 if (!noninteractive
&& NILP (nomessage
))
574 message ("Loading %s (source)...done", XSTRING (file
)->data
);
576 message ("Loading %s (compiled; note, source file is newer)...done",
577 XSTRING (file
)->data
);
578 else /* The typical case; compiled file newer than source file. */
579 message ("Loading %s...done", XSTRING (file
)->data
);
585 load_unwind (stream
) /* used as unwind-protect function in load */
588 fclose ((FILE *) (XFASTINT (XCONS (stream
)->car
) << 16
589 | XFASTINT (XCONS (stream
)->cdr
)));
590 if (--load_in_progress
< 0) load_in_progress
= 0;
595 load_descriptor_unwind (oldlist
)
598 load_descriptor_list
= oldlist
;
602 /* Close all descriptors in use for Floads.
603 This is used when starting a subprocess. */
610 for (tail
= load_descriptor_list
; !NILP (tail
); tail
= XCONS (tail
)->cdr
)
611 close (XFASTINT (XCONS (tail
)->car
));
616 complete_filename_p (pathname
)
617 Lisp_Object pathname
;
619 register unsigned char *s
= XSTRING (pathname
)->data
;
620 return (IS_DIRECTORY_SEP (s
[0])
621 || (XSTRING (pathname
)->size
> 2
622 && IS_DEVICE_SEP (s
[1]) && IS_DIRECTORY_SEP (s
[2]))
632 /* Search for a file whose name is STR, looking in directories
633 in the Lisp list PATH, and trying suffixes from SUFFIX.
634 SUFFIX is a string containing possible suffixes separated by colons.
635 On success, returns a file descriptor. On failure, returns -1.
637 EXEC_ONLY nonzero means don't open the files,
638 just look for one that is executable. In this case,
639 returns 1 on success.
641 If STOREPTR is nonzero, it points to a slot where the name of
642 the file actually found should be stored as a Lisp string.
643 nil is stored there on failure.
645 If the file we find is remote, return 0
646 but store the found remote file name in *STOREPTR.
647 We do not check for remote files if EXEC_ONLY is nonzero. */
650 openp (path
, str
, suffix
, storeptr
, exec_only
)
651 Lisp_Object path
, str
;
653 Lisp_Object
*storeptr
;
659 register char *fn
= buf
;
662 Lisp_Object filename
;
670 if (complete_filename_p (str
))
673 for (; !NILP (path
); path
= Fcdr (path
))
677 filename
= Fexpand_file_name (str
, Fcar (path
));
678 if (!complete_filename_p (filename
))
679 /* If there are non-absolute elts in PATH (eg ".") */
680 /* Of course, this could conceivably lose if luser sets
681 default-directory to be something non-absolute... */
683 filename
= Fexpand_file_name (filename
, current_buffer
->directory
);
684 if (!complete_filename_p (filename
))
685 /* Give up on this path element! */
689 /* Calculate maximum size of any filename made from
690 this path element/specified file name and any possible suffix. */
691 want_size
= strlen (suffix
) + XSTRING (filename
)->size
+ 1;
692 if (fn_size
< want_size
)
693 fn
= (char *) alloca (fn_size
= 100 + want_size
);
697 /* Loop over suffixes. */
700 char *esuffix
= (char *) index (nsuffix
, ':');
701 int lsuffix
= esuffix
? esuffix
- nsuffix
: strlen (nsuffix
);
704 /* Concatenate path element/specified name with the suffix.
705 If the directory starts with /:, remove that. */
706 if (XSTRING (filename
)->size
> 2
707 && XSTRING (filename
)->data
[0] == '/'
708 && XSTRING (filename
)->data
[1] == ':')
710 strncpy (fn
, XSTRING (filename
)->data
+ 2,
711 XSTRING (filename
)->size
- 2);
712 fn
[XSTRING (filename
)->size
- 2] = 0;
716 strncpy (fn
, XSTRING (filename
)->data
, XSTRING (filename
)->size
);
717 fn
[XSTRING (filename
)->size
] = 0;
720 if (lsuffix
!= 0) /* Bug happens on CCI if lsuffix is 0. */
721 strncat (fn
, nsuffix
, lsuffix
);
723 /* Check that the file exists and is not a directory. */
727 handler
= Ffind_file_name_handler (filename
, Qfile_exists_p
);
728 if (! NILP (handler
) && ! exec_only
)
733 string
= build_string (fn
);
734 exists
= ! NILP (exec_only
? Ffile_executable_p (string
)
735 : Ffile_readable_p (string
));
737 && ! NILP (Ffile_directory_p (build_string (fn
))))
742 /* We succeeded; return this descriptor and filename. */
744 *storeptr
= build_string (fn
);
751 int exists
= (stat (fn
, &st
) >= 0
752 && (st
.st_mode
& S_IFMT
) != S_IFDIR
);
755 /* Check that we can access or open it. */
757 fd
= (access (fn
, X_OK
) == 0) ? 1 : -1;
759 fd
= open (fn
, O_RDONLY
, 0);
763 /* We succeeded; return this descriptor and filename. */
765 *storeptr
= build_string (fn
);
772 /* Advance to next suffix. */
775 nsuffix
+= lsuffix
+ 1;
786 /* Merge the list we've accumulated of globals from the current input source
787 into the load_history variable. The details depend on whether
788 the source has an associated file name or not. */
791 build_load_history (stream
, source
)
795 register Lisp_Object tail
, prev
, newelt
;
796 register Lisp_Object tem
, tem2
;
797 register int foundit
, loading
;
799 /* Don't bother recording anything for preloaded files. */
800 if (!NILP (Vpurify_flag
))
803 loading
= stream
|| !NARROWED
;
805 tail
= Vload_history
;
812 /* Find the feature's previous assoc list... */
813 if (!NILP (Fequal (source
, Fcar (tem
))))
817 /* If we're loading, remove it. */
821 Vload_history
= Fcdr (tail
);
823 Fsetcdr (prev
, Fcdr (tail
));
826 /* Otherwise, cons on new symbols that are not already members. */
829 tem2
= Vcurrent_load_list
;
833 newelt
= Fcar (tem2
);
835 if (NILP (Fmemq (newelt
, tem
)))
836 Fsetcar (tail
, Fcons (Fcar (tem
),
837 Fcons (newelt
, Fcdr (tem
))));
850 /* If we're loading, cons the new assoc onto the front of load-history,
851 the most-recently-loaded position. Also do this if we didn't find
852 an existing member for the current source. */
853 if (loading
|| !foundit
)
854 Vload_history
= Fcons (Fnreverse (Vcurrent_load_list
),
859 unreadpure () /* Used as unwind-protect function in readevalloop */
866 readevalloop (readcharfun
, stream
, sourcename
, evalfun
, printflag
)
867 Lisp_Object readcharfun
;
869 Lisp_Object sourcename
;
870 Lisp_Object (*evalfun
) ();
874 register Lisp_Object val
;
875 int count
= specpdl_ptr
- specpdl
;
877 struct buffer
*b
= 0;
879 if (BUFFERP (readcharfun
))
880 b
= XBUFFER (readcharfun
);
881 else if (MARKERP (readcharfun
))
882 b
= XMARKER (readcharfun
)->buffer
;
884 specbind (Qstandard_input
, readcharfun
);
885 specbind (Qcurrent_load_list
, Qnil
);
889 LOADHIST_ATTACH (sourcename
);
893 if (b
!= 0 && NILP (b
->name
))
894 error ("Reading from killed buffer");
900 while ((c
= READCHAR
) != '\n' && c
!= -1);
905 /* Ignore whitespace here, so we can detect eof. */
906 if (c
== ' ' || c
== '\t' || c
== '\n' || c
== '\f' || c
== '\r')
909 if (!NILP (Vpurify_flag
) && c
== '(')
911 int count1
= specpdl_ptr
- specpdl
;
912 record_unwind_protect (unreadpure
, Qnil
);
913 val
= read_list (-1, readcharfun
);
914 unbind_to (count1
, Qnil
);
920 if (NILP (Vload_read_function
))
921 val
= read0 (readcharfun
);
923 val
= call1 (Vload_read_function
, readcharfun
);
926 val
= (*evalfun
) (val
);
929 Vvalues
= Fcons (val
, Vvalues
);
930 if (EQ (Vstandard_output
, Qt
))
937 build_load_history (stream
, sourcename
);
940 unbind_to (count
, Qnil
);
945 DEFUN ("eval-buffer", Feval_buffer
, Seval_buffer
, 0, 3, "",
946 "Execute the current buffer as Lisp code.\n\
947 Programs can pass two arguments, BUFFER and PRINTFLAG.\n\
948 BUFFER is the buffer to evaluate (nil means use current buffer).\n\
949 PRINTFLAG controls printing of output:\n\
950 nil means discard it; anything else is stream for print.\n\
952 If the optional third argument FILENAME is non-nil,\n\
953 it specifies the file name to use for `load-history'.\n\
955 This function preserves the position of point.")
956 (buffer
, printflag
, filename
)
957 Lisp_Object buffer
, printflag
, filename
;
959 int count
= specpdl_ptr
- specpdl
;
960 Lisp_Object tem
, buf
;
963 buf
= Fcurrent_buffer ();
965 buf
= Fget_buffer (buffer
);
967 error ("No such buffer");
969 if (NILP (printflag
))
975 filename
= XBUFFER (buf
)->filename
;
977 specbind (Qstandard_output
, tem
);
978 record_unwind_protect (save_excursion_restore
, save_excursion_save ());
979 BUF_SET_PT (XBUFFER (buf
), BUF_BEGV (XBUFFER (buf
)));
980 readevalloop (buf
, 0, filename
, Feval
, !NILP (printflag
));
981 unbind_to (count
, Qnil
);
987 XDEFUN ("eval-current-buffer", Feval_current_buffer
, Seval_current_buffer
, 0, 1, "",
988 "Execute the current buffer as Lisp code.\n\
989 Programs can pass argument PRINTFLAG which controls printing of output:\n\
990 nil means discard it; anything else is stream for print.\n\
992 If there is no error, point does not move. If there is an error,\n\
993 point remains at the end of the last character read from the buffer.")
995 Lisp_Object printflag
;
997 int count
= specpdl_ptr
- specpdl
;
998 Lisp_Object tem
, cbuf
;
1000 cbuf
= Fcurrent_buffer ()
1002 if (NILP (printflag
))
1006 specbind (Qstandard_output
, tem
);
1007 record_unwind_protect (save_excursion_restore
, save_excursion_save ());
1009 readevalloop (cbuf
, 0, XBUFFER (cbuf
)->filename
, Feval
, !NILP (printflag
));
1010 return unbind_to (count
, Qnil
);
1014 DEFUN ("eval-region", Feval_region
, Seval_region
, 2, 3, "r",
1015 "Execute the region as Lisp code.\n\
1016 When called from programs, expects two arguments,\n\
1017 giving starting and ending indices in the current buffer\n\
1018 of the text to be executed.\n\
1019 Programs can pass third argument PRINTFLAG which controls output:\n\
1020 nil means discard it; anything else is stream for printing it.\n\
1022 If there is no error, point does not move. If there is an error,\n\
1023 point remains at the end of the last character read from the buffer.")
1024 (start
, end
, printflag
)
1025 Lisp_Object start
, end
, printflag
;
1027 int count
= specpdl_ptr
- specpdl
;
1028 Lisp_Object tem
, cbuf
;
1030 cbuf
= Fcurrent_buffer ();
1032 if (NILP (printflag
))
1036 specbind (Qstandard_output
, tem
);
1038 if (NILP (printflag
))
1039 record_unwind_protect (save_excursion_restore
, save_excursion_save ());
1040 record_unwind_protect (save_restriction_restore
, save_restriction_save ());
1042 /* This both uses start and checks its type. */
1044 Fnarrow_to_region (make_number (BEGV
), end
);
1045 readevalloop (cbuf
, 0, XBUFFER (cbuf
)->filename
, Feval
, !NILP (printflag
));
1047 return unbind_to (count
, Qnil
);
1050 #endif /* standalone */
1052 DEFUN ("read", Fread
, Sread
, 0, 1, 0,
1053 "Read one Lisp expression as text from STREAM, return as Lisp object.\n\
1054 If STREAM is nil, use the value of `standard-input' (which see).\n\
1055 STREAM or the value of `standard-input' may be:\n\
1056 a buffer (read from point and advance it)\n\
1057 a marker (read from where it points and advance it)\n\
1058 a function (call it with no arguments for each character,\n\
1059 call it with a char as argument to push a char back)\n\
1060 a string (takes text from string, starting at the beginning)\n\
1061 t (read text line using minibuffer and use it).")
1065 extern Lisp_Object
Fread_minibuffer ();
1068 stream
= Vstandard_input
;
1069 if (EQ (stream
, Qt
))
1070 stream
= Qread_char
;
1072 new_backquote_flag
= 0;
1073 read_objects
= Qnil
;
1076 if (EQ (stream
, Qread_char
))
1077 return Fread_minibuffer (build_string ("Lisp expression: "), Qnil
);
1080 if (STRINGP (stream
))
1081 return Fcar (Fread_from_string (stream
, Qnil
, Qnil
));
1083 return read0 (stream
);
1086 DEFUN ("read-from-string", Fread_from_string
, Sread_from_string
, 1, 3, 0,
1087 "Read one Lisp expression which is represented as text by STRING.\n\
1088 Returns a cons: (OBJECT-READ . FINAL-STRING-INDEX).\n\
1089 START and END optionally delimit a substring of STRING from which to read;\n\
1090 they default to 0 and (length STRING) respectively.")
1091 (string
, start
, end
)
1092 Lisp_Object string
, start
, end
;
1094 int startval
, endval
;
1097 CHECK_STRING (string
,0);
1100 endval
= XSTRING (string
)->size
;
1102 { CHECK_NUMBER (end
,2);
1103 endval
= XINT (end
);
1104 if (endval
< 0 || endval
> XSTRING (string
)->size
)
1105 args_out_of_range (string
, end
);
1111 { CHECK_NUMBER (start
,1);
1112 startval
= XINT (start
);
1113 if (startval
< 0 || startval
> endval
)
1114 args_out_of_range (string
, start
);
1117 read_from_string_index
= startval
;
1118 read_from_string_limit
= endval
;
1120 new_backquote_flag
= 0;
1121 read_objects
= Qnil
;
1123 tem
= read0 (string
);
1124 return Fcons (tem
, make_number (read_from_string_index
));
1127 /* Use this for recursive reads, in contexts where internal tokens
1131 Lisp_Object readcharfun
;
1133 register Lisp_Object val
;
1136 val
= read1 (readcharfun
, &c
, 0);
1138 Fsignal (Qinvalid_read_syntax
, Fcons (make_string (&c
, 1), Qnil
));
1143 static int read_buffer_size
;
1144 static char *read_buffer
;
1146 /* Read multibyte form and return it as a character. C is a first
1147 byte of multibyte form, and rest of them are read from
1150 read_multibyte (c
, readcharfun
)
1152 Lisp_Object readcharfun
;
1154 /* We need the actual character code of this multibyte
1156 unsigned char str
[MAX_LENGTH_OF_MULTI_BYTE_FORM
];
1160 while ((c
= READCHAR
) >= 0xA0
1161 && len
< MAX_LENGTH_OF_MULTI_BYTE_FORM
)
1164 return STRING_CHAR (str
, len
);
1168 read_escape (readcharfun
)
1169 Lisp_Object readcharfun
;
1171 register int c
= READCHAR
;
1175 error ("End of file");
1201 error ("Invalid escape character syntax");
1204 c
= read_escape (readcharfun
);
1205 return c
| meta_modifier
;
1210 error ("Invalid escape character syntax");
1213 c
= read_escape (readcharfun
);
1214 return c
| shift_modifier
;
1219 error ("Invalid escape character syntax");
1222 c
= read_escape (readcharfun
);
1223 return c
| hyper_modifier
;
1228 error ("Invalid escape character syntax");
1231 c
= read_escape (readcharfun
);
1232 return c
| alt_modifier
;
1237 error ("Invalid escape character syntax");
1240 c
= read_escape (readcharfun
);
1241 return c
| super_modifier
;
1246 error ("Invalid escape character syntax");
1250 c
= read_escape (readcharfun
);
1251 if ((c
& 0177) == '?')
1253 /* ASCII control chars are made from letters (both cases),
1254 as well as the non-letters within 0100...0137. */
1255 else if ((c
& 0137) >= 0101 && (c
& 0137) <= 0132)
1256 return (c
& (037 | ~0177));
1257 else if ((c
& 0177) >= 0100 && (c
& 0177) <= 0137)
1258 return (c
& (037 | ~0177));
1260 return c
| ctrl_modifier
;
1270 /* An octal escape, as in ANSI C. */
1272 register int i
= c
- '0';
1273 register int count
= 0;
1276 if ((c
= READCHAR
) >= '0' && c
<= '7')
1291 /* A hex escape, as in ANSI C. */
1297 if (c
>= '0' && c
<= '9')
1302 else if ((c
>= 'a' && c
<= 'f')
1303 || (c
>= 'A' && c
<= 'F'))
1306 if (c
>= 'a' && c
<= 'f')
1321 if (BASE_LEADING_CODE_P (c
))
1322 c
= read_multibyte (c
, readcharfun
);
1327 /* If the next token is ')' or ']' or '.', we store that character
1328 in *PCH and the return value is not interesting. Else, we store
1329 zero in *PCH and we read and return one lisp object.
1331 FIRST_IN_LIST is nonzero if this is the first element of a list. */
1334 read1 (readcharfun
, pch
, first_in_list
)
1335 register Lisp_Object readcharfun
;
1340 int uninterned_symbol
= 0;
1347 if (c
< 0) return Fsignal (Qend_of_file
, Qnil
);
1352 return read_list (0, readcharfun
);
1355 return read_vector (readcharfun
);
1372 tmp
= read_vector (readcharfun
);
1373 if (XVECTOR (tmp
)->size
< CHAR_TABLE_STANDARD_SLOTS
1374 || XVECTOR (tmp
)->size
> CHAR_TABLE_STANDARD_SLOTS
+ 10)
1375 error ("Invalid size char-table");
1376 XSETCHAR_TABLE (tmp
, XCHAR_TABLE (tmp
));
1377 XCHAR_TABLE (tmp
)->top
= Qt
;
1386 tmp
= read_vector (readcharfun
);
1387 if (XVECTOR (tmp
)->size
!= SUB_CHAR_TABLE_STANDARD_SLOTS
)
1388 error ("Invalid size char-table");
1389 XSETCHAR_TABLE (tmp
, XCHAR_TABLE (tmp
));
1390 XCHAR_TABLE (tmp
)->top
= Qnil
;
1393 Fsignal (Qinvalid_read_syntax
,
1394 Fcons (make_string ("#^^", 3), Qnil
));
1396 Fsignal (Qinvalid_read_syntax
, Fcons (make_string ("#^", 2), Qnil
));
1401 length
= read1 (readcharfun
, pch
, first_in_list
);
1405 Lisp_Object tmp
, val
;
1406 int size_in_chars
= ((XFASTINT (length
) + BITS_PER_CHAR
- 1)
1410 tmp
= read1 (readcharfun
, pch
, first_in_list
);
1411 if (size_in_chars
!= XSTRING (tmp
)->size
1412 /* We used to print 1 char too many
1413 when the number of bits was a multiple of 8.
1414 Accept such input in case it came from an old version. */
1415 && ! (XFASTINT (length
)
1416 == (XSTRING (tmp
)->size
- 1) * BITS_PER_CHAR
))
1417 Fsignal (Qinvalid_read_syntax
,
1418 Fcons (make_string ("#&...", 5), Qnil
));
1420 val
= Fmake_bool_vector (length
, Qnil
);
1421 bcopy (XSTRING (tmp
)->data
, XBOOL_VECTOR (val
)->data
,
1425 Fsignal (Qinvalid_read_syntax
, Fcons (make_string ("#&...", 5),
1430 /* Accept compiled functions at read-time so that we don't have to
1431 build them using function calls. */
1433 tmp
= read_vector (readcharfun
);
1434 return Fmake_byte_code (XVECTOR (tmp
)->size
,
1435 XVECTOR (tmp
)->contents
);
1437 #ifdef USE_TEXT_PROPERTIES
1441 struct gcpro gcpro1
;
1444 /* Read the string itself. */
1445 tmp
= read1 (readcharfun
, &ch
, 0);
1446 if (ch
!= 0 || !STRINGP (tmp
))
1447 Fsignal (Qinvalid_read_syntax
, Fcons (make_string ("#", 1), Qnil
));
1449 /* Read the intervals and their properties. */
1452 Lisp_Object beg
, end
, plist
;
1454 beg
= read1 (readcharfun
, &ch
, 0);
1458 end
= read1 (readcharfun
, &ch
, 0);
1460 plist
= read1 (readcharfun
, &ch
, 0);
1462 Fsignal (Qinvalid_read_syntax
,
1463 Fcons (build_string ("invalid string property list"),
1465 Fset_text_properties (beg
, end
, plist
, tmp
);
1471 /* #@NUMBER is used to skip NUMBER following characters.
1472 That's used in .elc files to skip over doc strings
1473 and function definitions. */
1478 /* Read a decimal integer. */
1479 while ((c
= READCHAR
) >= 0
1480 && c
>= '0' && c
<= '9')
1488 #ifndef DOS_NT /* I don't know if filepos works right on MSDOS and Windoze. */
1489 if (load_force_doc_strings
&& EQ (readcharfun
, Qget_file_char
))
1491 /* If we are supposed to force doc strings into core right now,
1492 record the last string that we skipped,
1493 and record where in the file it comes from. */
1494 if (saved_doc_string_size
== 0)
1496 saved_doc_string_size
= nskip
+ 100;
1497 saved_doc_string
= (char *) xmalloc (saved_doc_string_size
);
1499 if (nskip
> saved_doc_string_size
)
1501 saved_doc_string_size
= nskip
+ 100;
1502 saved_doc_string
= (char *) xrealloc (saved_doc_string
,
1503 saved_doc_string_size
);
1506 saved_doc_string_position
= ftell (instream
);
1508 /* Copy that many characters into saved_doc_string. */
1509 for (i
= 0; i
< nskip
&& c
>= 0; i
++)
1510 saved_doc_string
[i
] = c
= READCHAR
;
1512 saved_doc_string_length
= i
;
1515 #endif /* not DOS_NT */
1517 /* Skip that many characters. */
1518 for (i
= 0; i
< nskip
&& c
>= 0; i
++)
1525 return Vload_file_name
;
1527 return Fcons (Qfunction
, Fcons (read0 (readcharfun
), Qnil
));
1528 /* #:foo is the uninterned symbol named foo. */
1531 uninterned_symbol
= 1;
1535 /* Reader forms that can reuse previously read objects. */
1536 if (c
>= '0' && c
<= '9')
1541 /* Read a non-negative integer. */
1542 while (c
>= '0' && c
<= '9')
1548 /* #n=object returns object, but associates it with n for #n#. */
1551 tem
= read0 (readcharfun
);
1552 read_objects
= Fcons (Fcons (make_number (n
), tem
), read_objects
);
1555 /* #n# returns a previously read object. */
1558 tem
= Fassq (make_number (n
), read_objects
);
1561 /* Fall through to error message. */
1563 /* Fall through to error message. */
1567 Fsignal (Qinvalid_read_syntax
, Fcons (make_string ("#", 1), Qnil
));
1570 while ((c
= READCHAR
) >= 0 && c
!= '\n');
1575 return Fcons (Qquote
, Fcons (read0 (readcharfun
), Qnil
));
1585 new_backquote_flag
= 1;
1586 value
= read0 (readcharfun
);
1587 new_backquote_flag
= 0;
1589 return Fcons (Qbackquote
, Fcons (value
, Qnil
));
1593 if (new_backquote_flag
)
1595 Lisp_Object comma_type
= Qnil
;
1600 comma_type
= Qcomma_at
;
1602 comma_type
= Qcomma_dot
;
1605 if (ch
>= 0) UNREAD (ch
);
1606 comma_type
= Qcomma
;
1609 new_backquote_flag
= 0;
1610 value
= read0 (readcharfun
);
1611 new_backquote_flag
= 1;
1612 return Fcons (comma_type
, Fcons (value
, Qnil
));
1619 register Lisp_Object val
;
1622 if (c
< 0) return Fsignal (Qend_of_file
, Qnil
);
1625 c
= read_escape (readcharfun
);
1626 else if (BASE_LEADING_CODE_P (c
))
1627 c
= read_multibyte (c
, readcharfun
);
1635 register char *p
= read_buffer
;
1636 register char *end
= read_buffer
+ read_buffer_size
;
1640 while ((c
= READCHAR
) >= 0
1645 char *new = (char *) xrealloc (read_buffer
, read_buffer_size
*= 2);
1646 p
+= new - read_buffer
;
1647 read_buffer
+= new - read_buffer
;
1648 end
= read_buffer
+ read_buffer_size
;
1652 c
= read_escape (readcharfun
);
1653 if (! SINGLE_BYTE_CHAR_P ((c
& ~CHAR_META
)))
1656 char *str
= workbuf
;
1659 length
= non_ascii_char_to_string (c
, workbuf
, &str
);
1661 if (p
+ length
> end
)
1663 char *new = (char *) xrealloc (read_buffer
, read_buffer_size
*= 2);
1664 p
+= new - read_buffer
;
1665 read_buffer
+= new - read_buffer
;
1666 end
= read_buffer
+ read_buffer_size
;
1669 bcopy (str
, p
, length
);
1674 /* c is -1 if \ newline has just been seen */
1677 if (p
== read_buffer
)
1682 /* Allow `\C- ' and `\C-?'. */
1683 if (c
== (CHAR_CTL
| ' '))
1685 else if (c
== (CHAR_CTL
| '?'))
1689 /* Move the meta bit to the right place for a string. */
1690 c
= (c
& ~CHAR_META
) | 0x80;
1692 error ("Invalid modifier in string");
1696 if (c
< 0) return Fsignal (Qend_of_file
, Qnil
);
1698 /* If purifying, and string starts with \ newline,
1699 return zero instead. This is for doc strings
1700 that we are really going to find in etc/DOC.nn.nn */
1701 if (!NILP (Vpurify_flag
) && NILP (Vdoc_file_name
) && cancel
)
1702 return make_number (0);
1705 return make_pure_string (read_buffer
, p
- read_buffer
);
1707 return make_string (read_buffer
, p
- read_buffer
);
1712 #ifdef LISP_FLOAT_TYPE
1713 /* If a period is followed by a number, then we should read it
1714 as a floating point number. Otherwise, it denotes a dotted
1716 int next_char
= READCHAR
;
1719 if (! (next_char
>= '0' && next_char
<= '9'))
1726 /* Otherwise, we fall through! Note that the atom-reading loop
1727 below will now loop at least once, assuring that we will not
1728 try to UNREAD two characters in a row. */
1732 if (c
<= 040) goto retry
;
1734 register char *p
= read_buffer
;
1738 register char *end
= read_buffer
+ read_buffer_size
;
1741 !(c
== '\"' || c
== '\'' || c
== ';' || c
== '?'
1742 || c
== '(' || c
== ')'
1743 #ifndef LISP_FLOAT_TYPE
1744 /* If we have floating-point support, then we need
1745 to allow <digits><dot><digits>. */
1747 #endif /* not LISP_FLOAT_TYPE */
1748 || c
== '[' || c
== ']' || c
== '#'
1753 register char *new = (char *) xrealloc (read_buffer
, read_buffer_size
*= 2);
1754 p
+= new - read_buffer
;
1755 read_buffer
+= new - read_buffer
;
1756 end
= read_buffer
+ read_buffer_size
;
1769 char *new = (char *) xrealloc (read_buffer
, read_buffer_size
*= 2);
1770 p
+= new - read_buffer
;
1771 read_buffer
+= new - read_buffer
;
1772 /* end = read_buffer + read_buffer_size; */
1779 if (!quoted
&& !uninterned_symbol
)
1782 register Lisp_Object val
;
1784 if (*p1
== '+' || *p1
== '-') p1
++;
1785 /* Is it an integer? */
1788 while (p1
!= p
&& (c
= *p1
) >= '0' && c
<= '9') p1
++;
1789 #ifdef LISP_FLOAT_TYPE
1790 /* Integers can have trailing decimal points. */
1791 if (p1
> read_buffer
&& p1
< p
&& *p1
== '.') p1
++;
1794 /* It is an integer. */
1796 #ifdef LISP_FLOAT_TYPE
1800 if (sizeof (int) == sizeof (EMACS_INT
))
1801 XSETINT (val
, atoi (read_buffer
));
1802 else if (sizeof (long) == sizeof (EMACS_INT
))
1803 XSETINT (val
, atol (read_buffer
));
1809 #ifdef LISP_FLOAT_TYPE
1810 if (isfloat_string (read_buffer
))
1811 return make_float (atof (read_buffer
));
1815 if (uninterned_symbol
)
1816 return make_symbol (read_buffer
);
1818 return intern (read_buffer
);
1823 #ifdef LISP_FLOAT_TYPE
1838 if (*cp
== '+' || *cp
== '-')
1841 if (*cp
>= '0' && *cp
<= '9')
1844 while (*cp
>= '0' && *cp
<= '9')
1852 if (*cp
>= '0' && *cp
<= '9')
1855 while (*cp
>= '0' && *cp
<= '9')
1858 if (*cp
== 'e' || *cp
== 'E')
1862 if (*cp
== '+' || *cp
== '-')
1866 if (*cp
>= '0' && *cp
<= '9')
1869 while (*cp
>= '0' && *cp
<= '9')
1872 return (((*cp
== 0) || (*cp
== ' ') || (*cp
== '\t') || (*cp
== '\n') || (*cp
== '\r') || (*cp
== '\f'))
1873 && (state
== (LEAD_INT
|DOT_CHAR
|TRAIL_INT
)
1874 || state
== (DOT_CHAR
|TRAIL_INT
)
1875 || state
== (LEAD_INT
|E_CHAR
|EXP_INT
)
1876 || state
== (LEAD_INT
|DOT_CHAR
|TRAIL_INT
|E_CHAR
|EXP_INT
)
1877 || state
== (DOT_CHAR
|TRAIL_INT
|E_CHAR
|EXP_INT
)));
1879 #endif /* LISP_FLOAT_TYPE */
1882 read_vector (readcharfun
)
1883 Lisp_Object readcharfun
;
1887 register Lisp_Object
*ptr
;
1888 register Lisp_Object tem
, vector
;
1889 register struct Lisp_Cons
*otem
;
1892 tem
= read_list (1, readcharfun
);
1893 len
= Flength (tem
);
1894 vector
= (read_pure
? make_pure_vector (XINT (len
)) : Fmake_vector (len
, Qnil
));
1897 size
= XVECTOR (vector
)->size
;
1898 ptr
= XVECTOR (vector
)->contents
;
1899 for (i
= 0; i
< size
; i
++)
1901 ptr
[i
] = read_pure
? Fpurecopy (Fcar (tem
)) : Fcar (tem
);
1909 /* flag = 1 means check for ] to terminate rather than ) and .
1910 flag = -1 means check for starting with defun
1911 and make structure pure. */
1914 read_list (flag
, readcharfun
)
1916 register Lisp_Object readcharfun
;
1918 /* -1 means check next element for defun,
1919 0 means don't check,
1920 1 means already checked and found defun. */
1921 int defunflag
= flag
< 0 ? -1 : 0;
1922 Lisp_Object val
, tail
;
1923 register Lisp_Object elt
, tem
;
1924 struct gcpro gcpro1
, gcpro2
;
1925 /* 0 is the normal case.
1926 1 means this list is a doc reference; replace it with the number 0.
1927 2 means this list is a doc reference; replace it with the doc string. */
1928 int doc_reference
= 0;
1930 /* Initialize this to 1 if we are reading a list. */
1931 int first_in_list
= flag
<= 0;
1940 elt
= read1 (readcharfun
, &ch
, first_in_list
);
1945 /* While building, if the list starts with #$, treat it specially. */
1946 if (EQ (elt
, Vload_file_name
)
1948 && !NILP (Vpurify_flag
))
1950 if (NILP (Vdoc_file_name
))
1951 /* We have not yet called Snarf-documentation, so assume
1952 this file is described in the DOC-MM.NN file
1953 and Snarf-documentation will fill in the right value later.
1954 For now, replace the whole list with 0. */
1957 /* We have already called Snarf-documentation, so make a relative
1958 file name for this file, so it can be found properly
1959 in the installed Lisp directory.
1960 We don't use Fexpand_file_name because that would make
1961 the directory absolute now. */
1962 elt
= concat2 (build_string ("../lisp/"),
1963 Ffile_name_nondirectory (elt
));
1965 else if (EQ (elt
, Vload_file_name
)
1967 && load_force_doc_strings
)
1976 Fsignal (Qinvalid_read_syntax
,
1977 Fcons (make_string (") or . in a vector", 18), Qnil
));
1985 XCONS (tail
)->cdr
= read0 (readcharfun
);
1987 val
= read0 (readcharfun
);
1988 read1 (readcharfun
, &ch
, 0);
1992 if (doc_reference
== 1)
1993 return make_number (0);
1994 if (doc_reference
== 2)
1996 /* Get a doc string from the file we are loading.
1997 If it's in saved_doc_string, get it from there. */
1998 int pos
= XINT (XCONS (val
)->cdr
);
1999 if (pos
>= saved_doc_string_position
2000 && pos
< (saved_doc_string_position
2001 + saved_doc_string_length
))
2003 int start
= pos
- saved_doc_string_position
;
2006 /* Process quoting with ^A,
2007 and find the end of the string,
2008 which is marked with ^_ (037). */
2009 for (from
= start
, to
= start
;
2010 saved_doc_string
[from
] != 037;)
2012 int c
= saved_doc_string
[from
++];
2015 c
= saved_doc_string
[from
++];
2017 saved_doc_string
[to
++] = c
;
2019 saved_doc_string
[to
++] = 0;
2021 saved_doc_string
[to
++] = 037;
2024 saved_doc_string
[to
++] = c
;
2027 return make_string (saved_doc_string
+ start
,
2031 return read_doc_string (val
);
2036 return Fsignal (Qinvalid_read_syntax
, Fcons (make_string (". in wrong context", 18), Qnil
));
2038 return Fsignal (Qinvalid_read_syntax
, Fcons (make_string ("] in a list", 11), Qnil
));
2040 tem
= (read_pure
&& flag
<= 0
2041 ? pure_cons (elt
, Qnil
)
2042 : Fcons (elt
, Qnil
));
2044 XCONS (tail
)->cdr
= tem
;
2049 defunflag
= EQ (elt
, Qdefun
);
2050 else if (defunflag
> 0)
2055 Lisp_Object Vobarray
;
2056 Lisp_Object initial_obarray
;
2058 /* oblookup stores the bucket number here, for the sake of Funintern. */
2060 int oblookup_last_bucket_number
;
2062 static int hash_string ();
2063 Lisp_Object
oblookup ();
2065 /* Get an error if OBARRAY is not an obarray.
2066 If it is one, return it. */
2069 check_obarray (obarray
)
2070 Lisp_Object obarray
;
2072 while (!VECTORP (obarray
) || XVECTOR (obarray
)->size
== 0)
2074 /* If Vobarray is now invalid, force it to be valid. */
2075 if (EQ (Vobarray
, obarray
)) Vobarray
= initial_obarray
;
2077 obarray
= wrong_type_argument (Qvectorp
, obarray
);
2082 /* Intern the C string STR: return a symbol with that name,
2083 interned in the current obarray. */
2090 int len
= strlen (str
);
2091 Lisp_Object obarray
;
2094 if (!VECTORP (obarray
) || XVECTOR (obarray
)->size
== 0)
2095 obarray
= check_obarray (obarray
);
2096 tem
= oblookup (obarray
, str
, len
);
2099 return Fintern (make_string (str
, len
), obarray
);
2102 /* Create an uninterned symbol with name STR. */
2108 int len
= strlen (str
);
2110 return Fmake_symbol ((!NILP (Vpurify_flag
)
2111 ? make_pure_string (str
, len
)
2112 : make_string (str
, len
)));
2115 DEFUN ("intern", Fintern
, Sintern
, 1, 2, 0,
2116 "Return the canonical symbol whose name is STRING.\n\
2117 If there is none, one is created by this function and returned.\n\
2118 A second optional argument specifies the obarray to use;\n\
2119 it defaults to the value of `obarray'.")
2121 Lisp_Object string
, obarray
;
2123 register Lisp_Object tem
, sym
, *ptr
;
2125 if (NILP (obarray
)) obarray
= Vobarray
;
2126 obarray
= check_obarray (obarray
);
2128 CHECK_STRING (string
, 0);
2130 tem
= oblookup (obarray
, XSTRING (string
)->data
, XSTRING (string
)->size
);
2131 if (!INTEGERP (tem
))
2134 if (!NILP (Vpurify_flag
))
2135 string
= Fpurecopy (string
);
2136 sym
= Fmake_symbol (string
);
2137 XSYMBOL (sym
)->obarray
= obarray
;
2139 if (XSTRING (string
)->data
[0] == ':')
2140 XSYMBOL (sym
)->value
= sym
;
2142 ptr
= &XVECTOR (obarray
)->contents
[XINT (tem
)];
2144 XSYMBOL (sym
)->next
= XSYMBOL (*ptr
);
2146 XSYMBOL (sym
)->next
= 0;
2151 DEFUN ("intern-soft", Fintern_soft
, Sintern_soft
, 1, 2, 0,
2152 "Return the canonical symbol whose name is STRING, or nil if none exists.\n\
2153 A second optional argument specifies the obarray to use;\n\
2154 it defaults to the value of `obarray'.")
2156 Lisp_Object string
, obarray
;
2158 register Lisp_Object tem
;
2160 if (NILP (obarray
)) obarray
= Vobarray
;
2161 obarray
= check_obarray (obarray
);
2163 CHECK_STRING (string
, 0);
2165 tem
= oblookup (obarray
, XSTRING (string
)->data
, XSTRING (string
)->size
);
2166 if (!INTEGERP (tem
))
2171 DEFUN ("unintern", Funintern
, Sunintern
, 1, 2, 0,
2172 "Delete the symbol named NAME, if any, from OBARRAY.\n\
2173 The value is t if a symbol was found and deleted, nil otherwise.\n\
2174 NAME may be a string or a symbol. If it is a symbol, that symbol\n\
2175 is deleted, if it belongs to OBARRAY--no other symbol is deleted.\n\
2176 OBARRAY defaults to the value of the variable `obarray'.")
2178 Lisp_Object name
, obarray
;
2180 register Lisp_Object string
, tem
;
2183 if (NILP (obarray
)) obarray
= Vobarray
;
2184 obarray
= check_obarray (obarray
);
2187 XSETSTRING (string
, XSYMBOL (name
)->name
);
2190 CHECK_STRING (name
, 0);
2194 tem
= oblookup (obarray
, XSTRING (string
)->data
, XSTRING (string
)->size
);
2197 /* If arg was a symbol, don't delete anything but that symbol itself. */
2198 if (SYMBOLP (name
) && !EQ (name
, tem
))
2201 hash
= oblookup_last_bucket_number
;
2203 if (EQ (XVECTOR (obarray
)->contents
[hash
], tem
))
2205 if (XSYMBOL (tem
)->next
)
2206 XSETSYMBOL (XVECTOR (obarray
)->contents
[hash
], XSYMBOL (tem
)->next
);
2208 XSETINT (XVECTOR (obarray
)->contents
[hash
], 0);
2212 Lisp_Object tail
, following
;
2214 for (tail
= XVECTOR (obarray
)->contents
[hash
];
2215 XSYMBOL (tail
)->next
;
2218 XSETSYMBOL (following
, XSYMBOL (tail
)->next
);
2219 if (EQ (following
, tem
))
2221 XSYMBOL (tail
)->next
= XSYMBOL (following
)->next
;
2230 /* Return the symbol in OBARRAY whose names matches the string
2231 of SIZE characters at PTR. If there is no such symbol in OBARRAY,
2234 Also store the bucket number in oblookup_last_bucket_number. */
2237 oblookup (obarray
, ptr
, size
)
2238 Lisp_Object obarray
;
2244 register Lisp_Object tail
;
2245 Lisp_Object bucket
, tem
;
2247 if (!VECTORP (obarray
)
2248 || (obsize
= XVECTOR (obarray
)->size
) == 0)
2250 obarray
= check_obarray (obarray
);
2251 obsize
= XVECTOR (obarray
)->size
;
2253 /* This is sometimes needed in the middle of GC. */
2254 obsize
&= ~ARRAY_MARK_FLAG
;
2255 /* Combining next two lines breaks VMS C 2.3. */
2256 hash
= hash_string (ptr
, size
);
2258 bucket
= XVECTOR (obarray
)->contents
[hash
];
2259 oblookup_last_bucket_number
= hash
;
2260 if (XFASTINT (bucket
) == 0)
2262 else if (!SYMBOLP (bucket
))
2263 error ("Bad data in guts of obarray"); /* Like CADR error message */
2265 for (tail
= bucket
; ; XSETSYMBOL (tail
, XSYMBOL (tail
)->next
))
2267 if (XSYMBOL (tail
)->name
->size
== size
2268 && !bcmp (XSYMBOL (tail
)->name
->data
, ptr
, size
))
2270 else if (XSYMBOL (tail
)->next
== 0)
2273 XSETINT (tem
, hash
);
2278 hash_string (ptr
, len
)
2282 register unsigned char *p
= ptr
;
2283 register unsigned char *end
= p
+ len
;
2284 register unsigned char c
;
2285 register int hash
= 0;
2290 if (c
>= 0140) c
-= 40;
2291 hash
= ((hash
<<3) + (hash
>>28) + c
);
2293 return hash
& 07777777777;
2297 map_obarray (obarray
, fn
, arg
)
2298 Lisp_Object obarray
;
2303 register Lisp_Object tail
;
2304 CHECK_VECTOR (obarray
, 1);
2305 for (i
= XVECTOR (obarray
)->size
- 1; i
>= 0; i
--)
2307 tail
= XVECTOR (obarray
)->contents
[i
];
2312 if (XSYMBOL (tail
)->next
== 0)
2314 XSETSYMBOL (tail
, XSYMBOL (tail
)->next
);
2319 mapatoms_1 (sym
, function
)
2320 Lisp_Object sym
, function
;
2322 call1 (function
, sym
);
2325 DEFUN ("mapatoms", Fmapatoms
, Smapatoms
, 1, 2, 0,
2326 "Call FUNCTION on every symbol in OBARRAY.\n\
2327 OBARRAY defaults to the value of `obarray'.")
2329 Lisp_Object function
, obarray
;
2333 if (NILP (obarray
)) obarray
= Vobarray
;
2334 obarray
= check_obarray (obarray
);
2336 map_obarray (obarray
, mapatoms_1
, function
);
2340 #define OBARRAY_SIZE 1511
2345 Lisp_Object oblength
;
2349 XSETFASTINT (oblength
, OBARRAY_SIZE
);
2351 Qnil
= Fmake_symbol (make_pure_string ("nil", 3));
2352 Vobarray
= Fmake_vector (oblength
, make_number (0));
2353 initial_obarray
= Vobarray
;
2354 staticpro (&initial_obarray
);
2355 /* Intern nil in the obarray */
2356 XSYMBOL (Qnil
)->obarray
= Vobarray
;
2357 /* These locals are to kludge around a pyramid compiler bug. */
2358 hash
= hash_string ("nil", 3);
2359 /* Separate statement here to avoid VAXC bug. */
2360 hash
%= OBARRAY_SIZE
;
2361 tem
= &XVECTOR (Vobarray
)->contents
[hash
];
2364 Qunbound
= Fmake_symbol (make_pure_string ("unbound", 7));
2365 XSYMBOL (Qnil
)->function
= Qunbound
;
2366 XSYMBOL (Qunbound
)->value
= Qunbound
;
2367 XSYMBOL (Qunbound
)->function
= Qunbound
;
2370 XSYMBOL (Qnil
)->value
= Qnil
;
2371 XSYMBOL (Qnil
)->plist
= Qnil
;
2372 XSYMBOL (Qt
)->value
= Qt
;
2374 /* Qt is correct even if CANNOT_DUMP. loadup.el will set to nil at end. */
2377 Qvariable_documentation
= intern ("variable-documentation");
2378 staticpro (&Qvariable_documentation
);
2380 read_buffer_size
= 100;
2381 read_buffer
= (char *) malloc (read_buffer_size
);
2386 struct Lisp_Subr
*sname
;
2389 sym
= intern (sname
->symbol_name
);
2390 XSETSUBR (XSYMBOL (sym
)->function
, sname
);
2393 #ifdef NOTDEF /* use fset in subr.el now */
2395 defalias (sname
, string
)
2396 struct Lisp_Subr
*sname
;
2400 sym
= intern (string
);
2401 XSETSUBR (XSYMBOL (sym
)->function
, sname
);
2405 /* Define an "integer variable"; a symbol whose value is forwarded
2406 to a C variable of type int. Sample call: */
2407 /* DEFVAR_INT ("indent-tabs-mode", &indent_tabs_mode, "Documentation"); */
2409 defvar_int (namestring
, address
)
2413 Lisp_Object sym
, val
;
2414 sym
= intern (namestring
);
2415 val
= allocate_misc ();
2416 XMISCTYPE (val
) = Lisp_Misc_Intfwd
;
2417 XINTFWD (val
)->intvar
= address
;
2418 XSYMBOL (sym
)->value
= val
;
2421 /* Similar but define a variable whose value is T if address contains 1,
2422 NIL if address contains 0 */
2424 defvar_bool (namestring
, address
)
2428 Lisp_Object sym
, val
;
2429 sym
= intern (namestring
);
2430 val
= allocate_misc ();
2431 XMISCTYPE (val
) = Lisp_Misc_Boolfwd
;
2432 XBOOLFWD (val
)->boolvar
= address
;
2433 XSYMBOL (sym
)->value
= val
;
2436 /* Similar but define a variable whose value is the Lisp Object stored
2437 at address. Two versions: with and without gc-marking of the C
2438 variable. The nopro version is used when that variable will be
2439 gc-marked for some other reason, since marking the same slot twice
2440 can cause trouble with strings. */
2442 defvar_lisp_nopro (namestring
, address
)
2444 Lisp_Object
*address
;
2446 Lisp_Object sym
, val
;
2447 sym
= intern (namestring
);
2448 val
= allocate_misc ();
2449 XMISCTYPE (val
) = Lisp_Misc_Objfwd
;
2450 XOBJFWD (val
)->objvar
= address
;
2451 XSYMBOL (sym
)->value
= val
;
2455 defvar_lisp (namestring
, address
)
2457 Lisp_Object
*address
;
2459 defvar_lisp_nopro (namestring
, address
);
2460 staticpro (address
);
2465 /* Similar but define a variable whose value is the Lisp Object stored in
2466 the current buffer. address is the address of the slot in the buffer
2467 that is current now. */
2470 defvar_per_buffer (namestring
, address
, type
, doc
)
2472 Lisp_Object
*address
;
2476 Lisp_Object sym
, val
;
2478 extern struct buffer buffer_local_symbols
;
2480 sym
= intern (namestring
);
2481 val
= allocate_misc ();
2482 offset
= (char *)address
- (char *)current_buffer
;
2484 XMISCTYPE (val
) = Lisp_Misc_Buffer_Objfwd
;
2485 XBUFFER_OBJFWD (val
)->offset
= offset
;
2486 XSYMBOL (sym
)->value
= val
;
2487 *(Lisp_Object
*)(offset
+ (char *)&buffer_local_symbols
) = sym
;
2488 *(Lisp_Object
*)(offset
+ (char *)&buffer_local_types
) = type
;
2489 if (XINT (*(Lisp_Object
*)(offset
+ (char *)&buffer_local_flags
)) == 0)
2490 /* Did a DEFVAR_PER_BUFFER without initializing the corresponding
2491 slot of buffer_local_flags */
2495 #endif /* standalone */
2497 /* Similar but define a variable whose value is the Lisp Object stored
2498 at a particular offset in the current kboard object. */
2501 defvar_kboard (namestring
, offset
)
2505 Lisp_Object sym
, val
;
2506 sym
= intern (namestring
);
2507 val
= allocate_misc ();
2508 XMISCTYPE (val
) = Lisp_Misc_Kboard_Objfwd
;
2509 XKBOARD_OBJFWD (val
)->offset
= offset
;
2510 XSYMBOL (sym
)->value
= val
;
2513 /* Record the value of load-path used at the start of dumping
2514 so we can see if the site changed it later during dumping. */
2515 static Lisp_Object dump_path
;
2520 int turn_off_warning
= 0;
2522 #ifdef HAVE_SETLOCALE
2523 /* Make sure numbers are parsed as we expect. */
2524 setlocale (LC_NUMERIC
, "C");
2525 #endif /* HAVE_SETLOCALE */
2527 /* Compute the default load-path. */
2529 normal
= PATH_LOADSEARCH
;
2530 Vload_path
= decode_env_path (0, normal
);
2532 if (NILP (Vpurify_flag
))
2533 normal
= PATH_LOADSEARCH
;
2535 normal
= PATH_DUMPLOADSEARCH
;
2537 /* In a dumped Emacs, we normally have to reset the value of
2538 Vload_path from PATH_LOADSEARCH, since the value that was dumped
2539 uses ../lisp, instead of the path of the installed elisp
2540 libraries. However, if it appears that Vload_path was changed
2541 from the default before dumping, don't override that value. */
2544 if (! NILP (Fequal (dump_path
, Vload_path
)))
2546 Vload_path
= decode_env_path (0, normal
);
2547 if (!NILP (Vinstallation_directory
))
2549 /* Add to the path the lisp subdir of the
2550 installation dir, if it exists. */
2551 Lisp_Object tem
, tem1
;
2552 tem
= Fexpand_file_name (build_string ("lisp"),
2553 Vinstallation_directory
);
2554 tem1
= Ffile_exists_p (tem
);
2557 if (NILP (Fmember (tem
, Vload_path
)))
2559 turn_off_warning
= 1;
2560 Vload_path
= nconc2 (Vload_path
, Fcons (tem
, Qnil
));
2564 /* That dir doesn't exist, so add the build-time
2565 Lisp dirs instead. */
2566 Vload_path
= nconc2 (Vload_path
, dump_path
);
2568 /* Add leim under the installation dir, if it exists. */
2569 tem
= Fexpand_file_name (build_string ("leim"),
2570 Vinstallation_directory
);
2571 tem1
= Ffile_exists_p (tem
);
2574 if (NILP (Fmember (tem
, Vload_path
)))
2575 Vload_path
= nconc2 (Vload_path
, Fcons (tem
, Qnil
));
2578 /* Add site-list under the installation dir, if it exists. */
2579 tem
= Fexpand_file_name (build_string ("site-lisp"),
2580 Vinstallation_directory
);
2581 tem1
= Ffile_exists_p (tem
);
2584 if (NILP (Fmember (tem
, Vload_path
)))
2585 Vload_path
= nconc2 (Vload_path
, Fcons (tem
, Qnil
));
2588 /* If Emacs was not built in the source directory,
2589 and it is run from where it was built, add to load-path
2590 the lisp, leim and site-lisp dirs under that directory. */
2592 if (NILP (Fequal (Vinstallation_directory
, Vsource_directory
)))
2596 tem
= Fexpand_file_name (build_string ("src/Makefile"),
2597 Vinstallation_directory
);
2598 tem1
= Ffile_exists_p (tem
);
2600 /* Don't be fooled if they moved the entire source tree
2601 AFTER dumping Emacs. If the build directory is indeed
2602 different from the source dir, src/Makefile.in and
2603 src/Makefile will not be found together. */
2604 tem
= Fexpand_file_name (build_string ("src/Makefile.in"),
2605 Vinstallation_directory
);
2606 tem2
= Ffile_exists_p (tem
);
2607 if (!NILP (tem1
) && NILP (tem2
))
2609 tem
= Fexpand_file_name (build_string ("lisp"),
2612 if (NILP (Fmember (tem
, Vload_path
)))
2613 Vload_path
= nconc2 (Vload_path
, Fcons (tem
, Qnil
));
2615 tem
= Fexpand_file_name (build_string ("leim"),
2618 if (NILP (Fmember (tem
, Vload_path
)))
2619 Vload_path
= nconc2 (Vload_path
, Fcons (tem
, Qnil
));
2621 tem
= Fexpand_file_name (build_string ("site-lisp"),
2624 if (NILP (Fmember (tem
, Vload_path
)))
2625 Vload_path
= nconc2 (Vload_path
, Fcons (tem
, Qnil
));
2633 /* NORMAL refers to the lisp dir in the source directory. */
2634 /* We used to add ../lisp at the front here, but
2635 that caused trouble because it was copied from dump_path
2636 into Vload_path, aboe, when Vinstallation_directory was non-nil.
2637 It should be unnecessary. */
2638 Vload_path
= decode_env_path (0, normal
);
2639 dump_path
= Vload_path
;
2644 /* When Emacs is invoked over network shares on NT, PATH_LOADSEARCH is
2645 almost never correct, thereby causing a warning to be printed out that
2646 confuses users. Since PATH_LOADSEARCH is always overridden by the
2647 EMACSLOADPATH environment variable below, disable the warning on NT. */
2649 /* Warn if dirs in the *standard* path don't exist. */
2650 if (!turn_off_warning
)
2652 Lisp_Object path_tail
;
2654 for (path_tail
= Vload_path
;
2656 path_tail
= XCONS (path_tail
)->cdr
)
2658 Lisp_Object dirfile
;
2659 dirfile
= Fcar (path_tail
);
2660 if (STRINGP (dirfile
))
2662 dirfile
= Fdirectory_file_name (dirfile
);
2663 if (access (XSTRING (dirfile
)->data
, 0) < 0)
2664 dir_warning ("Warning: Lisp directory `%s' does not exist.\n",
2665 XCONS (path_tail
)->car
);
2669 #endif /* WINDOWSNT */
2671 /* If the EMACSLOADPATH environment variable is set, use its value.
2672 This doesn't apply if we're dumping. */
2674 if (NILP (Vpurify_flag
)
2675 && egetenv ("EMACSLOADPATH"))
2677 Vload_path
= decode_env_path ("EMACSLOADPATH", normal
);
2681 load_in_progress
= 0;
2682 Vload_file_name
= Qnil
;
2684 load_descriptor_list
= Qnil
;
2687 /* Print a warning, using format string FORMAT, that directory DIRNAME
2688 does not exist. Print it on stderr and put it in *Message*. */
2690 dir_warning (format
, dirname
)
2692 Lisp_Object dirname
;
2695 = (char *) alloca (XSTRING (dirname
)->size
+ strlen (format
) + 5);
2697 fprintf (stderr
, format
, XSTRING (dirname
)->data
);
2698 sprintf (buffer
, format
, XSTRING (dirname
)->data
);
2699 message_dolog (buffer
, strlen (buffer
), 0);
2706 defsubr (&Sread_from_string
);
2708 defsubr (&Sintern_soft
);
2709 defsubr (&Sunintern
);
2711 defsubr (&Seval_buffer
);
2712 defsubr (&Seval_region
);
2713 defsubr (&Sread_char
);
2714 defsubr (&Sread_char_exclusive
);
2715 defsubr (&Sread_event
);
2716 defsubr (&Sget_file_char
);
2717 defsubr (&Smapatoms
);
2719 DEFVAR_LISP ("obarray", &Vobarray
,
2720 "Symbol table for use by `intern' and `read'.\n\
2721 It is a vector whose length ought to be prime for best results.\n\
2722 The vector's contents don't make sense if examined from Lisp programs;\n\
2723 to find all the symbols in an obarray, use `mapatoms'.");
2725 DEFVAR_LISP ("values", &Vvalues
,
2726 "List of values of all expressions which were read, evaluated and printed.\n\
2727 Order is reverse chronological.");
2729 DEFVAR_LISP ("standard-input", &Vstandard_input
,
2730 "Stream for read to get input from.\n\
2731 See documentation of `read' for possible values.");
2732 Vstandard_input
= Qt
;
2734 DEFVAR_LISP ("load-path", &Vload_path
,
2735 "*List of directories to search for files to load.\n\
2736 Each element is a string (directory name) or nil (try default directory).\n\
2737 Initialized based on EMACSLOADPATH environment variable, if any,\n\
2738 otherwise to default specified by file `paths.h' when Emacs was built.");
2740 DEFVAR_BOOL ("load-in-progress", &load_in_progress
,
2741 "Non-nil iff inside of `load'.");
2743 DEFVAR_LISP ("after-load-alist", &Vafter_load_alist
,
2744 "An alist of expressions to be evalled when particular files are loaded.\n\
2745 Each element looks like (FILENAME FORMS...).\n\
2746 When `load' is run and the file-name argument is FILENAME,\n\
2747 the FORMS in the corresponding element are executed at the end of loading.\n\n\
2748 FILENAME must match exactly! Normally FILENAME is the name of a library,\n\
2749 with no directory specified, since that is how `load' is normally called.\n\
2750 An error in FORMS does not undo the load,\n\
2751 but does prevent execution of the rest of the FORMS.");
2752 Vafter_load_alist
= Qnil
;
2754 DEFVAR_LISP ("load-history", &Vload_history
,
2755 "Alist mapping source file names to symbols and features.\n\
2756 Each alist element is a list that starts with a file name,\n\
2757 except for one element (optional) that starts with nil and describes\n\
2758 definitions evaluated from buffers not visiting files.\n\
2759 The remaining elements of each list are symbols defined as functions\n\
2760 or variables, and cons cells `(provide . FEATURE)' and `(require . FEATURE)'.");
2761 Vload_history
= Qnil
;
2763 DEFVAR_LISP ("load-file-name", &Vload_file_name
,
2764 "Full name of file being loaded by `load'.");
2765 Vload_file_name
= Qnil
;
2767 DEFVAR_LISP ("current-load-list", &Vcurrent_load_list
,
2768 "Used for internal purposes by `load'.");
2769 Vcurrent_load_list
= Qnil
;
2771 DEFVAR_LISP ("load-read-function", &Vload_read_function
,
2772 "Function used by `load' and `eval-region' for reading expressions.\n\
2773 The default is nil, which means use the function `read'.");
2774 Vload_read_function
= Qnil
;
2776 DEFVAR_LISP ("load-source-file-function", &Vload_source_file_function
,
2777 "Function called in `load' for loading an Emacs lisp source file.\n\
2778 This function is for doing code conversion before reading the source file.\n\
2779 If nil, loading is done without any code conversion.\n\
2780 Arguments are FULLNAME, FILE, NOERROR, NOMESSAGE, where\n\
2781 FULLNAME is the full name of FILE.\n\
2782 See `load' for the meaning of the remaining arguments.");
2783 Vload_source_file_function
= Qnil
;
2785 DEFVAR_BOOL ("load-force-doc-strings", &load_force_doc_strings
,
2786 "Non-nil means `load' should force-load all dynamic doc strings.\n\
2787 This is useful when the file being loaded is a temporary copy.");
2788 load_force_doc_strings
= 0;
2790 DEFVAR_LISP ("source-directory", &Vsource_directory
,
2791 "Directory in which Emacs sources were found when Emacs was built.\n\
2792 You cannot count on them to still be there!");
2794 = Fexpand_file_name (build_string ("../"),
2795 Fcar (decode_env_path (0, PATH_DUMPLOADSEARCH
)));
2797 DEFVAR_LISP ("preloaded-file-list", &Vpreloaded_file_list
,
2798 "List of files that were preloaded (when dumping Emacs).");
2799 Vpreloaded_file_list
= Qnil
;
2801 /* Vsource_directory was initialized in init_lread. */
2803 load_descriptor_list
= Qnil
;
2804 staticpro (&load_descriptor_list
);
2806 Qcurrent_load_list
= intern ("current-load-list");
2807 staticpro (&Qcurrent_load_list
);
2809 Qstandard_input
= intern ("standard-input");
2810 staticpro (&Qstandard_input
);
2812 Qread_char
= intern ("read-char");
2813 staticpro (&Qread_char
);
2815 Qget_file_char
= intern ("get-file-char");
2816 staticpro (&Qget_file_char
);
2818 Qbackquote
= intern ("`");
2819 staticpro (&Qbackquote
);
2820 Qcomma
= intern (",");
2821 staticpro (&Qcomma
);
2822 Qcomma_at
= intern (",@");
2823 staticpro (&Qcomma_at
);
2824 Qcomma_dot
= intern (",.");
2825 staticpro (&Qcomma_dot
);
2827 Qinhibit_file_name_operation
= intern ("inhibit-file-name-operation");
2828 staticpro (&Qinhibit_file_name_operation
);
2830 Qascii_character
= intern ("ascii-character");
2831 staticpro (&Qascii_character
);
2833 Qfunction
= intern ("function");
2834 staticpro (&Qfunction
);
2836 Qload
= intern ("load");
2839 Qload_file_name
= intern ("load-file-name");
2840 staticpro (&Qload_file_name
);
2842 staticpro (&dump_path
);
2844 staticpro (&read_objects
);
2845 read_objects
= Qnil
;