diff options
Diffstat (limited to 'src/lread.c')
| -rw-r--r-- | src/lread.c | 73 |
1 files changed, 49 insertions, 24 deletions
diff --git a/src/lread.c b/src/lread.c index b6161ebedaa..d8abde1c458 100644 --- a/src/lread.c +++ b/src/lread.c | |||
| @@ -89,6 +89,7 @@ Lisp_Object Qascii_character, Qload, Qload_file_name; | |||
| 89 | Lisp_Object Qbackquote, Qcomma, Qcomma_at, Qcomma_dot, Qfunction; | 89 | Lisp_Object Qbackquote, Qcomma, Qcomma_at, Qcomma_dot, Qfunction; |
| 90 | Lisp_Object Qinhibit_file_name_operation; | 90 | Lisp_Object Qinhibit_file_name_operation; |
| 91 | Lisp_Object Qeval_buffer_list, Veval_buffer_list; | 91 | Lisp_Object Qeval_buffer_list, Veval_buffer_list; |
| 92 | Lisp_Object Qfile_truename, Qdo_after_load_evaluation; /* ACM 2006/5/16 */ | ||
| 92 | 93 | ||
| 93 | /* Used instead of Qget_file_char while loading *.elc files compiled | 94 | /* Used instead of Qget_file_char while loading *.elc files compiled |
| 94 | by Emacs 21 or older. */ | 95 | by Emacs 21 or older. */ |
| @@ -897,8 +898,8 @@ Return t if the file exists and loads successfully. */) | |||
| 897 | register int fd = -1; | 898 | register int fd = -1; |
| 898 | int count = SPECPDL_INDEX (); | 899 | int count = SPECPDL_INDEX (); |
| 899 | Lisp_Object temp; | 900 | Lisp_Object temp; |
| 900 | struct gcpro gcpro1, gcpro2; | 901 | struct gcpro gcpro1, gcpro2, gcpro3; |
| 901 | Lisp_Object found, efound; | 902 | Lisp_Object found, efound, hist_file_name; |
| 902 | /* 1 means we printed the ".el is newer" message. */ | 903 | /* 1 means we printed the ".el is newer" message. */ |
| 903 | int newer = 0; | 904 | int newer = 0; |
| 904 | /* 1 means we are loading a compiled file. */ | 905 | /* 1 means we are loading a compiled file. */ |
| @@ -906,6 +907,7 @@ Return t if the file exists and loads successfully. */) | |||
| 906 | Lisp_Object handler; | 907 | Lisp_Object handler; |
| 907 | int safe_p = 1; | 908 | int safe_p = 1; |
| 908 | char *fmode = "r"; | 909 | char *fmode = "r"; |
| 910 | Lisp_Object tmp[2]; | ||
| 909 | int version; | 911 | int version; |
| 910 | 912 | ||
| 911 | #ifdef DOS_NT | 913 | #ifdef DOS_NT |
| @@ -924,7 +926,7 @@ Return t if the file exists and loads successfully. */) | |||
| 924 | the need to gcpro noerror, nomessage and nosuffix. | 926 | the need to gcpro noerror, nomessage and nosuffix. |
| 925 | (Below here, we care only whether they are nil or not.) | 927 | (Below here, we care only whether they are nil or not.) |
| 926 | The presence of this call is the result of a historical accident: | 928 | The presence of this call is the result of a historical accident: |
| 927 | it used to be in every file-operations and when it got removed | 929 | it used to be in every file-operation and when it got removed |
| 928 | everywhere, it accidentally stayed here. Since then, enough people | 930 | everywhere, it accidentally stayed here. Since then, enough people |
| 929 | supposedly have things like (load "$PROJECT/foo.el") in their .emacs | 931 | supposedly have things like (load "$PROJECT/foo.el") in their .emacs |
| 930 | that it seemed risky to remove. */ | 932 | that it seemed risky to remove. */ |
| @@ -944,7 +946,6 @@ Return t if the file exists and loads successfully. */) | |||
| 944 | if (SCHARS (file) > 0) | 946 | if (SCHARS (file) > 0) |
| 945 | { | 947 | { |
| 946 | int size = SBYTES (file); | 948 | int size = SBYTES (file); |
| 947 | Lisp_Object tmp[2]; | ||
| 948 | 949 | ||
| 949 | found = Qnil; | 950 | found = Qnil; |
| 950 | GCPRO2 (file, found); | 951 | GCPRO2 (file, found); |
| @@ -1028,6 +1029,13 @@ Return t if the file exists and loads successfully. */) | |||
| 1028 | Vloads_in_progress = Fcons (found, Vloads_in_progress); | 1029 | Vloads_in_progress = Fcons (found, Vloads_in_progress); |
| 1029 | } | 1030 | } |
| 1030 | 1031 | ||
| 1032 | /* Get the name for load-history. */ | ||
| 1033 | hist_file_name = (! NILP (Vpurify_flag) | ||
| 1034 | ? Fconcat (2, (tmp[0] = Ffile_name_directory (file), | ||
| 1035 | tmp[1] = Ffile_name_nondirectory (found), | ||
| 1036 | tmp)) | ||
| 1037 | : found) ; | ||
| 1038 | |||
| 1031 | version = -1; | 1039 | version = -1; |
| 1032 | if (!bcmp (SDATA (found) + SBYTES (found) - 4, | 1040 | if (!bcmp (SDATA (found) + SBYTES (found) - 4, |
| 1033 | ".elc", 4) | 1041 | ".elc", 4) |
| @@ -1040,7 +1048,7 @@ Return t if the file exists and loads successfully. */) | |||
| 1040 | struct stat s1, s2; | 1048 | struct stat s1, s2; |
| 1041 | int result; | 1049 | int result; |
| 1042 | 1050 | ||
| 1043 | GCPRO2 (file, found); | 1051 | GCPRO3 (file, found, hist_file_name); |
| 1044 | 1052 | ||
| 1045 | if (version < 0 | 1053 | if (version < 0 |
| 1046 | && ! (version = safe_to_load_p (fd))) | 1054 | && ! (version = safe_to_load_p (fd))) |
| @@ -1095,14 +1103,14 @@ Return t if the file exists and loads successfully. */) | |||
| 1095 | 1103 | ||
| 1096 | if (fd >= 0) | 1104 | if (fd >= 0) |
| 1097 | emacs_close (fd); | 1105 | emacs_close (fd); |
| 1098 | val = call4 (Vload_source_file_function, found, file, | 1106 | val = call4 (Vload_source_file_function, found, hist_file_name, |
| 1099 | NILP (noerror) ? Qnil : Qt, | 1107 | NILP (noerror) ? Qnil : Qt, |
| 1100 | NILP (nomessage) ? Qnil : Qt); | 1108 | NILP (nomessage) ? Qnil : Qt); |
| 1101 | return unbind_to (count, val); | 1109 | return unbind_to (count, val); |
| 1102 | } | 1110 | } |
| 1103 | } | 1111 | } |
| 1104 | 1112 | ||
| 1105 | GCPRO2 (file, found); | 1113 | GCPRO3 (file, found, hist_file_name); |
| 1106 | 1114 | ||
| 1107 | #ifdef WINDOWSNT | 1115 | #ifdef WINDOWSNT |
| 1108 | emacs_close (fd); | 1116 | emacs_close (fd); |
| @@ -1142,23 +1150,23 @@ Return t if the file exists and loads successfully. */) | |||
| 1142 | = Fcons (make_number (fileno (stream)), load_descriptor_list); | 1150 | = Fcons (make_number (fileno (stream)), load_descriptor_list); |
| 1143 | load_in_progress++; | 1151 | load_in_progress++; |
| 1144 | if (! version || version >= 22) | 1152 | if (! version || version >= 22) |
| 1145 | readevalloop (Qget_file_char, stream, | 1153 | readevalloop (Qget_file_char, stream, hist_file_name, |
| 1146 | (! NILP (Vpurify_flag) ? file : found), | ||
| 1147 | Feval, 0, Qnil, Qnil, Qnil, Qnil); | 1154 | Feval, 0, Qnil, Qnil, Qnil, Qnil); |
| 1148 | else | 1155 | else |
| 1149 | { | 1156 | { |
| 1150 | /* We can't handle a file which was compiled with | 1157 | /* We can't handle a file which was compiled with |
| 1151 | byte-compile-dynamic by older version of Emacs. */ | 1158 | byte-compile-dynamic by older version of Emacs. */ |
| 1152 | specbind (Qload_force_doc_strings, Qt); | 1159 | specbind (Qload_force_doc_strings, Qt); |
| 1153 | readevalloop (Qget_emacs_mule_file_char, stream, file, Feval, | 1160 | readevalloop (Qget_emacs_mule_file_char, stream, hist_file_name, Feval, |
| 1154 | 0, Qnil, Qnil, Qnil, Qnil); | 1161 | 0, Qnil, Qnil, Qnil, Qnil); |
| 1155 | } | 1162 | } |
| 1156 | unbind_to (count, Qnil); | 1163 | unbind_to (count, Qnil); |
| 1157 | 1164 | ||
| 1158 | /* Run any load-hooks for this file. */ | 1165 | /* Run any eval-after-load forms for this file */ |
| 1159 | temp = Fassoc (file, Vafter_load_alist); | 1166 | if (NILP (Vpurify_flag) |
| 1160 | if (!NILP (temp)) | 1167 | && (!NILP (Ffboundp (Qdo_after_load_evaluation)))) |
| 1161 | Fprogn (Fcdr (temp)); | 1168 | call1 (Qdo_after_load_evaluation, hist_file_name) ; |
| 1169 | |||
| 1162 | UNGCPRO; | 1170 | UNGCPRO; |
| 1163 | 1171 | ||
| 1164 | if (saved_doc_string) | 1172 | if (saved_doc_string) |
| @@ -1583,6 +1591,12 @@ readevalloop (readcharfun, stream, sourcename, evalfun, | |||
| 1583 | 1591 | ||
| 1584 | GCPRO4 (sourcename, readfun, start, end); | 1592 | GCPRO4 (sourcename, readfun, start, end); |
| 1585 | 1593 | ||
| 1594 | /* Try to ensure sourcename is a truename, except whilst preloading. */ | ||
| 1595 | if (NILP (Vpurify_flag) | ||
| 1596 | && !NILP (sourcename) && Ffile_name_absolute_p (sourcename) | ||
| 1597 | && (!NILP (Ffboundp (Qfile_truename)))) | ||
| 1598 | sourcename = call1 (Qfile_truename, sourcename) ; | ||
| 1599 | |||
| 1586 | LOADHIST_ATTACH (sourcename); | 1600 | LOADHIST_ATTACH (sourcename); |
| 1587 | 1601 | ||
| 1588 | continue_reading_p = 1; | 1602 | continue_reading_p = 1; |
| @@ -4110,16 +4124,17 @@ customize `jka-compr-load-suffixes' rather than the present variable. */); | |||
| 4110 | 4124 | ||
| 4111 | DEFVAR_LISP ("after-load-alist", &Vafter_load_alist, | 4125 | DEFVAR_LISP ("after-load-alist", &Vafter_load_alist, |
| 4112 | doc: /* An alist of expressions to be evalled when particular files are loaded. | 4126 | doc: /* An alist of expressions to be evalled when particular files are loaded. |
| 4113 | Each element looks like (FILENAME FORMS...). | 4127 | Each element looks like (REGEXP-OR-FEATURE FORMS...). |
| 4114 | When `load' is run and the file-name argument is FILENAME, | 4128 | |
| 4115 | the FORMS in the corresponding element are executed at the end of loading. | 4129 | REGEXP-OR-FEATURE is either a regular expression to match file names, or |
| 4116 | 4130 | a symbol \(a feature name). | |
| 4117 | FILENAME must match exactly! Normally FILENAME is the name of a library, | 4131 | |
| 4118 | with no directory specified, since that is how `load' is normally called. | 4132 | When `load' is run and the file-name argument matches an element's |
| 4119 | An error in FORMS does not undo the load, | 4133 | REGEXP-OR-FEATURE, or when `provide' is run and provides the symbol |
| 4120 | but does prevent execution of the rest of the FORMS. | 4134 | REGEXP-OR-FEATURE, the FORMS in the element are executed. |
| 4121 | FILENAME can also be a symbol (a feature) and FORMS are then executed | 4135 | |
| 4122 | when the corresponding call to `provide' is made. */); | 4136 | An error in FORMS does not undo the load, but does prevent execution of |
| 4137 | the rest of the FORMS. */); | ||
| 4123 | Vafter_load_alist = Qnil; | 4138 | Vafter_load_alist = Qnil; |
| 4124 | 4139 | ||
| 4125 | DEFVAR_LISP ("load-history", &Vload_history, | 4140 | DEFVAR_LISP ("load-history", &Vload_history, |
| @@ -4127,6 +4142,10 @@ when the corresponding call to `provide' is made. */); | |||
| 4127 | Each alist element is a list that starts with a file name, | 4142 | Each alist element is a list that starts with a file name, |
| 4128 | except for one element (optional) that starts with nil and describes | 4143 | except for one element (optional) that starts with nil and describes |
| 4129 | definitions evaluated from buffers not visiting files. | 4144 | definitions evaluated from buffers not visiting files. |
| 4145 | |||
| 4146 | The file name is absolute and is the true file name (i.e. it doesn't | ||
| 4147 | contain symbolic links) of the loaded file. | ||
| 4148 | |||
| 4130 | The remaining elements of each list are symbols defined as variables | 4149 | The remaining elements of each list are symbols defined as variables |
| 4131 | and cons cells of the form `(provide . FEATURE)', `(require . FEATURE)', | 4150 | and cons cells of the form `(provide . FEATURE)', `(require . FEATURE)', |
| 4132 | `(defun . FUNCTION)', `(autoload . SYMBOL)', and `(t . SYMBOL)'. | 4151 | `(defun . FUNCTION)', `(autoload . SYMBOL)', and `(t . SYMBOL)'. |
| @@ -4263,6 +4282,12 @@ to load. See also `load-dangerous-libraries'. */); | |||
| 4263 | Qeval_buffer_list = intern ("eval-buffer-list"); | 4282 | Qeval_buffer_list = intern ("eval-buffer-list"); |
| 4264 | staticpro (&Qeval_buffer_list); | 4283 | staticpro (&Qeval_buffer_list); |
| 4265 | 4284 | ||
| 4285 | Qfile_truename = intern ("file-truename"); | ||
| 4286 | staticpro (&Qfile_truename) ; | ||
| 4287 | |||
| 4288 | Qdo_after_load_evaluation = intern ("do-after-load-evaluation"); | ||
| 4289 | staticpro (&Qdo_after_load_evaluation) ; | ||
| 4290 | |||
| 4266 | staticpro (&dump_path); | 4291 | staticpro (&dump_path); |
| 4267 | 4292 | ||
| 4268 | staticpro (&read_objects); | 4293 | staticpro (&read_objects); |