unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Please confirm this file-name-directory behavior
@ 2007-09-14 14:31 Mirko
  2007-09-14 15:01 ` Sven Joachim
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Mirko @ 2007-09-14 14:31 UTC (permalink / raw)
  To: help-gnu-emacs

Hi,

I am running Emacs 22.1.1 on Windows XP, and I observe that file-name-
directory does not check whether the actual directory exists.  It just
parses the string argument for the directory & file parts.

I am not complaining about it not checking whether the directory
exists, I just want to confirm that this behavior is by design.

Thanks,

Mirko

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Please confirm this file-name-directory behavior
  2007-09-14 14:31 Please confirm this file-name-directory behavior Mirko
@ 2007-09-14 15:01 ` Sven Joachim
  2007-09-14 15:33 ` Eli Zaretskii
       [not found] ` <mailman.873.1189784002.18990.help-gnu-emacs@gnu.org>
  2 siblings, 0 replies; 6+ messages in thread
From: Sven Joachim @ 2007-09-14 15:01 UTC (permalink / raw)
  To: help-gnu-emacs

Mirko <mvukovic@nycap.rr.com> writes:

> I am running Emacs 22.1.1 on Windows XP, and I observe that file-name-
> directory does not check whether the actual directory exists.  It just
> parses the string argument for the directory & file parts.

That's correct.

> I am not complaining about it not checking whether the directory
> exists, I just want to confirm that this behavior is by design.

It is by design, also in other file-name-* functions.

Sven

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Please confirm this file-name-directory behavior
  2007-09-14 14:31 Please confirm this file-name-directory behavior Mirko
  2007-09-14 15:01 ` Sven Joachim
@ 2007-09-14 15:33 ` Eli Zaretskii
       [not found] ` <mailman.873.1189784002.18990.help-gnu-emacs@gnu.org>
  2 siblings, 0 replies; 6+ messages in thread
From: Eli Zaretskii @ 2007-09-14 15:33 UTC (permalink / raw)
  To: help-gnu-emacs

> From: Mirko <mvukovic@nycap.rr.com>
> Date: Fri, 14 Sep 2007 14:31:24 -0000
> 
> I am running Emacs 22.1.1 on Windows XP, and I observe that file-name-
> directory does not check whether the actual directory exists.  It just
> parses the string argument for the directory & file parts.
> 
> I am not complaining about it not checking whether the directory
> exists, I just want to confirm that this behavior is by design.

It's by design.  file-name-directory is driven by syntax of file
names, not by whether files or directories exist.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Please confirm this file-name-directory behavior
       [not found] ` <mailman.873.1189784002.18990.help-gnu-emacs@gnu.org>
@ 2007-09-15  1:26   ` Barry Margolin
  2007-09-17  2:46     ` Mirko
  0 siblings, 1 reply; 6+ messages in thread
From: Barry Margolin @ 2007-09-15  1:26 UTC (permalink / raw)
  To: help-gnu-emacs

In article <mailman.873.1189784002.18990.help-gnu-emacs@gnu.org>,
 Eli Zaretskii <eliz@gnu.org> wrote:

> > From: Mirko <mvukovic@nycap.rr.com>
> > Date: Fri, 14 Sep 2007 14:31:24 -0000
> > 
> > I am running Emacs 22.1.1 on Windows XP, and I observe that file-name-
> > directory does not check whether the actual directory exists.  It just
> > parses the string argument for the directory & file parts.
> > 
> > I am not complaining about it not checking whether the directory
> > exists, I just want to confirm that this behavior is by design.
> 
> It's by design.  file-name-directory is driven by syntax of file
> names, not by whether files or directories exist.

And it's easy to explain why it works this way.  Suppose you wanted a 
function that creates a file, as well as its directory if necessary.  It 
will call file-name-directory to get the directory name, and then check 
whether the directory exists to determine if it needs to create it.

-- 
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Please confirm this file-name-directory behavior
  2007-09-15  1:26   ` Barry Margolin
@ 2007-09-17  2:46     ` Mirko
  2007-09-17  4:04       ` Eli Zaretskii
  0 siblings, 1 reply; 6+ messages in thread
From: Mirko @ 2007-09-17  2:46 UTC (permalink / raw)
  To: help-gnu-emacs

On Sep 14, 9:26 pm, Barry Margolin <bar...@alum.mit.edu> wrote:
> In article <mailman.873.1189784002.18990.help-gnu-em...@gnu.org>,
>  Eli Zaretskii <e...@gnu.org> wrote:
>
> > > From: Mirko <mvuko...@nycap.rr.com>
> > > Date: Fri, 14 Sep 2007 14:31:24 -0000
>
> > > I am running Emacs 22.1.1 on Windows XP, and I observe that file-name-
> > > directory does not check whether the actual directory exists.  It just
> > > parses the string argument for the directory & file parts.
>
> > > I am not complaining about it not checking whether the directory
> > > exists, I just want to confirm that this behavior is by design.
>
> > It's by design.  file-name-directory is driven by syntax of file
> > names, not by whether files or directories exist.
>
> And it's easy to explain why it works this way.  Suppose you wanted a
> function that creates a file, as well as its directory if necessary.  It
> will call file-name-directory to get the directory name, and then check
> whether the directory exists to determine if it needs to create it.
>
> --
> Barry Margolin, bar...@alum.mit.edu
> Arlington, MA
> *** PLEASE post questions in newsgroups, not directly to me ***
> *** PLEASE don't copy me on replies, I'll read them in the group ***

First, thank you to all who posted.

Continuing, what is the expected behavior if the argument does not end
in a slash, like

(file-name-directory "~/foo/bar/") vs (file-name-directory "~/foo/
bar")

On windows, the first  form returns the full argument, while the
second "~/foo/".  Is that
the expected behavior?

These question stem from a problem I am having with emacs-muse, and I
am trying
to figure out whether this is a consequence of the windows version of
emacs, or
something else.

Thank you very much to all.

Mirko

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Please confirm this file-name-directory behavior
  2007-09-17  2:46     ` Mirko
@ 2007-09-17  4:04       ` Eli Zaretskii
  0 siblings, 0 replies; 6+ messages in thread
From: Eli Zaretskii @ 2007-09-17  4:04 UTC (permalink / raw)
  To: help-gnu-emacs

> From: Mirko <mvukovic@nycap.rr.com>
> Date: Mon, 17 Sep 2007 02:46:12 -0000
> 
> Continuing, what is the expected behavior if the argument does not end
> in a slash, like
> 
> (file-name-directory "~/foo/bar/") vs (file-name-directory "~/foo/
> bar")
> 
> On windows, the first  form returns the full argument, while the
> second "~/foo/".  Is that the expected behavior?

Yes.

The ELisp manual says (in the node that describes
file-name-directory):

       On most systems, the directory part is everything up to and including
    the last slash (backslash is also allowed in input on MS-DOS or
    MS-Windows); the nondirectory part is the rest.

So if the file name ends with a slash, it's treated as a directory.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2007-09-17  4:04 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-09-14 14:31 Please confirm this file-name-directory behavior Mirko
2007-09-14 15:01 ` Sven Joachim
2007-09-14 15:33 ` Eli Zaretskii
     [not found] ` <mailman.873.1189784002.18990.help-gnu-emacs@gnu.org>
2007-09-15  1:26   ` Barry Margolin
2007-09-17  2:46     ` Mirko
2007-09-17  4:04       ` Eli Zaretskii

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).