emacs.exe --load FILE and current directory on w32

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

emacs.exe --load FILE and current directory on w32

Lennart Borgman
Info says that the startup argujment load looks in the current directory
for the file to load. That does not seem to be correct, at least not on w32.


_______________________________________________
Emacs-devel mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/emacs-devel
Reply | Threaded
Open this post in threaded view
|

Re: emacs.exe --load FILE and current directory on w32

Richard Stallman
    Info says that the startup argujment load looks in the current directory
    for the file to load. That does not seem to be correct, at least not on w32.

Would you please provide a complete test case?


_______________________________________________
Emacs-devel mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/emacs-devel
Reply | Threaded
Open this post in threaded view
|

Re: emacs.exe --load FILE and current directory on w32

Lennart Borgman
Richard Stallman wrote:

>    Info says that the startup argujment load looks in the current directory
>    for the file to load. That does not seem to be correct, at least not on w32.
>
>Would you please provide a complete test case?
>
Yes, of course.

*** If we have loadme.el:
(message "I am loaded, thank you!")
**********************

This works:

    emacs.exe -batch -no-site-file -q somefile.txt -l loadme.el
    I am loaded, thank you!

However when  somefile.txt is in another directory then it fails:

    emacs.exe -batch -no-site-file -q ..\somefile.txt -l loadme.el
    Cannot open load file: loadme.el




_______________________________________________
Emacs-devel mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/emacs-devel
Reply | Threaded
Open this post in threaded view
|

Re: emacs.exe --load FILE and current directory on w32

Eli Zaretskii
> Date: Sat, 04 Jun 2005 23:58:24 +0200
> From: Lennart Borgman <[hidden email]>
> Cc: [hidden email]
>
> Richard Stallman wrote:
>
> >    Info says that the startup argujment load looks in the current directory
> >    for the file to load. That does not seem to be correct, at least not on w32.
> >
> >Would you please provide a complete test case?
> >
> Yes, of course.
>
> *** If we have loadme.el:
> (message "I am loaded, thank you!")
> **********************
>
> This works:
>
>     emacs.exe -batch -no-site-file -q somefile.txt -l loadme.el
>     I am loaded, thank you!
>
> However when  somefile.txt is in another directory then it fails:
>
>     emacs.exe -batch -no-site-file -q ..\somefile.txt -l loadme.el
>     Cannot open load file: loadme.el

I get the same behavior on GNU/Linux, both with the current CVS and
with Emacs 21.3.

I think Emacs always behaved like that.  The manual is simplifying a
bit: you will see in startup.el that we try to find the file in the
_default_ directory; if we visited a file before processing -l, that
is no longer the current directory, but rather the directory of the
visited file.  I'm not sure this subtlety needs to be documented,
except, perhaps in a footnote.


_______________________________________________
Emacs-devel mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/emacs-devel
Reply | Threaded
Open this post in threaded view
|

Re: emacs.exe --load FILE and current directory on w32

Lennart Borgman
Eli Zaretskii wrote:

> I get the same behavior on GNU/Linux, both with the current CVS and
>
>with Emacs 21.3.
>
>I think Emacs always behaved like that.  The manual is simplifying a
>bit: you will see in startup.el that we try to find the file in the
>_default_ directory; if we visited a file before processing -l, that
>is no longer the current directory, but rather the directory of the
>visited file.  I'm not sure this subtlety needs to be documented,
>except, perhaps in a footnote.
>
Info says:

`-l FILE'
`--load=FILE'
     Load a Lisp library named FILE with the function `load'.  *Note
     Lisp Libraries::.  If FILE is not an absolute file name, the
     library can be found either in the current directory, or in the
     Emacs library search path as specified with `EMACSLOADPATH' (*note
     General Variables::).

I think "current directory" in this context must mean the current
directory for the program starting Emacs.

I would say that the preffered way to work would be just that. The
current behaviour is unexpected and confusing. load-library does not
search Emacs current directory. Then why should the --load startup
argument do that?

However what is preferred to do in this situation is another thing.
Maybe just change it to something like:

     FILE is not an absolute file name, the library can be found either in
     Emacs current directory, or in the Emacs library search path as
     specified with `EMACSLOADPATH' (*note General Variables::).

     Note: Emacs current directory might be different from the current
     directory in the context where Emacs is invoked. This will be the
     case when for example a file to visit is found before --load on
     the command line.

But I think it is rather ugly and I do not know if it is correct. Must
the file to visit be before --load? This subtle difficulties could be
avoided if the behaviour was changed.


_______________________________________________
Emacs-devel mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/emacs-devel
Reply | Threaded
Open this post in threaded view
|

Re: emacs.exe --load FILE and current directory on w32

Richard Stallman
In reply to this post by Eli Zaretskii
I propose to add this.

*** cmdargs.texi 11 Apr 2005 12:46:09 -0400 1.92
--- cmdargs.texi 05 Jun 2005 08:08:41 -0400
***************
*** 119,124 ****
--- 119,128 ----
  Emacs library search path as specified with @env{EMACSLOADPATH}
  (@pxref{General Variables}).
 
+ @strong{Warning:} If previous command-line arguments have visited
+ files, the current directory is the directory of the last file
+ visited.
+
  @item -L @var{dir}
  @opindex -L
  @itemx --directory=@var{dir}


_______________________________________________
Emacs-devel mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/emacs-devel