emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: how having the basename of a file or directory


From: Stefan Monnier
Subject: Re: how having the basename of a file or directory
Date: Mon, 31 Jan 2011 14:53:53 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

> (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.
It should be

  (defun file-basename (file)
    (file-name-nondirectory (directory-file-name file)))


-- Stefan



reply via email to

[Prev in Thread] Current Thread [Next in Thread]