diff options
| author | Andrea Corallo | 2020-09-01 20:04:00 +0200 |
|---|---|---|
| committer | Andrea Corallo | 2020-09-01 17:58:49 +0200 |
| commit | 3023eb569213a3dd5183640f6e322acd00ea536a (patch) | |
| tree | 3a56bc532a57c6a9ca92663846cf23e0f5c04406 /src | |
| parent | 78e8f991542160239049a50386ced50e456dc5c4 (diff) | |
| download | emacs-3023eb569213a3dd5183640f6e322acd00ea536a.tar.gz emacs-3023eb569213a3dd5183640f6e322acd00ea536a.zip | |
* Fix `load-filename' for installed instance (bug#43089)
* src/lread.c (parent_directory): Remove function as now
unnecessary.
(compute_found_effective): New function.
(Fload): Make use of 'compute_found_effective' and fix
`load-filename' computation.
Diffstat (limited to 'src')
| -rw-r--r-- | src/lread.c | 62 |
1 files changed, 22 insertions, 40 deletions
diff --git a/src/lread.c b/src/lread.c index 80d36f571c2..3c226e0b50c 100644 --- a/src/lread.c +++ b/src/lread.c | |||
| @@ -1099,12 +1099,22 @@ close_infile_unwind (void *arg) | |||
| 1099 | infile = prev_infile; | 1099 | infile = prev_infile; |
| 1100 | } | 1100 | } |
| 1101 | 1101 | ||
| 1102 | static ATTRIBUTE_UNUSED Lisp_Object | 1102 | /* Compute the filename we want in `load-history' and `load-file-name'. */ |
| 1103 | parent_directory (Lisp_Object directory) | 1103 | |
| 1104 | static Lisp_Object | ||
| 1105 | compute_found_effective (Lisp_Object found) | ||
| 1104 | { | 1106 | { |
| 1105 | return Ffile_name_directory (Fsubstring (directory, | 1107 | /* Reconstruct the .elc filename. */ |
| 1106 | make_fixnum (0), | 1108 | Lisp_Object src_name = |
| 1107 | Fsub1 (Flength (directory)))); | 1109 | Fgethash (Ffile_name_nondirectory (found), Vcomp_eln_to_el_h, Qnil); |
| 1110 | |||
| 1111 | if (NILP (src_name)) | ||
| 1112 | /* Manual eln load. */ | ||
| 1113 | return found; | ||
| 1114 | |||
| 1115 | if (suffix_p (src_name, "el.gz")) | ||
| 1116 | src_name = Fsubstring (src_name, make_fixnum (0), make_fixnum (-3)); | ||
| 1117 | return concat2 (src_name, build_string ("c")); | ||
| 1108 | } | 1118 | } |
| 1109 | 1119 | ||
| 1110 | DEFUN ("load", Fload, Sload, 1, 5, 0, | 1120 | DEFUN ("load", Fload, Sload, 1, 5, 0, |
| @@ -1321,30 +1331,15 @@ Return t if the file exists and loads successfully. */) | |||
| 1321 | Vload_source_file_function. */ | 1331 | Vload_source_file_function. */ |
| 1322 | specbind (Qlexical_binding, Qnil); | 1332 | specbind (Qlexical_binding, Qnil); |
| 1323 | 1333 | ||
| 1324 | /* Get the name for load-history. */ | 1334 | Lisp_Object found_eff = |
| 1325 | Lisp_Object found_for_hist; | 1335 | is_native_elisp |
| 1326 | if (is_native_elisp) | 1336 | ? compute_found_effective (found) |
| 1327 | { | 1337 | : found; |
| 1328 | /* Reconstruct the .elc filename. */ | ||
| 1329 | Lisp_Object src_name = Fgethash (Ffile_name_nondirectory (found), | ||
| 1330 | Vcomp_eln_to_el_h, Qnil); | ||
| 1331 | if (NILP (src_name)) | ||
| 1332 | /* Manual eln load. */ | ||
| 1333 | found_for_hist = found; | ||
| 1334 | else | ||
| 1335 | { | ||
| 1336 | if (suffix_p (src_name, "el.gz")) | ||
| 1337 | src_name = Fsubstring (src_name, make_fixnum (0), make_fixnum (-3)); | ||
| 1338 | found_for_hist = concat2 (src_name, build_string ("c")); | ||
| 1339 | } | ||
| 1340 | } | ||
| 1341 | else | ||
| 1342 | found_for_hist = found; | ||
| 1343 | 1338 | ||
| 1344 | hist_file_name = (! NILP (Vpurify_flag) | 1339 | hist_file_name = (! NILP (Vpurify_flag) |
| 1345 | ? concat2 (Ffile_name_directory (file), | 1340 | ? concat2 (Ffile_name_directory (file), |
| 1346 | Ffile_name_nondirectory (found_for_hist)) | 1341 | Ffile_name_nondirectory (found_eff)) |
| 1347 | : found_for_hist); | 1342 | : found_eff); |
| 1348 | 1343 | ||
| 1349 | version = -1; | 1344 | version = -1; |
| 1350 | 1345 | ||
| @@ -1489,20 +1484,7 @@ Return t if the file exists and loads successfully. */) | |||
| 1489 | message_with_string ("Loading %s...", file, 1); | 1484 | message_with_string ("Loading %s...", file, 1); |
| 1490 | } | 1485 | } |
| 1491 | 1486 | ||
| 1492 | if (is_native_elisp) | 1487 | specbind (Qload_file_name, found_eff); |
| 1493 | { | ||
| 1494 | /* Many packages use `load-file-name' as a way to obtain the | ||
| 1495 | package location (see bug#40099). .eln files are not in the | ||
| 1496 | same folder of their respective sources therfore not to break | ||
| 1497 | packages we fake `load-file-name' here. The non faked | ||
| 1498 | version of it is `load-true-file-name'. */ | ||
| 1499 | Lisp_Object el_name = Fgethash (Ffile_name_nondirectory (found), | ||
| 1500 | Vcomp_eln_to_el_h, Qnil); | ||
| 1501 | specbind (Qload_file_name, | ||
| 1502 | NILP (el_name) ? Qnil : concat2 (el_name, build_string ("c"))); | ||
| 1503 | } | ||
| 1504 | else | ||
| 1505 | specbind (Qload_file_name, found); | ||
| 1506 | specbind (Qload_true_file_name, found); | 1488 | specbind (Qload_true_file_name, found); |
| 1507 | specbind (Qinhibit_file_name_operation, Qnil); | 1489 | specbind (Qinhibit_file_name_operation, Qnil); |
| 1508 | specbind (Qload_in_progress, Qt); | 1490 | specbind (Qload_in_progress, Qt); |