diff options
| author | Paul Eggert | 2012-01-14 22:41:53 -0800 |
|---|---|---|
| committer | Paul Eggert | 2012-01-14 22:41:53 -0800 |
| commit | 807f82fcebc7d946baa23f1d29ff5b0cf336f08e (patch) | |
| tree | fa41cebf5b9c6d3bb6a22517a7002fe3a398588f /src/lread.c | |
| parent | 35cf62d95cdcd5323dcea4a5385942c342ff1d9c (diff) | |
| parent | 861df977526140af8147bef4950e8863655c203d (diff) | |
| download | emacs-807f82fcebc7d946baa23f1d29ff5b0cf336f08e.tar.gz emacs-807f82fcebc7d946baa23f1d29ff5b0cf336f08e.zip | |
Merge from trunk.
Diffstat (limited to 'src/lread.c')
| -rw-r--r-- | src/lread.c | 205 |
1 files changed, 129 insertions, 76 deletions
diff --git a/src/lread.c b/src/lread.c index 2a7b7a8585d..256624da046 100644 --- a/src/lread.c +++ b/src/lread.c | |||
| @@ -4115,7 +4115,46 @@ init_lread (void) | |||
| 4115 | const char *normal; | 4115 | const char *normal; |
| 4116 | int turn_off_warning = 0; | 4116 | int turn_off_warning = 0; |
| 4117 | 4117 | ||
| 4118 | /* Compute the default load-path. */ | 4118 | /* Compute the default Vload-path, with the following logic: |
| 4119 | If CANNOT_DUMP just use PATH_LOADSEARCH. | ||
| 4120 | Else if purify-flag (ie dumping) start from PATH_DUMPLOADSEARCH; | ||
| 4121 | otherwise start from PATH_LOADSEARCH. | ||
| 4122 | If !initialized, then just set both Vload_path and dump_path. | ||
| 4123 | If initialized, then if Vload_path != dump_path, do nothing. | ||
| 4124 | (Presumably the load-path has already been changed by something.) | ||
| 4125 | Also do nothing if Vinstallation_directory is nil. | ||
| 4126 | Otherwise: | ||
| 4127 | Remove site-lisp directories from the front of load-path. | ||
| 4128 | Add installation-dir/lisp (if exists and not already a member), | ||
| 4129 | at the front, and turn off warnings about missing directories | ||
| 4130 | (because we are presumably running uninstalled). | ||
| 4131 | If it does not exist, add dump_path at the end instead. | ||
| 4132 | Add installation-dir/leim (if exists and not already a member) | ||
| 4133 | at the front. | ||
| 4134 | Add installation-dir/site-lisp (if !no_site_lisp, and exists | ||
| 4135 | and not already a member) at the front. | ||
| 4136 | If installation-dir != source-dir (ie running an uninstalled, | ||
| 4137 | out-of-tree build) AND install-dir/src/Makefile exists BUT | ||
| 4138 | install-dir/src/Makefile.in does NOT exist (this is a sanity | ||
| 4139 | check), then repeat the above steps for source-dir/lisp, | ||
| 4140 | leim and site-lisp. | ||
| 4141 | Finally, add the previously removed site-lisp directories back | ||
| 4142 | at the front (if !no_site_lisp). | ||
| 4143 | |||
| 4144 | We then warn about any of the load-path elements that do not | ||
| 4145 | exist. The only ones that might not exist are those from | ||
| 4146 | PATH_LOADSEARCH, and perhaps dump_path. | ||
| 4147 | |||
| 4148 | Having done all this, we then throw it all away if purify-flag is | ||
| 4149 | nil (ie, not dumping) and EMACSLOADPATH is set, and just | ||
| 4150 | unconditionally use the latter value instead. | ||
| 4151 | So AFAICS the only net results of all the previous steps will be | ||
| 4152 | possibly to issue some irrelevant warnings. | ||
| 4153 | |||
| 4154 | FIXME? There's a case for saying that if we are running | ||
| 4155 | uninstalled, the eventual installation directories should not yet | ||
| 4156 | be included in load-path. | ||
| 4157 | */ | ||
| 4119 | #ifdef CANNOT_DUMP | 4158 | #ifdef CANNOT_DUMP |
| 4120 | normal = PATH_LOADSEARCH; | 4159 | normal = PATH_LOADSEARCH; |
| 4121 | Vload_path = decode_env_path (0, normal); | 4160 | Vload_path = decode_env_path (0, normal); |
| @@ -4125,23 +4164,28 @@ init_lread (void) | |||
| 4125 | else | 4164 | else |
| 4126 | normal = PATH_DUMPLOADSEARCH; | 4165 | normal = PATH_DUMPLOADSEARCH; |
| 4127 | 4166 | ||
| 4128 | /* In a dumped Emacs, we normally have to reset the value of | 4167 | /* In a dumped Emacs, we normally reset the value of Vload_path using |
| 4129 | Vload_path from PATH_LOADSEARCH, since the value that was dumped | 4168 | PATH_LOADSEARCH, since the value that was dumped uses lisp/ in |
| 4130 | uses ../lisp, instead of the path of the installed elisp | 4169 | the source directory, instead of the path of the installed elisp |
| 4131 | libraries. However, if it appears that Vload_path was changed | 4170 | libraries. However, if it appears that Vload_path has already been |
| 4132 | from the default before dumping, don't override that value. */ | 4171 | changed from the default that was saved before dumping, don't |
| 4172 | change it further. */ | ||
| 4133 | if (initialized) | 4173 | if (initialized) |
| 4134 | { | 4174 | { |
| 4135 | if (! NILP (Fequal (dump_path, Vload_path))) | 4175 | if (! NILP (Fequal (dump_path, Vload_path))) |
| 4136 | { | 4176 | { |
| 4137 | Vload_path = decode_env_path (0, normal); | 4177 | Vload_path = decode_env_path (0, normal); |
| 4138 | if (!NILP (Vinstallation_directory)) | 4178 | if (no_site_lisp || !NILP (Vinstallation_directory)) |
| 4139 | { | 4179 | { |
| 4140 | Lisp_Object tem, tem1, sitelisp; | 4180 | Lisp_Object tem, tem1, sitelisp; |
| 4141 | 4181 | ||
| 4142 | /* Remove site-lisp dirs from path temporarily and store | 4182 | /* Remove "site-lisp" dirs from front of path temporarily |
| 4143 | them in sitelisp, then conc them on at the end so | 4183 | and store them in sitelisp, then conc them on at the |
| 4144 | they're always first in path. */ | 4184 | end so they're always first in path. |
| 4185 | Note that this won't work if you used a | ||
| 4186 | --enable-locallisppath element that does not happen | ||
| 4187 | to contain "site-lisp" in its name. | ||
| 4188 | */ | ||
| 4145 | sitelisp = Qnil; | 4189 | sitelisp = Qnil; |
| 4146 | while (1) | 4190 | while (1) |
| 4147 | { | 4191 | { |
| @@ -4157,96 +4201,99 @@ init_lread (void) | |||
| 4157 | break; | 4201 | break; |
| 4158 | } | 4202 | } |
| 4159 | 4203 | ||
| 4160 | /* Add to the path the lisp subdir of the | 4204 | if (!NILP (Vinstallation_directory)) |
| 4161 | installation dir, if it exists. */ | ||
| 4162 | tem = Fexpand_file_name (build_string ("lisp"), | ||
| 4163 | Vinstallation_directory); | ||
| 4164 | tem1 = Ffile_exists_p (tem); | ||
| 4165 | if (!NILP (tem1)) | ||
| 4166 | { | ||
| 4167 | if (NILP (Fmember (tem, Vload_path))) | ||
| 4168 | { | ||
| 4169 | turn_off_warning = 1; | ||
| 4170 | Vload_path = Fcons (tem, Vload_path); | ||
| 4171 | } | ||
| 4172 | } | ||
| 4173 | else | ||
| 4174 | /* That dir doesn't exist, so add the build-time | ||
| 4175 | Lisp dirs instead. */ | ||
| 4176 | Vload_path = nconc2 (Vload_path, dump_path); | ||
| 4177 | |||
| 4178 | /* Add leim under the installation dir, if it exists. */ | ||
| 4179 | tem = Fexpand_file_name (build_string ("leim"), | ||
| 4180 | Vinstallation_directory); | ||
| 4181 | tem1 = Ffile_exists_p (tem); | ||
| 4182 | if (!NILP (tem1)) | ||
| 4183 | { | ||
| 4184 | if (NILP (Fmember (tem, Vload_path))) | ||
| 4185 | Vload_path = Fcons (tem, Vload_path); | ||
| 4186 | } | ||
| 4187 | |||
| 4188 | /* Add site-lisp under the installation dir, if it exists. */ | ||
| 4189 | if (!no_site_lisp) | ||
| 4190 | { | 4205 | { |
| 4191 | tem = Fexpand_file_name (build_string ("site-lisp"), | 4206 | /* Add to the path the lisp subdir of the |
| 4207 | installation dir, if it exists. */ | ||
| 4208 | tem = Fexpand_file_name (build_string ("lisp"), | ||
| 4192 | Vinstallation_directory); | 4209 | Vinstallation_directory); |
| 4193 | tem1 = Ffile_exists_p (tem); | 4210 | tem1 = Ffile_exists_p (tem); |
| 4194 | if (!NILP (tem1)) | 4211 | if (!NILP (tem1)) |
| 4195 | { | 4212 | { |
| 4196 | if (NILP (Fmember (tem, Vload_path))) | 4213 | if (NILP (Fmember (tem, Vload_path))) |
| 4197 | Vload_path = Fcons (tem, Vload_path); | 4214 | { |
| 4215 | turn_off_warning = 1; | ||
| 4216 | Vload_path = Fcons (tem, Vload_path); | ||
| 4217 | } | ||
| 4198 | } | 4218 | } |
| 4199 | } | 4219 | else |
| 4200 | 4220 | /* That dir doesn't exist, so add the build-time | |
| 4201 | /* If Emacs was not built in the source directory, | 4221 | Lisp dirs instead. */ |
| 4202 | and it is run from where it was built, add to load-path | 4222 | Vload_path = nconc2 (Vload_path, dump_path); |
| 4203 | the lisp, leim and site-lisp dirs under that directory. */ | ||
| 4204 | |||
| 4205 | if (NILP (Fequal (Vinstallation_directory, Vsource_directory))) | ||
| 4206 | { | ||
| 4207 | Lisp_Object tem2; | ||
| 4208 | 4223 | ||
| 4209 | tem = Fexpand_file_name (build_string ("src/Makefile"), | 4224 | /* Add leim under the installation dir, if it exists. */ |
| 4225 | tem = Fexpand_file_name (build_string ("leim"), | ||
| 4210 | Vinstallation_directory); | 4226 | Vinstallation_directory); |
| 4211 | tem1 = Ffile_exists_p (tem); | 4227 | tem1 = Ffile_exists_p (tem); |
| 4212 | 4228 | if (!NILP (tem1)) | |
| 4213 | /* Don't be fooled if they moved the entire source tree | ||
| 4214 | AFTER dumping Emacs. If the build directory is indeed | ||
| 4215 | different from the source dir, src/Makefile.in and | ||
| 4216 | src/Makefile will not be found together. */ | ||
| 4217 | tem = Fexpand_file_name (build_string ("src/Makefile.in"), | ||
| 4218 | Vinstallation_directory); | ||
| 4219 | tem2 = Ffile_exists_p (tem); | ||
| 4220 | if (!NILP (tem1) && NILP (tem2)) | ||
| 4221 | { | 4229 | { |
| 4222 | tem = Fexpand_file_name (build_string ("lisp"), | ||
| 4223 | Vsource_directory); | ||
| 4224 | |||
| 4225 | if (NILP (Fmember (tem, Vload_path))) | 4230 | if (NILP (Fmember (tem, Vload_path))) |
| 4226 | Vload_path = Fcons (tem, Vload_path); | 4231 | Vload_path = Fcons (tem, Vload_path); |
| 4232 | } | ||
| 4227 | 4233 | ||
| 4228 | tem = Fexpand_file_name (build_string ("leim"), | 4234 | /* Add site-lisp under the installation dir, if it exists. */ |
| 4229 | Vsource_directory); | 4235 | if (!no_site_lisp) |
| 4236 | { | ||
| 4237 | tem = Fexpand_file_name (build_string ("site-lisp"), | ||
| 4238 | Vinstallation_directory); | ||
| 4239 | tem1 = Ffile_exists_p (tem); | ||
| 4240 | if (!NILP (tem1)) | ||
| 4241 | { | ||
| 4242 | if (NILP (Fmember (tem, Vload_path))) | ||
| 4243 | Vload_path = Fcons (tem, Vload_path); | ||
| 4244 | } | ||
| 4245 | } | ||
| 4230 | 4246 | ||
| 4231 | if (NILP (Fmember (tem, Vload_path))) | 4247 | /* If Emacs was not built in the source directory, |
| 4232 | Vload_path = Fcons (tem, Vload_path); | 4248 | and it is run from where it was built, add to load-path |
| 4249 | the lisp, leim and site-lisp dirs under that directory. */ | ||
| 4233 | 4250 | ||
| 4234 | if (!no_site_lisp) | 4251 | if (NILP (Fequal (Vinstallation_directory, Vsource_directory))) |
| 4252 | { | ||
| 4253 | Lisp_Object tem2; | ||
| 4254 | |||
| 4255 | tem = Fexpand_file_name (build_string ("src/Makefile"), | ||
| 4256 | Vinstallation_directory); | ||
| 4257 | tem1 = Ffile_exists_p (tem); | ||
| 4258 | |||
| 4259 | /* Don't be fooled if they moved the entire source tree | ||
| 4260 | AFTER dumping Emacs. If the build directory is indeed | ||
| 4261 | different from the source dir, src/Makefile.in and | ||
| 4262 | src/Makefile will not be found together. */ | ||
| 4263 | tem = Fexpand_file_name (build_string ("src/Makefile.in"), | ||
| 4264 | Vinstallation_directory); | ||
| 4265 | tem2 = Ffile_exists_p (tem); | ||
| 4266 | if (!NILP (tem1) && NILP (tem2)) | ||
| 4235 | { | 4267 | { |
| 4236 | tem = Fexpand_file_name (build_string ("site-lisp"), | 4268 | tem = Fexpand_file_name (build_string ("lisp"), |
| 4269 | Vsource_directory); | ||
| 4270 | |||
| 4271 | if (NILP (Fmember (tem, Vload_path))) | ||
| 4272 | Vload_path = Fcons (tem, Vload_path); | ||
| 4273 | |||
| 4274 | tem = Fexpand_file_name (build_string ("leim"), | ||
| 4237 | Vsource_directory); | 4275 | Vsource_directory); |
| 4238 | 4276 | ||
| 4239 | if (NILP (Fmember (tem, Vload_path))) | 4277 | if (NILP (Fmember (tem, Vload_path))) |
| 4240 | Vload_path = Fcons (tem, Vload_path); | 4278 | Vload_path = Fcons (tem, Vload_path); |
| 4279 | |||
| 4280 | if (!no_site_lisp) | ||
| 4281 | { | ||
| 4282 | tem = Fexpand_file_name (build_string ("site-lisp"), | ||
| 4283 | Vsource_directory); | ||
| 4284 | |||
| 4285 | if (NILP (Fmember (tem, Vload_path))) | ||
| 4286 | Vload_path = Fcons (tem, Vload_path); | ||
| 4287 | } | ||
| 4241 | } | 4288 | } |
| 4242 | } | 4289 | } /* Vinstallation_directory != Vsource_directory */ |
| 4243 | } | 4290 | } /* if Vinstallation_directory */ |
| 4244 | if (!NILP (sitelisp) && !no_site_lisp) | 4291 | if (!NILP (sitelisp) && !no_site_lisp) |
| 4245 | Vload_path = nconc2 (Fnreverse (sitelisp), Vload_path); | 4292 | Vload_path = nconc2 (Fnreverse (sitelisp), Vload_path); |
| 4246 | } | 4293 | } /* if Vinstallation_directory || no_site_lisp */ |
| 4247 | } | 4294 | } /* if dump_path == Vload_path */ |
| 4248 | } | 4295 | } |
| 4249 | else | 4296 | else /* !initialized */ |
| 4250 | { | 4297 | { |
| 4251 | /* NORMAL refers to the lisp dir in the source directory. */ | 4298 | /* NORMAL refers to the lisp dir in the source directory. */ |
| 4252 | /* We used to add ../lisp at the front here, but | 4299 | /* We used to add ../lisp at the front here, but |
| @@ -4256,7 +4303,7 @@ init_lread (void) | |||
| 4256 | Vload_path = decode_env_path (0, normal); | 4303 | Vload_path = decode_env_path (0, normal); |
| 4257 | dump_path = Vload_path; | 4304 | dump_path = Vload_path; |
| 4258 | } | 4305 | } |
| 4259 | #endif | 4306 | #endif /* CANNOT_DUMP */ |
| 4260 | 4307 | ||
| 4261 | #if (!(defined (WINDOWSNT) || (defined (HAVE_NS)))) | 4308 | #if (!(defined (WINDOWSNT) || (defined (HAVE_NS)))) |
| 4262 | /* When Emacs is invoked over network shares on NT, PATH_LOADSEARCH is | 4309 | /* When Emacs is invoked over network shares on NT, PATH_LOADSEARCH is |
| @@ -4264,6 +4311,8 @@ init_lread (void) | |||
| 4264 | confuses users. Since PATH_LOADSEARCH is always overridden by the | 4311 | confuses users. Since PATH_LOADSEARCH is always overridden by the |
| 4265 | EMACSLOADPATH environment variable below, disable the warning on NT. */ | 4312 | EMACSLOADPATH environment variable below, disable the warning on NT. */ |
| 4266 | 4313 | ||
| 4314 | /* HAVE_NS also uses EMACSLOADPATH. */ | ||
| 4315 | |||
| 4267 | /* Warn if dirs in the *standard* path don't exist. */ | 4316 | /* Warn if dirs in the *standard* path don't exist. */ |
| 4268 | if (!turn_off_warning) | 4317 | if (!turn_off_warning) |
| 4269 | { | 4318 | { |
| @@ -4278,6 +4327,10 @@ init_lread (void) | |||
| 4278 | if (STRINGP (dirfile)) | 4327 | if (STRINGP (dirfile)) |
| 4279 | { | 4328 | { |
| 4280 | dirfile = Fdirectory_file_name (dirfile); | 4329 | dirfile = Fdirectory_file_name (dirfile); |
| 4330 | /* Do we really need to warn about missing site-lisp dirs? | ||
| 4331 | It's true that the installation should have created | ||
| 4332 | them and added subdirs.el, but it's harmless if they | ||
| 4333 | are not there. */ | ||
| 4281 | if (access (SSDATA (dirfile), 0) < 0) | 4334 | if (access (SSDATA (dirfile), 0) < 0) |
| 4282 | dir_warning ("Warning: Lisp directory `%s' does not exist.\n", | 4335 | dir_warning ("Warning: Lisp directory `%s' does not exist.\n", |
| 4283 | XCAR (path_tail)); | 4336 | XCAR (path_tail)); |