aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLuc Teirlinck2006-02-27 02:04:35 +0000
committerLuc Teirlinck2006-02-27 02:04:35 +0000
commit971a4293be26ffbe31f422d72efeffeb827a54dd (patch)
tree880f8c02ddcd5806f34c6f67837447e4498fecba /src
parentf352b9d7735eb10f2c604aa9ba0bc8f8ee964d1b (diff)
downloademacs-971a4293be26ffbe31f422d72efeffeb827a54dd.tar.gz
emacs-971a4293be26ffbe31f422d72efeffeb827a54dd.zip
Declare Vload_file_rep_suffixes instead of
deleted variable default_suffixes. (Fget_load_suffixes): New function. (Fload): Use Fget_load_suffixes and Vload_file_rep_suffixes. No longer use deleted variable default_suffixes. Update docstring. (syms_of_lread): defsubr Sget_load_suffixes. Expand `load-suffixes' docstring. Delete default_suffixes and DEFVAR_LISP the new variable `load-file-rep-suffixes'.
Diffstat (limited to 'src')
-rw-r--r--src/lread.c87
1 files changed, 69 insertions, 18 deletions
diff --git a/src/lread.c b/src/lread.c
index 3b100d80e4d..892c102c58f 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -98,7 +98,7 @@ int load_in_progress;
98Lisp_Object Vsource_directory; 98Lisp_Object Vsource_directory;
99 99
100/* Search path and suffixes for files to be loaded. */ 100/* Search path and suffixes for files to be loaded. */
101Lisp_Object Vload_path, Vload_suffixes, default_suffixes; 101Lisp_Object Vload_path, Vload_suffixes, Vload_file_rep_suffixes;
102 102
103/* File name of user's init file. */ 103/* File name of user's init file. */
104Lisp_Object Vuser_init_file; 104Lisp_Object Vuser_init_file;
@@ -653,28 +653,64 @@ load_error_handler (data)
653 return Qnil; 653 return Qnil;
654} 654}
655 655
656DEFUN ("get-load-suffixes", Fget_load_suffixes, Sget_load_suffixes, 0, 0, 0,
657 doc: /* Return the suffixes that `load' should try if a suffix is \
658required.
659This uses the variables `load-suffixes' and `load-file-rep-suffixes'. */)
660 ()
661{
662 Lisp_Object lst = Qnil, suffixes = Vload_suffixes, suffix, ext;
663 while (CONSP (suffixes))
664 {
665 Lisp_Object exts = Vload_file_rep_suffixes;
666 suffix = XCAR (suffixes);
667 suffixes = XCDR (suffixes);
668 while (CONSP (exts))
669 {
670 ext = XCAR (exts);
671 exts = XCDR (exts);
672 lst = Fcons (concat2 (suffix, ext), lst);
673 }
674 }
675 return Fnreverse (lst);
676}
677
656DEFUN ("load", Fload, Sload, 1, 5, 0, 678DEFUN ("load", Fload, Sload, 1, 5, 0,
657 doc: /* Execute a file of Lisp code named FILE. 679 doc: /* Execute a file of Lisp code named FILE.
658First try FILE with `.elc' appended, then try with `.el', 680First try FILE with `.elc' appended, then try with `.el',
659 then try FILE unmodified (the exact suffixes are determined by 681then try FILE unmodified (the exact suffixes in the exact order are
660`load-suffixes'). Environment variable references in FILE 682determined by `load-suffixes'). Environment variable references in
661 are replaced with their values by calling `substitute-in-file-name'. 683FILE are replaced with their values by calling `substitute-in-file-name'.
662This function searches the directories in `load-path'. 684This function searches the directories in `load-path'.
685
663If optional second arg NOERROR is non-nil, 686If optional second arg NOERROR is non-nil,
664 report no error if FILE doesn't exist. 687report no error if FILE doesn't exist.
665Print messages at start and end of loading unless 688Print messages at start and end of loading unless
666 optional third arg NOMESSAGE is non-nil. 689optional third arg NOMESSAGE is non-nil.
667If optional fourth arg NOSUFFIX is non-nil, don't try adding 690If optional fourth arg NOSUFFIX is non-nil, don't try adding
668 suffixes `.elc' or `.el' to the specified name FILE. 691suffixes `.elc' or `.el' to the specified name FILE.
669If optional fifth arg MUST-SUFFIX is non-nil, insist on 692If optional fifth arg MUST-SUFFIX is non-nil, insist on
670 the suffix `.elc' or `.el'; don't accept just FILE unless 693the suffix `.elc' or `.el'; don't accept just FILE unless
671 it ends in one of those suffixes or includes a directory name. 694it ends in one of those suffixes or includes a directory name.
695
696If this function fails to find a file, it may look for different
697representations of that file before trying another file.
698It does so by adding the non-empty suffixes in `load-file-rep-suffixes'
699to the file name. Emacs uses this feature mainly to find compressed
700versions of files when Auto Compression mode is enabled.
701
702The exact suffixes that this function tries out, in the exact order,
703are given by the value of the variable `load-file-rep-suffixes' if
704NOSUFFIX is non-nil and by the return value of the function
705`get-load-suffixes' if MUST-SUFFIX is non-nil. If both NOSUFFIX and
706MUST-SUFFIX are nil, this function first tries out the latter suffixes
707and then the former.
672 708
673Loading a file records its definitions, and its `provide' and 709Loading a file records its definitions, and its `provide' and
674`require' calls, in an element of `load-history' whose 710`require' calls, in an element of `load-history' whose
675car is the file name loaded. See `load-history'. 711car is the file name loaded. See `load-history'.
676 712
677Return t if file exists. */) 713Return t if the file exists and loads successfully. */)
678 (file, noerror, nomessage, nosuffix, must_suffix) 714 (file, noerror, nomessage, nosuffix, must_suffix)
679 Lisp_Object file, noerror, nomessage, nosuffix, must_suffix; 715 Lisp_Object file, noerror, nomessage, nosuffix, must_suffix;
680{ 716{
@@ -749,9 +785,9 @@ Return t if file exists. */)
749 785
750 fd = openp (Vload_path, file, 786 fd = openp (Vload_path, file,
751 (!NILP (nosuffix) ? Qnil 787 (!NILP (nosuffix) ? Qnil
752 : !NILP (must_suffix) ? Vload_suffixes 788 : !NILP (must_suffix) ? Fget_load_suffixes ()
753 : Fappend (2, (tmp[0] = Vload_suffixes, 789 : Fappend (2, (tmp[0] = Fget_load_suffixes (),
754 tmp[1] = default_suffixes, 790 tmp[1] = Vload_file_rep_suffixes,
755 tmp))), 791 tmp))),
756 &found, Qnil); 792 &found, Qnil);
757 UNGCPRO; 793 UNGCPRO;
@@ -1109,7 +1145,7 @@ openp (path, str, suffixes, storeptr, predicate)
1109 fn = (char *) alloca (fn_size = 100 + want_size); 1145 fn = (char *) alloca (fn_size = 100 + want_size);
1110 1146
1111 /* Loop over suffixes. */ 1147 /* Loop over suffixes. */
1112 for (tail = NILP (suffixes) ? default_suffixes : suffixes; 1148 for (tail = NILP (suffixes) ? Fcons (build_string (""), Qnil) : suffixes;
1113 CONSP (tail); tail = XCDR (tail)) 1149 CONSP (tail); tail = XCDR (tail))
1114 { 1150 {
1115 int lsuffix = SBYTES (XCAR (tail)); 1151 int lsuffix = SBYTES (XCAR (tail));
@@ -3840,6 +3876,7 @@ syms_of_lread ()
3840 defsubr (&Sintern); 3876 defsubr (&Sintern);
3841 defsubr (&Sintern_soft); 3877 defsubr (&Sintern_soft);
3842 defsubr (&Sunintern); 3878 defsubr (&Sunintern);
3879 defsubr (&Sget_load_suffixes);
3843 defsubr (&Sload); 3880 defsubr (&Sload);
3844 defsubr (&Seval_buffer); 3881 defsubr (&Seval_buffer);
3845 defsubr (&Seval_region); 3882 defsubr (&Seval_region);
@@ -3901,13 +3938,27 @@ Initialized based on EMACSLOADPATH environment variable, if any,
3901otherwise to default specified by file `epaths.h' when Emacs was built. */); 3938otherwise to default specified by file `epaths.h' when Emacs was built. */);
3902 3939
3903 DEFVAR_LISP ("load-suffixes", &Vload_suffixes, 3940 DEFVAR_LISP ("load-suffixes", &Vload_suffixes,
3904 doc: /* *List of suffixes to try for files to load. 3941 doc: /* List of suffixes for (compiled or source) Emacs Lisp files.
3905This list should not include the empty string. */); 3942This list should not include the empty string.
3943`load' and related functions try to append these suffixes, in order,
3944to the specified file name if a Lisp suffix is allowed or required. */);
3906 Vload_suffixes = Fcons (build_string (".elc"), 3945 Vload_suffixes = Fcons (build_string (".elc"),
3907 Fcons (build_string (".el"), Qnil)); 3946 Fcons (build_string (".el"), Qnil));
3947 DEFVAR_LISP ("load-file-rep-suffixes", &Vload_file_rep_suffixes,
3948 doc: /* List of suffixes that indicate representations of \
3949the same file.
3950This list should normally start with the empty string.
3951
3952Enabling Auto Compression mode appends the suffixes in
3953`jka-compr-load-suffixes' to this list and disabling Auto Compression
3954mode removes them again. `load' and related functions use this list to
3955determine whether they should look for compressed versions of a file
3956and, if so, which suffixes they should try to append to the file name
3957in order to do so. However, if you want to customize which suffixes
3958the loading functions recognize as compression suffixes, you should
3959customize `jka-compr-load-suffixes' rather than the present variable. */);
3908 /* We don't use empty_string because it's not initialized yet. */ 3960 /* We don't use empty_string because it's not initialized yet. */
3909 default_suffixes = Fcons (build_string (""), Qnil); 3961 Vload_file_rep_suffixes = Fcons (build_string (""), Qnil);
3910 staticpro (&default_suffixes);
3911 3962
3912 DEFVAR_BOOL ("load-in-progress", &load_in_progress, 3963 DEFVAR_BOOL ("load-in-progress", &load_in_progress,
3913 doc: /* Non-nil iff inside of `load'. */); 3964 doc: /* Non-nil iff inside of `load'. */);