aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlan Mackenzie2006-05-24 13:24:21 +0000
committerAlan Mackenzie2006-05-24 13:24:21 +0000
commit6bb6da3ec1732ed5cdd8d5fafd06841b2dc1eaa4 (patch)
tree07180e3b282f27ce4b7ff17adf52eaa6913502b7 /src
parent33d74677e73926286cf179457dacebcea3306418 (diff)
downloademacs-6bb6da3ec1732ed5cdd8d5fafd06841b2dc1eaa4.tar.gz
emacs-6bb6da3ec1732ed5cdd8d5fafd06841b2dc1eaa4.zip
lread.c (Vload_history): Enhance doc-string to say that the file is the
absolute truename of the loaded file. lread.c (Vafter_load_alist): doc-string: state that an element now has a regexp to match file names, not a file name as such. lread.c (readevalloop): Call file-truename on the name for load-history, except at preloading time. lread.c (Fload): At preloading time, preserve the extension of the filename which goes into load-history. New variable hist_file_name. lread.c (Fload): Do eval-after-load stuff by calling the lisp function do-after-load-evaluation.
Diffstat (limited to 'src')
-rw-r--r--src/lread.c70
1 files changed, 48 insertions, 22 deletions
diff --git a/src/lread.c b/src/lread.c
index e80b228e768..31f974d9bc0 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -87,6 +87,7 @@ Lisp_Object Qascii_character, Qload, Qload_file_name;
87Lisp_Object Qbackquote, Qcomma, Qcomma_at, Qcomma_dot, Qfunction; 87Lisp_Object Qbackquote, Qcomma, Qcomma_at, Qcomma_dot, Qfunction;
88Lisp_Object Qinhibit_file_name_operation; 88Lisp_Object Qinhibit_file_name_operation;
89Lisp_Object Qeval_buffer_list, Veval_buffer_list; 89Lisp_Object Qeval_buffer_list, Veval_buffer_list;
90Lisp_Object Qfile_truename, Qdo_after_load_evaluation; /* ACM 2006/5/16 */
90 91
91extern Lisp_Object Qevent_symbol_element_mask; 92extern Lisp_Object Qevent_symbol_element_mask;
92extern Lisp_Object Qfile_exists_p; 93extern Lisp_Object Qfile_exists_p;
@@ -718,8 +719,8 @@ Return t if the file exists and loads successfully. */)
718 register int fd = -1; 719 register int fd = -1;
719 int count = SPECPDL_INDEX (); 720 int count = SPECPDL_INDEX ();
720 Lisp_Object temp; 721 Lisp_Object temp;
721 struct gcpro gcpro1, gcpro2; 722 struct gcpro gcpro1, gcpro2, gcpro3;
722 Lisp_Object found, efound; 723 Lisp_Object found, efound, hist_file_name;
723 /* 1 means we printed the ".el is newer" message. */ 724 /* 1 means we printed the ".el is newer" message. */
724 int newer = 0; 725 int newer = 0;
725 /* 1 means we are loading a compiled file. */ 726 /* 1 means we are loading a compiled file. */
@@ -727,6 +728,7 @@ Return t if the file exists and loads successfully. */)
727 Lisp_Object handler; 728 Lisp_Object handler;
728 int safe_p = 1; 729 int safe_p = 1;
729 char *fmode = "r"; 730 char *fmode = "r";
731 Lisp_Object tmp[2];
730#ifdef DOS_NT 732#ifdef DOS_NT
731 fmode = "rt"; 733 fmode = "rt";
732#endif /* DOS_NT */ 734#endif /* DOS_NT */
@@ -743,7 +745,7 @@ Return t if the file exists and loads successfully. */)
743 the need to gcpro noerror, nomessage and nosuffix. 745 the need to gcpro noerror, nomessage and nosuffix.
744 (Below here, we care only whether they are nil or not.) 746 (Below here, we care only whether they are nil or not.)
745 The presence of this call is the result of a historical accident: 747 The presence of this call is the result of a historical accident:
746 it used to be in every file-operations and when it got removed 748 it used to be in every file-operation and when it got removed
747 everywhere, it accidentally stayed here. Since then, enough people 749 everywhere, it accidentally stayed here. Since then, enough people
748 supposedly have things like (load "$PROJECT/foo.el") in their .emacs 750 supposedly have things like (load "$PROJECT/foo.el") in their .emacs
749 that it seemed risky to remove. */ 751 that it seemed risky to remove. */
@@ -763,7 +765,6 @@ Return t if the file exists and loads successfully. */)
763 if (SCHARS (file) > 0) 765 if (SCHARS (file) > 0)
764 { 766 {
765 int size = SBYTES (file); 767 int size = SBYTES (file);
766 Lisp_Object tmp[2];
767 768
768 found = Qnil; 769 found = Qnil;
769 GCPRO2 (file, found); 770 GCPRO2 (file, found);
@@ -847,6 +848,13 @@ Return t if the file exists and loads successfully. */)
847 Vloads_in_progress = Fcons (found, Vloads_in_progress); 848 Vloads_in_progress = Fcons (found, Vloads_in_progress);
848 } 849 }
849 850
851 /* Get the name for load-history. */
852 hist_file_name = (! NILP (Vpurify_flag)
853 ? Fconcat (2, (tmp[0] = Ffile_name_directory (file),
854 tmp[1] = Ffile_name_nondirectory (found),
855 tmp))
856 : found) ;
857
850 if (!bcmp (SDATA (found) + SBYTES (found) - 4, 858 if (!bcmp (SDATA (found) + SBYTES (found) - 4,
851 ".elc", 4)) 859 ".elc", 4))
852 /* Load .elc files directly, but not when they are 860 /* Load .elc files directly, but not when they are
@@ -857,7 +865,7 @@ Return t if the file exists and loads successfully. */)
857 struct stat s1, s2; 865 struct stat s1, s2;
858 int result; 866 int result;
859 867
860 GCPRO2 (file, found); 868 GCPRO3 (file, found, hist_file_name);
861 869
862 if (!safe_to_load_p (fd)) 870 if (!safe_to_load_p (fd))
863 { 871 {
@@ -911,14 +919,14 @@ Return t if the file exists and loads successfully. */)
911 919
912 if (fd >= 0) 920 if (fd >= 0)
913 emacs_close (fd); 921 emacs_close (fd);
914 val = call4 (Vload_source_file_function, found, file, 922 val = call4 (Vload_source_file_function, found, hist_file_name,
915 NILP (noerror) ? Qnil : Qt, 923 NILP (noerror) ? Qnil : Qt,
916 NILP (nomessage) ? Qnil : Qt); 924 NILP (nomessage) ? Qnil : Qt);
917 return unbind_to (count, val); 925 return unbind_to (count, val);
918 } 926 }
919 } 927 }
920 928
921 GCPRO2 (file, found); 929 GCPRO3 (file, found, hist_file_name);
922 930
923#ifdef WINDOWSNT 931#ifdef WINDOWSNT
924 emacs_close (fd); 932 emacs_close (fd);
@@ -957,14 +965,15 @@ Return t if the file exists and loads successfully. */)
957 load_descriptor_list 965 load_descriptor_list
958 = Fcons (make_number (fileno (stream)), load_descriptor_list); 966 = Fcons (make_number (fileno (stream)), load_descriptor_list);
959 load_in_progress++; 967 load_in_progress++;
960 readevalloop (Qget_file_char, stream, (! NILP (Vpurify_flag) ? file : found), 968 readevalloop (Qget_file_char, stream, hist_file_name,
961 Feval, 0, Qnil, Qnil, Qnil, Qnil); 969 Feval, 0, Qnil, Qnil, Qnil, Qnil);
962 unbind_to (count, Qnil); 970 unbind_to (count, Qnil);
963 971
964 /* Run any load-hooks for this file. */ 972 /* Run any eval-after-load forms for this file */
965 temp = Fassoc (file, Vafter_load_alist); 973 if (NILP (Vpurify_flag)
966 if (!NILP (temp)) 974 && (!NILP (Ffboundp (Qdo_after_load_evaluation))))
967 Fprogn (Fcdr (temp)); 975 call1 (Qdo_after_load_evaluation, hist_file_name) ;
976
968 UNGCPRO; 977 UNGCPRO;
969 978
970 if (saved_doc_string) 979 if (saved_doc_string)
@@ -1391,6 +1400,12 @@ readevalloop (readcharfun, stream, sourcename, evalfun,
1391 1400
1392 GCPRO4 (sourcename, readfun, start, end); 1401 GCPRO4 (sourcename, readfun, start, end);
1393 1402
1403 /* Try to ensure sourcename is a truename, except whilst preloading. */
1404 if (NILP (Vpurify_flag)
1405 && !NILP (sourcename) && Ffile_name_absolute_p (sourcename)
1406 && (!NILP (Ffboundp (Qfile_truename))))
1407 sourcename = call1 (Qfile_truename, sourcename) ;
1408
1394 LOADHIST_ATTACH (sourcename); 1409 LOADHIST_ATTACH (sourcename);
1395 1410
1396 continue_reading_p = 1; 1411 continue_reading_p = 1;
@@ -3971,16 +3986,17 @@ customize `jka-compr-load-suffixes' rather than the present variable. */);
3971 3986
3972 DEFVAR_LISP ("after-load-alist", &Vafter_load_alist, 3987 DEFVAR_LISP ("after-load-alist", &Vafter_load_alist,
3973 doc: /* An alist of expressions to be evalled when particular files are loaded. 3988 doc: /* An alist of expressions to be evalled when particular files are loaded.
3974Each element looks like (FILENAME FORMS...). 3989Each element looks like (REGEXP-OR-FEATURE FORMS...).
3975When `load' is run and the file-name argument is FILENAME, 3990
3976the FORMS in the corresponding element are executed at the end of loading. 3991REGEXP-OR-FEATURE is either a regular expression to match file names, or
3977 3992a symbol \(a feature name).
3978FILENAME must match exactly! Normally FILENAME is the name of a library, 3993
3979with no directory specified, since that is how `load' is normally called. 3994When `load' is run and the file-name argument matches an element's
3980An error in FORMS does not undo the load, 3995REGEXP-OR-FEATURE, or when `provide' is run and provides the symbol
3981but does prevent execution of the rest of the FORMS. 3996REGEXP-OR-FEATURE, the FORMS in the element are executed.
3982FILENAME can also be a symbol (a feature) and FORMS are then executed 3997
3983when the corresponding call to `provide' is made. */); 3998An error in FORMS does not undo the load, but does prevent execution of
3999the rest of the FORMS. */);
3984 Vafter_load_alist = Qnil; 4000 Vafter_load_alist = Qnil;
3985 4001
3986 DEFVAR_LISP ("load-history", &Vload_history, 4002 DEFVAR_LISP ("load-history", &Vload_history,
@@ -3988,6 +4004,10 @@ when the corresponding call to `provide' is made. */);
3988Each alist element is a list that starts with a file name, 4004Each alist element is a list that starts with a file name,
3989except for one element (optional) that starts with nil and describes 4005except for one element (optional) that starts with nil and describes
3990definitions evaluated from buffers not visiting files. 4006definitions evaluated from buffers not visiting files.
4007
4008The file name is absolute and is the true file name (i.e. it doesn't
4009contain symbolic links) of the loaded file.
4010
3991The remaining elements of each list are symbols defined as variables 4011The remaining elements of each list are symbols defined as variables
3992and cons cells of the form `(provide . FEATURE)', `(require . FEATURE)', 4012and cons cells of the form `(provide . FEATURE)', `(require . FEATURE)',
3993`(defun . FUNCTION)', `(autoload . SYMBOL)', and `(t . SYMBOL)'. 4013`(defun . FUNCTION)', `(autoload . SYMBOL)', and `(t . SYMBOL)'.
@@ -4118,6 +4138,12 @@ to load. See also `load-dangerous-libraries'. */);
4118 Qeval_buffer_list = intern ("eval-buffer-list"); 4138 Qeval_buffer_list = intern ("eval-buffer-list");
4119 staticpro (&Qeval_buffer_list); 4139 staticpro (&Qeval_buffer_list);
4120 4140
4141 Qfile_truename = intern ("file-truename");
4142 staticpro (&Qfile_truename) ;
4143
4144 Qdo_after_load_evaluation = intern ("do-after-load-evaluation");
4145 staticpro (&Qdo_after_load_evaluation) ;
4146
4121 staticpro (&dump_path); 4147 staticpro (&dump_path);
4122 4148
4123 staticpro (&read_objects); 4149 staticpro (&read_objects);