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 This function does not move point.")
1023 (start
, end
, printflag
)
1024 Lisp_Object start
, end
, printflag
;
1026 int count
= specpdl_ptr
- specpdl
;
1027 Lisp_Object tem
, cbuf
;
1029 cbuf
= Fcurrent_buffer ();
1031 if (NILP (printflag
))
1035 specbind (Qstandard_output
, tem
);
1037 if (NILP (printflag
))
1038 record_unwind_protect (save_excursion_restore
, save_excursion_save ());
1039 record_unwind_protect (save_restriction_restore
, save_restriction_save ());
1041 /* This both uses start and checks its type. */
1043 Fnarrow_to_region (make_number (BEGV
), end
);
1044 readevalloop (cbuf
, 0, XBUFFER (cbuf
)->filename
, Feval
, !NILP (printflag
));
1046 return unbind_to (count
, Qnil
);
1049 #endif /* standalone */
1051 DEFUN ("read", Fread
, Sread
, 0, 1, 0,
1052 "Read one Lisp expression as text from STREAM, return as Lisp object.\n\
1053 If STREAM is nil, use the value of `standard-input' (which see).\n\
1054 STREAM or the value of `standard-input' may be:\n\
1055 a buffer (read from point and advance it)\n\
1056 a marker (read from where it points and advance it)\n\
1057 a function (call it with no arguments for each character,\n\
1058 call it with a char as argument to push a char back)\n\
1059 a string (takes text from string, starting at the beginning)\n\
1060 t (read text line using minibuffer and use it).")
1064 extern Lisp_Object
Fread_minibuffer ();
1067 stream
= Vstandard_input
;
1068 if (EQ (stream
, Qt
))
1069 stream
= Qread_char
;
1071 new_backquote_flag
= 0;
1072 read_objects
= Qnil
;
1075 if (EQ (stream
, Qread_char
))
1076 return Fread_minibuffer (build_string ("Lisp expression: "), Qnil
);
1079 if (STRINGP (stream
))
1080 return Fcar (Fread_from_string (stream
, Qnil
, Qnil
));
1082 return read0 (stream
);
1085 DEFUN ("read-from-string", Fread_from_string
, Sread_from_string
, 1, 3, 0,
1086 "Read one Lisp expression which is represented as text by STRING.\n\
1087 Returns a cons: (OBJECT-READ . FINAL-STRING-INDEX).\n\
1088 START and END optionally delimit a substring of STRING from which to read;\n\
1089 they default to 0 and (length STRING) respectively.")
1090 (string
, start
, end
)
1091 Lisp_Object string
, start
, end
;
1093 int startval
, endval
;
1096 CHECK_STRING (string
,0);
1099 endval
= XSTRING (string
)->size
;
1101 { CHECK_NUMBER (end
,2);
1102 endval
= XINT (end
);
1103 if (endval
< 0 || endval
> XSTRING (string
)->size
)
1104 args_out_of_range (string
, end
);
1110 { CHECK_NUMBER (start
,1);
1111 startval
= XINT (start
);
1112 if (startval
< 0 || startval
> endval
)
1113 args_out_of_range (string
, start
);
1116 read_from_string_index
= startval
;
1117 read_from_string_limit
= endval
;
1119 new_backquote_flag
= 0;
1120 read_objects
= Qnil
;
1122 tem
= read0 (string
);
1123 return Fcons (tem
, make_number (read_from_string_index
));
1126 /* Use this for recursive reads, in contexts where internal tokens
1130 Lisp_Object readcharfun
;
1132 register Lisp_Object val
;
1135 val
= read1 (readcharfun
, &c
, 0);
1137 Fsignal (Qinvalid_read_syntax
, Fcons (make_string (&c
, 1), Qnil
));
1142 static int read_buffer_size
;
1143 static char *read_buffer
;
1145 /* Read multibyte form and return it as a character. C is a first
1146 byte of multibyte form, and rest of them are read from
1149 read_multibyte (c
, readcharfun
)
1151 Lisp_Object readcharfun
;
1153 /* We need the actual character code of this multibyte
1155 unsigned char str
[MAX_LENGTH_OF_MULTI_BYTE_FORM
];
1159 while ((c
= READCHAR
) >= 0xA0
1160 && len
< MAX_LENGTH_OF_MULTI_BYTE_FORM
)
1163 return STRING_CHAR (str
, len
);
1167 read_escape (readcharfun
)
1168 Lisp_Object readcharfun
;
1170 register int c
= READCHAR
;
1174 error ("End of file");
1200 error ("Invalid escape character syntax");
1203 c
= read_escape (readcharfun
);
1204 return c
| meta_modifier
;
1209 error ("Invalid escape character syntax");
1212 c
= read_escape (readcharfun
);
1213 return c
| shift_modifier
;
1218 error ("Invalid escape character syntax");
1221 c
= read_escape (readcharfun
);
1222 return c
| hyper_modifier
;
1227 error ("Invalid escape character syntax");
1230 c
= read_escape (readcharfun
);
1231 return c
| alt_modifier
;
1236 error ("Invalid escape character syntax");
1239 c
= read_escape (readcharfun
);
1240 return c
| super_modifier
;
1245 error ("Invalid escape character syntax");
1249 c
= read_escape (readcharfun
);
1250 if ((c
& 0177) == '?')
1252 /* ASCII control chars are made from letters (both cases),
1253 as well as the non-letters within 0100...0137. */
1254 else if ((c
& 0137) >= 0101 && (c
& 0137) <= 0132)
1255 return (c
& (037 | ~0177));
1256 else if ((c
& 0177) >= 0100 && (c
& 0177) <= 0137)
1257 return (c
& (037 | ~0177));
1259 return c
| ctrl_modifier
;
1269 /* An octal escape, as in ANSI C. */
1271 register int i
= c
- '0';
1272 register int count
= 0;
1275 if ((c
= READCHAR
) >= '0' && c
<= '7')
1290 /* A hex escape, as in ANSI C. */
1296 if (c
>= '0' && c
<= '9')
1301 else if ((c
>= 'a' && c
<= 'f')
1302 || (c
>= 'A' && c
<= 'F'))
1305 if (c
>= 'a' && c
<= 'f')
1320 if (BASE_LEADING_CODE_P (c
))
1321 c
= read_multibyte (c
, readcharfun
);
1326 /* If the next token is ')' or ']' or '.', we store that character
1327 in *PCH and the return value is not interesting. Else, we store
1328 zero in *PCH and we read and return one lisp object.
1330 FIRST_IN_LIST is nonzero if this is the first element of a list. */
1333 read1 (readcharfun
, pch
, first_in_list
)
1334 register Lisp_Object readcharfun
;
1339 int uninterned_symbol
= 0;
1346 if (c
< 0) return Fsignal (Qend_of_file
, Qnil
);
1351 return read_list (0, readcharfun
);
1354 return read_vector (readcharfun
);
1371 tmp
= read_vector (readcharfun
);
1372 if (XVECTOR (tmp
)->size
< CHAR_TABLE_STANDARD_SLOTS
1373 || XVECTOR (tmp
)->size
> CHAR_TABLE_STANDARD_SLOTS
+ 10)
1374 error ("Invalid size char-table");
1375 XSETCHAR_TABLE (tmp
, XCHAR_TABLE (tmp
));
1376 XCHAR_TABLE (tmp
)->top
= Qt
;
1385 tmp
= read_vector (readcharfun
);
1386 if (XVECTOR (tmp
)->size
!= SUB_CHAR_TABLE_STANDARD_SLOTS
)
1387 error ("Invalid size char-table");
1388 XSETCHAR_TABLE (tmp
, XCHAR_TABLE (tmp
));
1389 XCHAR_TABLE (tmp
)->top
= Qnil
;
1392 Fsignal (Qinvalid_read_syntax
,
1393 Fcons (make_string ("#^^", 3), Qnil
));
1395 Fsignal (Qinvalid_read_syntax
, Fcons (make_string ("#^", 2), Qnil
));
1400 length
= read1 (readcharfun
, pch
, first_in_list
);
1404 Lisp_Object tmp
, val
;
1405 int size_in_chars
= ((XFASTINT (length
) + BITS_PER_CHAR
- 1)
1409 tmp
= read1 (readcharfun
, pch
, first_in_list
);
1410 if (size_in_chars
!= XSTRING (tmp
)->size
1411 /* We used to print 1 char too many
1412 when the number of bits was a multiple of 8.
1413 Accept such input in case it came from an old version. */
1414 && ! (XFASTINT (length
)
1415 == (XSTRING (tmp
)->size
- 1) * BITS_PER_CHAR
))
1416 Fsignal (Qinvalid_read_syntax
,
1417 Fcons (make_string ("#&...", 5), Qnil
));
1419 val
= Fmake_bool_vector (length
, Qnil
);
1420 bcopy (XSTRING (tmp
)->data
, XBOOL_VECTOR (val
)->data
,
1424 Fsignal (Qinvalid_read_syntax
, Fcons (make_string ("#&...", 5),
1429 /* Accept compiled functions at read-time so that we don't have to
1430 build them using function calls. */
1432 tmp
= read_vector (readcharfun
);
1433 return Fmake_byte_code (XVECTOR (tmp
)->size
,
1434 XVECTOR (tmp
)->contents
);
1436 #ifdef USE_TEXT_PROPERTIES
1440 struct gcpro gcpro1
;
1443 /* Read the string itself. */
1444 tmp
= read1 (readcharfun
, &ch
, 0);
1445 if (ch
!= 0 || !STRINGP (tmp
))
1446 Fsignal (Qinvalid_read_syntax
, Fcons (make_string ("#", 1), Qnil
));
1448 /* Read the intervals and their properties. */
1451 Lisp_Object beg
, end
, plist
;
1453 beg
= read1 (readcharfun
, &ch
, 0);
1457 end
= read1 (readcharfun
, &ch
, 0);
1459 plist
= read1 (readcharfun
, &ch
, 0);
1461 Fsignal (Qinvalid_read_syntax
,
1462 Fcons (build_string ("invalid string property list"),
1464 Fset_text_properties (beg
, end
, plist
, tmp
);
1470 /* #@NUMBER is used to skip NUMBER following characters.
1471 That's used in .elc files to skip over doc strings
1472 and function definitions. */
1477 /* Read a decimal integer. */
1478 while ((c
= READCHAR
) >= 0
1479 && c
>= '0' && c
<= '9')
1487 #ifndef DOS_NT /* I don't know if filepos works right on MSDOS and Windoze. */
1488 if (load_force_doc_strings
&& EQ (readcharfun
, Qget_file_char
))
1490 /* If we are supposed to force doc strings into core right now,
1491 record the last string that we skipped,
1492 and record where in the file it comes from. */
1493 if (saved_doc_string_size
== 0)
1495 saved_doc_string_size
= nskip
+ 100;
1496 saved_doc_string
= (char *) xmalloc (saved_doc_string_size
);
1498 if (nskip
> saved_doc_string_size
)
1500 saved_doc_string_size
= nskip
+ 100;
1501 saved_doc_string
= (char *) xrealloc (saved_doc_string
,
1502 saved_doc_string_size
);
1505 saved_doc_string_position
= ftell (instream
);
1507 /* Copy that many characters into saved_doc_string. */
1508 for (i
= 0; i
< nskip
&& c
>= 0; i
++)
1509 saved_doc_string
[i
] = c
= READCHAR
;
1511 saved_doc_string_length
= i
;
1514 #endif /* not DOS_NT */
1516 /* Skip that many characters. */
1517 for (i
= 0; i
< nskip
&& c
>= 0; i
++)
1524 return Vload_file_name
;
1526 return Fcons (Qfunction
, Fcons (read0 (readcharfun
), Qnil
));
1527 /* #:foo is the uninterned symbol named foo. */
1530 uninterned_symbol
= 1;
1534 /* Reader forms that can reuse previously read objects. */
1535 if (c
>= '0' && c
<= '9')
1540 /* Read a non-negative integer. */
1541 while (c
>= '0' && c
<= '9')
1547 /* #n=object returns object, but associates it with n for #n#. */
1550 tem
= read0 (readcharfun
);
1551 read_objects
= Fcons (Fcons (make_number (n
), tem
), read_objects
);
1554 /* #n# returns a previously read object. */
1557 tem
= Fassq (make_number (n
), read_objects
);
1560 /* Fall through to error message. */
1562 /* Fall through to error message. */
1566 Fsignal (Qinvalid_read_syntax
, Fcons (make_string ("#", 1), Qnil
));
1569 while ((c
= READCHAR
) >= 0 && c
!= '\n');
1574 return Fcons (Qquote
, Fcons (read0 (readcharfun
), Qnil
));
1584 new_backquote_flag
= 1;
1585 value
= read0 (readcharfun
);
1586 new_backquote_flag
= 0;
1588 return Fcons (Qbackquote
, Fcons (value
, Qnil
));
1592 if (new_backquote_flag
)
1594 Lisp_Object comma_type
= Qnil
;
1599 comma_type
= Qcomma_at
;
1601 comma_type
= Qcomma_dot
;
1604 if (ch
>= 0) UNREAD (ch
);
1605 comma_type
= Qcomma
;
1608 new_backquote_flag
= 0;
1609 value
= read0 (readcharfun
);
1610 new_backquote_flag
= 1;
1611 return Fcons (comma_type
, Fcons (value
, Qnil
));
1618 register Lisp_Object val
;
1621 if (c
< 0) return Fsignal (Qend_of_file
, Qnil
);
1624 c
= read_escape (readcharfun
);
1625 else if (BASE_LEADING_CODE_P (c
))
1626 c
= read_multibyte (c
, readcharfun
);
1634 register char *p
= read_buffer
;
1635 register char *end
= read_buffer
+ read_buffer_size
;
1639 while ((c
= READCHAR
) >= 0
1644 char *new = (char *) xrealloc (read_buffer
, read_buffer_size
*= 2);
1645 p
+= new - read_buffer
;
1646 read_buffer
+= new - read_buffer
;
1647 end
= read_buffer
+ read_buffer_size
;
1651 c
= read_escape (readcharfun
);
1652 if (! SINGLE_BYTE_CHAR_P ((c
& ~CHAR_META
)))
1654 unsigned char workbuf
[4];
1655 unsigned char *str
= workbuf
;
1658 length
= non_ascii_char_to_string (c
, workbuf
, &str
);
1660 if (p
+ length
> end
)
1662 char *new = (char *) xrealloc (read_buffer
, read_buffer_size
*= 2);
1663 p
+= new - read_buffer
;
1664 read_buffer
+= new - read_buffer
;
1665 end
= read_buffer
+ read_buffer_size
;
1668 bcopy (str
, p
, length
);
1673 /* c is -1 if \ newline has just been seen */
1676 if (p
== read_buffer
)
1681 /* Allow `\C- ' and `\C-?'. */
1682 if (c
== (CHAR_CTL
| ' '))
1684 else if (c
== (CHAR_CTL
| '?'))
1688 /* Move the meta bit to the right place for a string. */
1689 c
= (c
& ~CHAR_META
) | 0x80;
1691 error ("Invalid modifier in string");
1695 if (c
< 0) return Fsignal (Qend_of_file
, Qnil
);
1697 /* If purifying, and string starts with \ newline,
1698 return zero instead. This is for doc strings
1699 that we are really going to find in etc/DOC.nn.nn */
1700 if (!NILP (Vpurify_flag
) && NILP (Vdoc_file_name
) && cancel
)
1701 return make_number (0);
1704 return make_pure_string (read_buffer
, p
- read_buffer
);
1706 return make_string (read_buffer
, p
- read_buffer
);
1711 #ifdef LISP_FLOAT_TYPE
1712 /* If a period is followed by a number, then we should read it
1713 as a floating point number. Otherwise, it denotes a dotted
1715 int next_char
= READCHAR
;
1718 if (! (next_char
>= '0' && next_char
<= '9'))
1725 /* Otherwise, we fall through! Note that the atom-reading loop
1726 below will now loop at least once, assuring that we will not
1727 try to UNREAD two characters in a row. */
1731 if (c
<= 040) goto retry
;
1733 register char *p
= read_buffer
;
1737 register char *end
= read_buffer
+ read_buffer_size
;
1740 !(c
== '\"' || c
== '\'' || c
== ';' || c
== '?'
1741 || c
== '(' || c
== ')'
1742 #ifndef LISP_FLOAT_TYPE
1743 /* If we have floating-point support, then we need
1744 to allow <digits><dot><digits>. */
1746 #endif /* not LISP_FLOAT_TYPE */
1747 || c
== '[' || c
== ']' || c
== '#'
1752 register char *new = (char *) xrealloc (read_buffer
, read_buffer_size
*= 2);
1753 p
+= new - read_buffer
;
1754 read_buffer
+= new - read_buffer
;
1755 end
= read_buffer
+ read_buffer_size
;
1768 char *new = (char *) xrealloc (read_buffer
, read_buffer_size
*= 2);
1769 p
+= new - read_buffer
;
1770 read_buffer
+= new - read_buffer
;
1771 /* end = read_buffer + read_buffer_size; */
1778 if (!quoted
&& !uninterned_symbol
)
1781 register Lisp_Object val
;
1783 if (*p1
== '+' || *p1
== '-') p1
++;
1784 /* Is it an integer? */
1787 while (p1
!= p
&& (c
= *p1
) >= '0' && c
<= '9') p1
++;
1788 #ifdef LISP_FLOAT_TYPE
1789 /* Integers can have trailing decimal points. */
1790 if (p1
> read_buffer
&& p1
< p
&& *p1
== '.') p1
++;
1793 /* It is an integer. */
1795 #ifdef LISP_FLOAT_TYPE
1799 if (sizeof (int) == sizeof (EMACS_INT
))
1800 XSETINT (val
, atoi (read_buffer
));
1801 else if (sizeof (long) == sizeof (EMACS_INT
))
1802 XSETINT (val
, atol (read_buffer
));
1808 #ifdef LISP_FLOAT_TYPE
1809 if (isfloat_string (read_buffer
))
1810 return make_float (atof (read_buffer
));
1814 if (uninterned_symbol
)
1815 return make_symbol (read_buffer
);
1817 return intern (read_buffer
);
1822 #ifdef LISP_FLOAT_TYPE
1837 if (*cp
== '+' || *cp
== '-')
1840 if (*cp
>= '0' && *cp
<= '9')
1843 while (*cp
>= '0' && *cp
<= '9')
1851 if (*cp
>= '0' && *cp
<= '9')
1854 while (*cp
>= '0' && *cp
<= '9')
1857 if (*cp
== 'e' || *cp
== 'E')
1861 if (*cp
== '+' || *cp
== '-')
1865 if (*cp
>= '0' && *cp
<= '9')
1868 while (*cp
>= '0' && *cp
<= '9')
1871 return (((*cp
== 0) || (*cp
== ' ') || (*cp
== '\t') || (*cp
== '\n') || (*cp
== '\r') || (*cp
== '\f'))
1872 && (state
== (LEAD_INT
|DOT_CHAR
|TRAIL_INT
)
1873 || state
== (DOT_CHAR
|TRAIL_INT
)
1874 || state
== (LEAD_INT
|E_CHAR
|EXP_INT
)
1875 || state
== (LEAD_INT
|DOT_CHAR
|TRAIL_INT
|E_CHAR
|EXP_INT
)
1876 || state
== (DOT_CHAR
|TRAIL_INT
|E_CHAR
|EXP_INT
)));
1878 #endif /* LISP_FLOAT_TYPE */
1881 read_vector (readcharfun
)
1882 Lisp_Object readcharfun
;
1886 register Lisp_Object
*ptr
;
1887 register Lisp_Object tem
, vector
;
1888 register struct Lisp_Cons
*otem
;
1891 tem
= read_list (1, readcharfun
);
1892 len
= Flength (tem
);
1893 vector
= (read_pure
? make_pure_vector (XINT (len
)) : Fmake_vector (len
, Qnil
));
1896 size
= XVECTOR (vector
)->size
;
1897 ptr
= XVECTOR (vector
)->contents
;
1898 for (i
= 0; i
< size
; i
++)
1900 ptr
[i
] = read_pure
? Fpurecopy (Fcar (tem
)) : Fcar (tem
);
1908 /* flag = 1 means check for ] to terminate rather than ) and .
1909 flag = -1 means check for starting with defun
1910 and make structure pure. */
1913 read_list (flag
, readcharfun
)
1915 register Lisp_Object readcharfun
;
1917 /* -1 means check next element for defun,
1918 0 means don't check,
1919 1 means already checked and found defun. */
1920 int defunflag
= flag
< 0 ? -1 : 0;
1921 Lisp_Object val
, tail
;
1922 register Lisp_Object elt
, tem
;
1923 struct gcpro gcpro1
, gcpro2
;
1924 /* 0 is the normal case.
1925 1 means this list is a doc reference; replace it with the number 0.
1926 2 means this list is a doc reference; replace it with the doc string. */
1927 int doc_reference
= 0;
1929 /* Initialize this to 1 if we are reading a list. */
1930 int first_in_list
= flag
<= 0;
1939 elt
= read1 (readcharfun
, &ch
, first_in_list
);
1944 /* While building, if the list starts with #$, treat it specially. */
1945 if (EQ (elt
, Vload_file_name
)
1947 && !NILP (Vpurify_flag
))
1949 if (NILP (Vdoc_file_name
))
1950 /* We have not yet called Snarf-documentation, so assume
1951 this file is described in the DOC-MM.NN file
1952 and Snarf-documentation will fill in the right value later.
1953 For now, replace the whole list with 0. */
1956 /* We have already called Snarf-documentation, so make a relative
1957 file name for this file, so it can be found properly
1958 in the installed Lisp directory.
1959 We don't use Fexpand_file_name because that would make
1960 the directory absolute now. */
1961 elt
= concat2 (build_string ("../lisp/"),
1962 Ffile_name_nondirectory (elt
));
1964 else if (EQ (elt
, Vload_file_name
)
1966 && load_force_doc_strings
)
1975 Fsignal (Qinvalid_read_syntax
,
1976 Fcons (make_string (") or . in a vector", 18), Qnil
));
1984 XCONS (tail
)->cdr
= read0 (readcharfun
);
1986 val
= read0 (readcharfun
);
1987 read1 (readcharfun
, &ch
, 0);
1991 if (doc_reference
== 1)
1992 return make_number (0);
1993 if (doc_reference
== 2)
1995 /* Get a doc string from the file we are loading.
1996 If it's in saved_doc_string, get it from there. */
1997 int pos
= XINT (XCONS (val
)->cdr
);
1998 if (pos
>= saved_doc_string_position
1999 && pos
< (saved_doc_string_position
2000 + saved_doc_string_length
))
2002 int start
= pos
- saved_doc_string_position
;
2005 /* Process quoting with ^A,
2006 and find the end of the string,
2007 which is marked with ^_ (037). */
2008 for (from
= start
, to
= start
;
2009 saved_doc_string
[from
] != 037;)
2011 int c
= saved_doc_string
[from
++];
2014 c
= saved_doc_string
[from
++];
2016 saved_doc_string
[to
++] = c
;
2018 saved_doc_string
[to
++] = 0;
2020 saved_doc_string
[to
++] = 037;
2023 saved_doc_string
[to
++] = c
;
2026 return make_string (saved_doc_string
+ start
,
2030 return read_doc_string (val
);
2035 return Fsignal (Qinvalid_read_syntax
, Fcons (make_string (". in wrong context", 18), Qnil
));
2037 return Fsignal (Qinvalid_read_syntax
, Fcons (make_string ("] in a list", 11), Qnil
));
2039 tem
= (read_pure
&& flag
<= 0
2040 ? pure_cons (elt
, Qnil
)
2041 : Fcons (elt
, Qnil
));
2043 XCONS (tail
)->cdr
= tem
;
2048 defunflag
= EQ (elt
, Qdefun
);
2049 else if (defunflag
> 0)
2054 Lisp_Object Vobarray
;
2055 Lisp_Object initial_obarray
;
2057 /* oblookup stores the bucket number here, for the sake of Funintern. */
2059 int oblookup_last_bucket_number
;
2061 static int hash_string ();
2062 Lisp_Object
oblookup ();
2064 /* Get an error if OBARRAY is not an obarray.
2065 If it is one, return it. */
2068 check_obarray (obarray
)
2069 Lisp_Object obarray
;
2071 while (!VECTORP (obarray
) || XVECTOR (obarray
)->size
== 0)
2073 /* If Vobarray is now invalid, force it to be valid. */
2074 if (EQ (Vobarray
, obarray
)) Vobarray
= initial_obarray
;
2076 obarray
= wrong_type_argument (Qvectorp
, obarray
);
2081 /* Intern the C string STR: return a symbol with that name,
2082 interned in the current obarray. */
2089 int len
= strlen (str
);
2090 Lisp_Object obarray
;
2093 if (!VECTORP (obarray
) || XVECTOR (obarray
)->size
== 0)
2094 obarray
= check_obarray (obarray
);
2095 tem
= oblookup (obarray
, str
, len
);
2098 return Fintern (make_string (str
, len
), obarray
);
2101 /* Create an uninterned symbol with name STR. */
2107 int len
= strlen (str
);
2109 return Fmake_symbol ((!NILP (Vpurify_flag
)
2110 ? make_pure_string (str
, len
)
2111 : make_string (str
, len
)));
2114 DEFUN ("intern", Fintern
, Sintern
, 1, 2, 0,
2115 "Return the canonical symbol whose name is STRING.\n\
2116 If there is none, one is created by this function and returned.\n\
2117 A second optional argument specifies the obarray to use;\n\
2118 it defaults to the value of `obarray'.")
2120 Lisp_Object string
, obarray
;
2122 register Lisp_Object tem
, sym
, *ptr
;
2124 if (NILP (obarray
)) obarray
= Vobarray
;
2125 obarray
= check_obarray (obarray
);
2127 CHECK_STRING (string
, 0);
2129 tem
= oblookup (obarray
, XSTRING (string
)->data
, XSTRING (string
)->size
);
2130 if (!INTEGERP (tem
))
2133 if (!NILP (Vpurify_flag
))
2134 string
= Fpurecopy (string
);
2135 sym
= Fmake_symbol (string
);
2136 XSYMBOL (sym
)->obarray
= obarray
;
2138 if (XSTRING (string
)->data
[0] == ':')
2139 XSYMBOL (sym
)->value
= sym
;
2141 ptr
= &XVECTOR (obarray
)->contents
[XINT (tem
)];
2143 XSYMBOL (sym
)->next
= XSYMBOL (*ptr
);
2145 XSYMBOL (sym
)->next
= 0;
2150 DEFUN ("intern-soft", Fintern_soft
, Sintern_soft
, 1, 2, 0,
2151 "Return the canonical symbol whose name is STRING, or nil if none exists.\n\
2152 A second optional argument specifies the obarray to use;\n\
2153 it defaults to the value of `obarray'.")
2155 Lisp_Object string
, obarray
;
2157 register Lisp_Object tem
;
2159 if (NILP (obarray
)) obarray
= Vobarray
;
2160 obarray
= check_obarray (obarray
);
2162 CHECK_STRING (string
, 0);
2164 tem
= oblookup (obarray
, XSTRING (string
)->data
, XSTRING (string
)->size
);
2165 if (!INTEGERP (tem
))
2170 DEFUN ("unintern", Funintern
, Sunintern
, 1, 2, 0,
2171 "Delete the symbol named NAME, if any, from OBARRAY.\n\
2172 The value is t if a symbol was found and deleted, nil otherwise.\n\
2173 NAME may be a string or a symbol. If it is a symbol, that symbol\n\
2174 is deleted, if it belongs to OBARRAY--no other symbol is deleted.\n\
2175 OBARRAY defaults to the value of the variable `obarray'.")
2177 Lisp_Object name
, obarray
;
2179 register Lisp_Object string
, tem
;
2182 if (NILP (obarray
)) obarray
= Vobarray
;
2183 obarray
= check_obarray (obarray
);
2186 XSETSTRING (string
, XSYMBOL (name
)->name
);
2189 CHECK_STRING (name
, 0);
2193 tem
= oblookup (obarray
, XSTRING (string
)->data
, XSTRING (string
)->size
);
2196 /* If arg was a symbol, don't delete anything but that symbol itself. */
2197 if (SYMBOLP (name
) && !EQ (name
, tem
))
2200 hash
= oblookup_last_bucket_number
;
2202 if (EQ (XVECTOR (obarray
)->contents
[hash
], tem
))
2204 if (XSYMBOL (tem
)->next
)
2205 XSETSYMBOL (XVECTOR (obarray
)->contents
[hash
], XSYMBOL (tem
)->next
);
2207 XSETINT (XVECTOR (obarray
)->contents
[hash
], 0);
2211 Lisp_Object tail
, following
;
2213 for (tail
= XVECTOR (obarray
)->contents
[hash
];
2214 XSYMBOL (tail
)->next
;
2217 XSETSYMBOL (following
, XSYMBOL (tail
)->next
);
2218 if (EQ (following
, tem
))
2220 XSYMBOL (tail
)->next
= XSYMBOL (following
)->next
;
2229 /* Return the symbol in OBARRAY whose names matches the string
2230 of SIZE characters at PTR. If there is no such symbol in OBARRAY,
2233 Also store the bucket number in oblookup_last_bucket_number. */
2236 oblookup (obarray
, ptr
, size
)
2237 Lisp_Object obarray
;
2243 register Lisp_Object tail
;
2244 Lisp_Object bucket
, tem
;
2246 if (!VECTORP (obarray
)
2247 || (obsize
= XVECTOR (obarray
)->size
) == 0)
2249 obarray
= check_obarray (obarray
);
2250 obsize
= XVECTOR (obarray
)->size
;
2252 /* This is sometimes needed in the middle of GC. */
2253 obsize
&= ~ARRAY_MARK_FLAG
;
2254 /* Combining next two lines breaks VMS C 2.3. */
2255 hash
= hash_string (ptr
, size
);
2257 bucket
= XVECTOR (obarray
)->contents
[hash
];
2258 oblookup_last_bucket_number
= hash
;
2259 if (XFASTINT (bucket
) == 0)
2261 else if (!SYMBOLP (bucket
))
2262 error ("Bad data in guts of obarray"); /* Like CADR error message */
2264 for (tail
= bucket
; ; XSETSYMBOL (tail
, XSYMBOL (tail
)->next
))
2266 if (XSYMBOL (tail
)->name
->size
== size
2267 && !bcmp (XSYMBOL (tail
)->name
->data
, ptr
, size
))
2269 else if (XSYMBOL (tail
)->next
== 0)
2272 XSETINT (tem
, hash
);
2277 hash_string (ptr
, len
)
2281 register unsigned char *p
= ptr
;
2282 register unsigned char *end
= p
+ len
;
2283 register unsigned char c
;
2284 register int hash
= 0;
2289 if (c
>= 0140) c
-= 40;
2290 hash
= ((hash
<<3) + (hash
>>28) + c
);
2292 return hash
& 07777777777;
2296 map_obarray (obarray
, fn
, arg
)
2297 Lisp_Object obarray
;
2298 void (*fn
) P_ ((Lisp_Object
, Lisp_Object
));
2302 register Lisp_Object tail
;
2303 CHECK_VECTOR (obarray
, 1);
2304 for (i
= XVECTOR (obarray
)->size
- 1; i
>= 0; i
--)
2306 tail
= XVECTOR (obarray
)->contents
[i
];
2311 if (XSYMBOL (tail
)->next
== 0)
2313 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
;
2521 int turn_off_warning
= 0;
2523 #ifdef HAVE_SETLOCALE
2524 /* Make sure numbers are parsed as we expect. */
2525 setlocale (LC_NUMERIC
, "C");
2526 #endif /* HAVE_SETLOCALE */
2528 /* Compute the default load-path. */
2530 normal
= PATH_LOADSEARCH
;
2531 Vload_path
= decode_env_path (0, normal
);
2533 if (NILP (Vpurify_flag
))
2534 normal
= PATH_LOADSEARCH
;
2536 normal
= PATH_DUMPLOADSEARCH
;
2538 /* In a dumped Emacs, we normally have to reset the value of
2539 Vload_path from PATH_LOADSEARCH, since the value that was dumped
2540 uses ../lisp, instead of the path of the installed elisp
2541 libraries. However, if it appears that Vload_path was changed
2542 from the default before dumping, don't override that value. */
2545 if (! NILP (Fequal (dump_path
, Vload_path
)))
2547 Vload_path
= decode_env_path (0, normal
);
2548 if (!NILP (Vinstallation_directory
))
2550 /* Add to the path the lisp subdir of the
2551 installation dir, if it exists. */
2552 Lisp_Object tem
, tem1
;
2553 tem
= Fexpand_file_name (build_string ("lisp"),
2554 Vinstallation_directory
);
2555 tem1
= Ffile_exists_p (tem
);
2558 if (NILP (Fmember (tem
, Vload_path
)))
2560 turn_off_warning
= 1;
2561 Vload_path
= nconc2 (Vload_path
, Fcons (tem
, Qnil
));
2565 /* That dir doesn't exist, so add the build-time
2566 Lisp dirs instead. */
2567 Vload_path
= nconc2 (Vload_path
, dump_path
);
2569 /* Add leim under the installation dir, if it exists. */
2570 tem
= Fexpand_file_name (build_string ("leim"),
2571 Vinstallation_directory
);
2572 tem1
= Ffile_exists_p (tem
);
2575 if (NILP (Fmember (tem
, Vload_path
)))
2576 Vload_path
= nconc2 (Vload_path
, Fcons (tem
, Qnil
));
2579 /* Add site-list under the installation dir, if it exists. */
2580 tem
= Fexpand_file_name (build_string ("site-lisp"),
2581 Vinstallation_directory
);
2582 tem1
= Ffile_exists_p (tem
);
2585 if (NILP (Fmember (tem
, Vload_path
)))
2586 Vload_path
= nconc2 (Vload_path
, Fcons (tem
, Qnil
));
2589 /* If Emacs was not built in the source directory,
2590 and it is run from where it was built, add to load-path
2591 the lisp, leim and site-lisp dirs under that directory. */
2593 if (NILP (Fequal (Vinstallation_directory
, Vsource_directory
)))
2597 tem
= Fexpand_file_name (build_string ("src/Makefile"),
2598 Vinstallation_directory
);
2599 tem1
= Ffile_exists_p (tem
);
2601 /* Don't be fooled if they moved the entire source tree
2602 AFTER dumping Emacs. If the build directory is indeed
2603 different from the source dir, src/Makefile.in and
2604 src/Makefile will not be found together. */
2605 tem
= Fexpand_file_name (build_string ("src/Makefile.in"),
2606 Vinstallation_directory
);
2607 tem2
= Ffile_exists_p (tem
);
2608 if (!NILP (tem1
) && NILP (tem2
))
2610 tem
= Fexpand_file_name (build_string ("lisp"),
2613 if (NILP (Fmember (tem
, Vload_path
)))
2614 Vload_path
= nconc2 (Vload_path
, Fcons (tem
, Qnil
));
2616 tem
= Fexpand_file_name (build_string ("leim"),
2619 if (NILP (Fmember (tem
, Vload_path
)))
2620 Vload_path
= nconc2 (Vload_path
, Fcons (tem
, Qnil
));
2622 tem
= Fexpand_file_name (build_string ("site-lisp"),
2625 if (NILP (Fmember (tem
, Vload_path
)))
2626 Vload_path
= nconc2 (Vload_path
, Fcons (tem
, Qnil
));
2634 /* NORMAL refers to the lisp dir in the source directory. */
2635 /* We used to add ../lisp at the front here, but
2636 that caused trouble because it was copied from dump_path
2637 into Vload_path, aboe, when Vinstallation_directory was non-nil.
2638 It should be unnecessary. */
2639 Vload_path
= decode_env_path (0, normal
);
2640 dump_path
= Vload_path
;
2645 /* When Emacs is invoked over network shares on NT, PATH_LOADSEARCH is
2646 almost never correct, thereby causing a warning to be printed out that
2647 confuses users. Since PATH_LOADSEARCH is always overridden by the
2648 EMACSLOADPATH environment variable below, disable the warning on NT. */
2650 /* Warn if dirs in the *standard* path don't exist. */
2651 if (!turn_off_warning
)
2653 Lisp_Object path_tail
;
2655 for (path_tail
= Vload_path
;
2657 path_tail
= XCONS (path_tail
)->cdr
)
2659 Lisp_Object dirfile
;
2660 dirfile
= Fcar (path_tail
);
2661 if (STRINGP (dirfile
))
2663 dirfile
= Fdirectory_file_name (dirfile
);
2664 if (access (XSTRING (dirfile
)->data
, 0) < 0)
2665 dir_warning ("Warning: Lisp directory `%s' does not exist.\n",
2666 XCONS (path_tail
)->car
);
2670 #endif /* WINDOWSNT */
2672 /* If the EMACSLOADPATH environment variable is set, use its value.
2673 This doesn't apply if we're dumping. */
2675 if (NILP (Vpurify_flag
)
2676 && egetenv ("EMACSLOADPATH"))
2678 Vload_path
= decode_env_path ("EMACSLOADPATH", normal
);
2682 load_in_progress
= 0;
2683 Vload_file_name
= Qnil
;
2685 load_descriptor_list
= Qnil
;
2688 /* Print a warning, using format string FORMAT, that directory DIRNAME
2689 does not exist. Print it on stderr and put it in *Message*. */
2692 dir_warning (format
, dirname
)
2694 Lisp_Object dirname
;
2697 = (char *) alloca (XSTRING (dirname
)->size
+ strlen (format
) + 5);
2699 fprintf (stderr
, format
, XSTRING (dirname
)->data
);
2700 sprintf (buffer
, format
, XSTRING (dirname
)->data
);
2701 message_dolog (buffer
, strlen (buffer
), 0);
2708 defsubr (&Sread_from_string
);
2710 defsubr (&Sintern_soft
);
2711 defsubr (&Sunintern
);
2713 defsubr (&Seval_buffer
);
2714 defsubr (&Seval_region
);
2715 defsubr (&Sread_char
);
2716 defsubr (&Sread_char_exclusive
);
2717 defsubr (&Sread_event
);
2718 defsubr (&Sget_file_char
);
2719 defsubr (&Smapatoms
);
2721 DEFVAR_LISP ("obarray", &Vobarray
,
2722 "Symbol table for use by `intern' and `read'.\n\
2723 It is a vector whose length ought to be prime for best results.\n\
2724 The vector's contents don't make sense if examined from Lisp programs;\n\
2725 to find all the symbols in an obarray, use `mapatoms'.");
2727 DEFVAR_LISP ("values", &Vvalues
,
2728 "List of values of all expressions which were read, evaluated and printed.\n\
2729 Order is reverse chronological.");
2731 DEFVAR_LISP ("standard-input", &Vstandard_input
,
2732 "Stream for read to get input from.\n\
2733 See documentation of `read' for possible values.");
2734 Vstandard_input
= Qt
;
2736 DEFVAR_LISP ("load-path", &Vload_path
,
2737 "*List of directories to search for files to load.\n\
2738 Each element is a string (directory name) or nil (try default directory).\n\
2739 Initialized based on EMACSLOADPATH environment variable, if any,\n\
2740 otherwise to default specified by file `paths.h' when Emacs was built.");
2742 DEFVAR_BOOL ("load-in-progress", &load_in_progress
,
2743 "Non-nil iff inside of `load'.");
2745 DEFVAR_LISP ("after-load-alist", &Vafter_load_alist
,
2746 "An alist of expressions to be evalled when particular files are loaded.\n\
2747 Each element looks like (FILENAME FORMS...).\n\
2748 When `load' is run and the file-name argument is FILENAME,\n\
2749 the FORMS in the corresponding element are executed at the end of loading.\n\n\
2750 FILENAME must match exactly! Normally FILENAME is the name of a library,\n\
2751 with no directory specified, since that is how `load' is normally called.\n\
2752 An error in FORMS does not undo the load,\n\
2753 but does prevent execution of the rest of the FORMS.");
2754 Vafter_load_alist
= Qnil
;
2756 DEFVAR_LISP ("load-history", &Vload_history
,
2757 "Alist mapping source file names to symbols and features.\n\
2758 Each alist element is a list that starts with a file name,\n\
2759 except for one element (optional) that starts with nil and describes\n\
2760 definitions evaluated from buffers not visiting files.\n\
2761 The remaining elements of each list are symbols defined as functions\n\
2762 or variables, and cons cells `(provide . FEATURE)' and `(require . FEATURE)'.");
2763 Vload_history
= Qnil
;
2765 DEFVAR_LISP ("load-file-name", &Vload_file_name
,
2766 "Full name of file being loaded by `load'.");
2767 Vload_file_name
= Qnil
;
2769 DEFVAR_LISP ("current-load-list", &Vcurrent_load_list
,
2770 "Used for internal purposes by `load'.");
2771 Vcurrent_load_list
= Qnil
;
2773 DEFVAR_LISP ("load-read-function", &Vload_read_function
,
2774 "Function used by `load' and `eval-region' for reading expressions.\n\
2775 The default is nil, which means use the function `read'.");
2776 Vload_read_function
= Qnil
;
2778 DEFVAR_LISP ("load-source-file-function", &Vload_source_file_function
,
2779 "Function called in `load' for loading an Emacs lisp source file.\n\
2780 This function is for doing code conversion before reading the source file.\n\
2781 If nil, loading is done without any code conversion.\n\
2782 Arguments are FULLNAME, FILE, NOERROR, NOMESSAGE, where\n\
2783 FULLNAME is the full name of FILE.\n\
2784 See `load' for the meaning of the remaining arguments.");
2785 Vload_source_file_function
= Qnil
;
2787 DEFVAR_BOOL ("load-force-doc-strings", &load_force_doc_strings
,
2788 "Non-nil means `load' should force-load all dynamic doc strings.\n\
2789 This is useful when the file being loaded is a temporary copy.");
2790 load_force_doc_strings
= 0;
2792 DEFVAR_LISP ("source-directory", &Vsource_directory
,
2793 "Directory in which Emacs sources were found when Emacs was built.\n\
2794 You cannot count on them to still be there!");
2796 = Fexpand_file_name (build_string ("../"),
2797 Fcar (decode_env_path (0, PATH_DUMPLOADSEARCH
)));
2799 DEFVAR_LISP ("preloaded-file-list", &Vpreloaded_file_list
,
2800 "List of files that were preloaded (when dumping Emacs).");
2801 Vpreloaded_file_list
= Qnil
;
2803 /* Vsource_directory was initialized in init_lread. */
2805 load_descriptor_list
= Qnil
;
2806 staticpro (&load_descriptor_list
);
2808 Qcurrent_load_list
= intern ("current-load-list");
2809 staticpro (&Qcurrent_load_list
);
2811 Qstandard_input
= intern ("standard-input");
2812 staticpro (&Qstandard_input
);
2814 Qread_char
= intern ("read-char");
2815 staticpro (&Qread_char
);
2817 Qget_file_char
= intern ("get-file-char");
2818 staticpro (&Qget_file_char
);
2820 Qbackquote
= intern ("`");
2821 staticpro (&Qbackquote
);
2822 Qcomma
= intern (",");
2823 staticpro (&Qcomma
);
2824 Qcomma_at
= intern (",@");
2825 staticpro (&Qcomma_at
);
2826 Qcomma_dot
= intern (",.");
2827 staticpro (&Qcomma_dot
);
2829 Qinhibit_file_name_operation
= intern ("inhibit-file-name-operation");
2830 staticpro (&Qinhibit_file_name_operation
);
2832 Qascii_character
= intern ("ascii-character");
2833 staticpro (&Qascii_character
);
2835 Qfunction
= intern ("function");
2836 staticpro (&Qfunction
);
2838 Qload
= intern ("load");
2841 Qload_file_name
= intern ("load-file-name");
2842 staticpro (&Qload_file_name
);
2844 staticpro (&dump_path
);
2846 staticpro (&read_objects
);
2847 read_objects
= Qnil
;