[net.emacs] Loading CCAEmacs .elisp_init

martillo@mit-athena.ARPA (Joaquim Martillo) (12/06/84)

A few weeks ago, a fix to get CCAEmacs to load in the  .elisp_init  file
was  posted  to  net.emacs.  The fix only worked if the .elisp_init file
was linked to .elisp_init.l.  If the function stream_given_loadstring is
altered  so  that the code looks something like this, emacs will load in
the .elisp_init file without a link to .elisp_init.l.  In fact,  if  the
full  path  name to a file is fiven, any elisp file could be loaded even
if its name does not terminate in .l.


	if (is_full_pathname(name))
	{ 
		searchlist = ads_cons_protect(Null_String,Nil_Symbol);
		Pop_Elisp_Val;
		goto no_extension;
	} 
	else { 
		searchlist = ads_cons_protect(Null_String,searchlist);  
		Pop_Elisp_Val;
	}  
	

	/* find out whether the filename already has the proper extension */
	/* attached.  If so we set extension to "" */

	acq_sinfo(name,&schars,&slen);
	acq_sinfo(extension,&echars,&elen);

	if (elen >= slen) {
		goto ok_extension;
	}   
	while (elen > 0) {
		if (echars[--elen] != schars[--slen]) { 
			goto ok_extension;
		}   
	}
#if DEBUG    
	fprintf(dbgfp,"Setting extension to blank\n");    
#endif DEBUG    
no_extension:
	extension = Null_String;

ok_extension :

martillo@mit-athena.ARPA (Joaquim Martillo) (12/06/84)

stream_given_loadstring is in bio.c.

massar@godot.UUCP (J.P. Massar) (12/07/84)

In article <59@mit-athena.ARPA> version B 2.10.2 9/17/84; site godot.UUCP version B 2.10.1 6/24/83; site mit-athena.ARPA godot!mit-eddie!genrad!decvax!mit-athena!martillo martillo@mit-athena.ARPA (Joaquim Martillo) writes:
>A few weeks ago, a fix to get CCAEmacs to load in the  .elisp_init  file
>was  posted  to  net.emacs.  The fix only worked if the .elisp_init file
>was linked to .elisp_init.l.  If the function stream_given_loadstring is
>altered  so  that the code looks something like this, emacs will load in
>the .elisp_init file without a link to .elisp_init.l.  In fact,  if  the
>full  path  name to a file is fiven, any elisp file could be loaded even
>if its name does not terminate in .l.
>
>
>	if (is_full_pathname(name))
>	{ 
>		searchlist = ads_cons_protect(Null_String,Nil_Symbol);
>		Pop_Elisp_Val;
>		goto no_extension;
>	} 
>	else { 
>		searchlist = ads_cons_protect(Null_String,searchlist);  
>		Pop_Elisp_Val;
>	}  
>	
>
>	/* find out whether the filename already has the proper extension */
>	/* attached.  If so we set extension to "" */
>
>	acq_sinfo(name,&schars,&slen);
>	acq_sinfo(extension,&echars,&elen);
>
>	if (elen >= slen) {
>		goto ok_extension;
>	}   
>	while (elen > 0) {
>		if (echars[--elen] != schars[--slen]) { 
>			goto ok_extension;
>		}   
>	}
>#if DEBUG    
>	fprintf(dbgfp,"Setting extension to blank\n");    
>#endif DEBUG    
>no_extension:
>	extension = Null_String;
>
>ok_extension :


I am the author of Elisp.

This fix renders invalid the documentation in the Elisp manual, page 1-25.
(Section 1.23.4 Loading Files)

As I see it, the problem is not that one wants to be able to load
.elisp_init, it is that the Emacs documentation is wrong in that the
file should be called .elisp_init.l .

By causing different behavior when a full pathname is given versus when
a filename is given (where Elisp assumes the current working directory)
leads to confusion in my mind.

The current way to load an arbitrary file (which you generally don't want
to do a lot anyway) is:

(let ((temp *lisp-extension*))
     (unwind-protect 
             (progn (setq *lisp-extension* "")
                    (load <myfile>))
             (setq *lisp-extension* temp)))

which could easily be subroutine-ized.

Another algorithm might be to have Elisp look for <myfile> if <myfile.l>
does not exist.  But should it first scan all the directories in
*LOAD-PATHNAMES* for <myfile.l>?

Caveat emptor:  There is no guarentee that this or any other bug fix /
documentation fix will be incorporated into the next CCA Emacs release.

JP Massar
ihnp4!godot!massar
massar@cca-unix

martillo@mit-athena.ARPA (Joaquim Martillo) (12/09/84)

Another  possibility for fixing the problem and still allowing extension
for full pathname files would be to do an rindex to the last  /  in  the
path  and then do a strcmp whether the filename was .elisp_init.  If the
last path-element is .elisp_init, then the goto to no_extension could be
executed.   Then  pathname  extension works for all full path name files
except .elisp_init.  The argument sounds theological, no other  emacs  .
file has an extension (eg .emacs_vars, .emacs_init .emacs_keys).  If the
documentation is wrong, then emacs should be changed because emacs  only
tries  to  load  .elisp_init  and  not .elisp_init.l.  Perhaps Zimmerman
would like to comment.

martillo@mit-athena.ARPA (Joaquim Martillo) (12/09/84)

The necessary code so that the full path-name files can be properly
extended and the .elisp_init file can be loaded without the extension is

	if(!strcmp(rindex(Get_string_chars(name, '/')), "/.elisp_init"))
	{
		goto no_extension;
	}

.

This would substitute for the unconditional goto in my original fix.

Without either flavor of goto no_extension, but with the previously posted
load fix emacs would try to load .elisp_init and elisp would load 
.elisp_init.l.  I think there would be no need without the changes I
suggested to have a .elisp_init file.  Actually, I prefer Massars's
documentation change.  CCAEmacs has too many strcmp's as it is.