* bug#12517: 24.2; (file-name-directory "~") returns nil
@ 2012-09-26 2:35 Leo
2012-09-26 7:14 ` Andreas Schwab
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Leo @ 2012-09-26 2:35 UTC (permalink / raw)
To: 12517
I was bitten by this corner case that (file-name-directory "~") returns
nil. I wonder if this is a bug/oversight?
Leo
^ permalink raw reply [flat|nested] 5+ messages in thread
* bug#12517: 24.2; (file-name-directory "~") returns nil
2012-09-26 2:35 bug#12517: 24.2; (file-name-directory "~") returns nil Leo
@ 2012-09-26 7:14 ` Andreas Schwab
2012-09-26 13:05 ` Stefan Monnier
2012-09-26 7:24 ` Eli Zaretskii
2012-09-26 16:26 ` Leo
2 siblings, 1 reply; 5+ messages in thread
From: Andreas Schwab @ 2012-09-26 7:14 UTC (permalink / raw)
To: Leo; +Cc: 12517
Leo <sdl.web@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@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 5+ messages in thread
* bug#12517: 24.2; (file-name-directory "~") returns nil
2012-09-26 2:35 bug#12517: 24.2; (file-name-directory "~") returns nil Leo
2012-09-26 7:14 ` Andreas Schwab
@ 2012-09-26 7:24 ` Eli Zaretskii
2012-09-26 16:26 ` Leo
2 siblings, 0 replies; 5+ messages in thread
From: Eli Zaretskii @ 2012-09-26 7:24 UTC (permalink / raw)
To: Leo; +Cc: 12517
> From: Leo <sdl.web@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.
^ permalink raw reply [flat|nested] 5+ messages in thread
* bug#12517: 24.2; (file-name-directory "~") returns nil
2012-09-26 7:14 ` Andreas Schwab
@ 2012-09-26 13:05 ` Stefan Monnier
0 siblings, 0 replies; 5+ messages in thread
From: Stefan Monnier @ 2012-09-26 13:05 UTC (permalink / raw)
To: Andreas Schwab; +Cc: 12517, Leo
>> 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
^ permalink raw reply [flat|nested] 5+ messages in thread
* bug#12517: 24.2; (file-name-directory "~") returns nil
2012-09-26 2:35 bug#12517: 24.2; (file-name-directory "~") returns nil Leo
2012-09-26 7:14 ` Andreas Schwab
2012-09-26 7:24 ` Eli Zaretskii
@ 2012-09-26 16:26 ` Leo
2 siblings, 0 replies; 5+ messages in thread
From: Leo @ 2012-09-26 16:26 UTC (permalink / raw)
To: 12517-done
Thanks to all for the explanations. Closing.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-09-26 16:26 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-26 2:35 bug#12517: 24.2; (file-name-directory "~") returns nil Leo
2012-09-26 7:14 ` Andreas Schwab
2012-09-26 13:05 ` Stefan Monnier
2012-09-26 7:24 ` Eli Zaretskii
2012-09-26 16:26 ` Leo
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.