From: Thierry Volpiatto <thierry.volpiatto@gmail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: "Stephen J. Turnbull" <stephen@xemacs.org>, emacs-devel@gnu.org
Subject: Re: how having the basename of a file or directory
Date: Mon, 31 Jan 2011 21:39:49 +0100 [thread overview]
Message-ID: <87wrlkbyei.fsf@gmail.com> (raw)
In-Reply-To: <jwvaaig97il.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Mon, 31 Jan 2011 14:53:53 -0500")
Stefan Monnier <monnier@iro.umontreal.ca> writes:
>> (defun basename (fname)
>> (if (or (file-directory-p fname)
>> (string-match "/$" fname))
>> (let ((dirname (directory-file-name fname)))
>> (file-name-nondirectory dirname))
>> (file-name-nondirectory fname)))
>
> If, as Karl suggests, your point is that you want a `basename' function,
> then maybe we could add such a function (I'm really not convinced it's
> worth the trouble. Better would be to add a paragraph in the manual,
> I think), but I still insist that the above definition is wrong.
The above definition is not wrong, but it have unneeded code.
However the unneeded code explain clearly what happen.
> It should be
>
> (defun file-basename (file)
> (file-name-nondirectory (directory-file-name file)))
Yes.
Because the name of this function (i.e directory-file-name), i didn't think
to call it on a filename, but it return the filename yes.
Maybe confusion with file-name-directory.
(always need to look manual when using all these file-name-*,
directory-file-* etc... functions)
Adding a basename function is just a first step to simplify all that.
--
A+ Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997
next prev parent reply other threads:[~2011-01-31 20:39 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-31 7:25 how having the basename of a file or directory Thierry Volpiatto
2011-01-31 8:30 ` Stephen J. Turnbull
2011-01-31 8:59 ` Thierry Volpiatto
2011-01-31 10:28 ` Andreas Schwab
2011-01-31 11:03 ` Thierry Volpiatto
2011-01-31 12:07 ` Andreas Schwab
2011-01-31 12:19 ` Thierry Volpiatto
2011-01-31 12:53 ` Andreas Schwab
2011-01-31 15:29 ` Stefan Monnier
2011-01-31 16:30 ` Thierry Volpiatto
2011-01-31 16:43 ` Karl Fogel
2011-01-31 19:53 ` Stefan Monnier
2011-01-31 20:39 ` Thierry Volpiatto [this message]
2011-02-01 11:55 ` Stephen J. Turnbull
2011-02-01 15:37 ` Karl Fogel
2011-02-01 16:26 ` Stephen J. Turnbull
2011-02-01 16:52 ` Karl Fogel
2011-02-02 12:27 ` Stephen J. Turnbull
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87wrlkbyei.fsf@gmail.com \
--to=thierry.volpiatto@gmail.com \
--cc=emacs-devel@gnu.org \
--cc=monnier@iro.umontreal.ca \
--cc=stephen@xemacs.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
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).