GNU bug report logs - #12517
24.2; (file-name-directory "~") returns nil

Previous Next

Package: emacs;

Reported by: Leo <sdl.web <at> gmail.com>

Date: Wed, 26 Sep 2012 02:38:02 UTC

Severity: normal

Found in version 24.2

Done: Leo <sdl.web <at> gmail.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 12517 in the body.
You can then email your comments to 12517 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#12517; Package emacs. (Wed, 26 Sep 2012 02:38:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Leo <sdl.web <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 26 Sep 2012 02:38:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Leo <sdl.web <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.2; (file-name-directory "~") returns nil
Date: Wed, 26 Sep 2012 10:35:10 +0800
I was bitten by this corner case that (file-name-directory "~") returns
nil. I wonder if this is a bug/oversight?

Leo




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#12517; Package emacs. (Wed, 26 Sep 2012 07:15:02 GMT) Full text and rfc822 format available.

Message #8 received at 12517 <at> debbugs.gnu.org (full text, mbox):

From: Andreas Schwab <schwab <at> linux-m68k.org>
To: Leo <sdl.web <at> gmail.com>
Cc: 12517 <at> debbugs.gnu.org
Subject: Re: bug#12517: 24.2; (file-name-directory "~") returns nil
Date: Wed, 26 Sep 2012 09:14:43 +0200
Leo <sdl.web <at> gmail.com> writes:

> I was bitten by this corner case that (file-name-directory "~") returns
> nil. I wonder if this is a bug/oversight?

That's not different from (file-name-directory "a").  The function works
purely textual and does not expand the argument, you have to call
expand-file-name yourself.

Andreas.

-- 
Andreas Schwab, schwab <at> linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#12517; Package emacs. (Wed, 26 Sep 2012 07:25:01 GMT) Full text and rfc822 format available.

Message #11 received at 12517 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Leo <sdl.web <at> gmail.com>
Cc: 12517 <at> debbugs.gnu.org
Subject: Re: bug#12517: 24.2; (file-name-directory "~") returns nil
Date: Wed, 26 Sep 2012 09:24:29 +0200
> From: Leo <sdl.web <at> gmail.com>
> Date: Wed, 26 Sep 2012 10:35:10 +0800
> 
> I was bitten by this corner case that (file-name-directory "~") returns
> nil.

As does (file-name-directory "a").

> I wonder if this is a bug/oversight?

I think it is neither.  file-name-directory works on the syntax of its
argument, not on its semantics.  The ELisp manual says:

 -- Function: file-name-directory filename
     This function returns the directory part of FILENAME, as a
     directory name (*note Directory Names::), or `nil' if FILENAME
     does not include a directory part.

"FILENAME does not include a directory part" means literally that: the
string FILENAME must _include_ a directory part for
file-name-directory to return a non-nil result.

If you want the directory of its argument, even if the argument is
given as any kind of shorthand, run that argument through
expand-file-name first.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#12517; Package emacs. (Wed, 26 Sep 2012 13:06:01 GMT) Full text and rfc822 format available.

Message #14 received at 12517 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Andreas Schwab <schwab <at> linux-m68k.org>
Cc: 12517 <at> debbugs.gnu.org, Leo <sdl.web <at> gmail.com>
Subject: Re: bug#12517: 24.2; (file-name-directory "~") returns nil
Date: Wed, 26 Sep 2012 09:05:48 -0400
>> I was bitten by this corner case that (file-name-directory "~") returns
>> nil. I wonder if this is a bug/oversight?

I don't know if it should be treated as a misfeature, but at least I've
already relies on it in code such as locate-dominating-file, which
I quote:

  ;; Represent /home/luser/foo as ~/foo so that we don't try to look for
  ;; `name' in /home or in /.
  (setq file (abbreviate-file-name file))


-- Stefan




Reply sent to Leo <sdl.web <at> gmail.com>:
You have taken responsibility. (Wed, 26 Sep 2012 16:27:01 GMT) Full text and rfc822 format available.

Notification sent to Leo <sdl.web <at> gmail.com>:
bug acknowledged by developer. (Wed, 26 Sep 2012 16:27:01 GMT) Full text and rfc822 format available.

Message #19 received at 12517-done <at> debbugs.gnu.org (full text, mbox):

From: Leo <sdl.web <at> gmail.com>
To: 12517-done <at> debbugs.gnu.org
Subject: Re: bug#12517: 24.2; (file-name-directory "~") returns nil
Date: Thu, 27 Sep 2012 00:26:35 +0800
Thanks to all for the explanations. Closing.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 25 Oct 2012 11:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 12 years and 245 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.