unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Get directory name?
@ 2008-08-27 20:38 Lennart Borgman (gmail)
  2008-08-27 20:44 ` Lennart Borgman (gmail)
  2008-08-27 21:06 ` Stefan Monnier
  0 siblings, 2 replies; 4+ messages in thread
From: Lennart Borgman (gmail) @ 2008-08-27 20:38 UTC (permalink / raw)
  To: Emacs Devel

I can't find a good way to get the last directory name from a directory
path using the current functions for file name handling. There must be
some way ...?

file-name-nondirectory does not work for a directory path (or, rather it
returns "" which is not what I want). Maybe there should be a

(defun  directory-last-name (directory)
  "Returns the last name in a directory path.
..."




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

* Re: Get directory name?
  2008-08-27 20:38 Get directory name? Lennart Borgman (gmail)
@ 2008-08-27 20:44 ` Lennart Borgman (gmail)
  2008-08-27 21:06 ` Stefan Monnier
  1 sibling, 0 replies; 4+ messages in thread
From: Lennart Borgman (gmail) @ 2008-08-27 20:44 UTC (permalink / raw)
  To: Emacs Devel

Lennart Borgman (gmail) wrote:
> I can't find a good way to get the last directory name from a directory
> path using the current functions for file name handling. There must be
> some way ...?
> 
> file-name-nondirectory does not work for a directory path (or, rather it
> returns "" which is not what I want). Maybe there should be a
> 
> (defun  directory-last-name (directory)
>   "Returns the last name in a directory path.
> ..."

Some more thoughts: Actually it can be implemented like this

(defun  directory-last-name (directory)
  "Returns the last name in a directory path."
  (file-name-nondirectory
   (expand-file-name "."
                     (file-name-as-directory directory))))

At least that works on w32. Any thoughts on adding this?




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

* Re: Get directory name?
  2008-08-27 20:38 Get directory name? Lennart Borgman (gmail)
  2008-08-27 20:44 ` Lennart Borgman (gmail)
@ 2008-08-27 21:06 ` Stefan Monnier
  2008-08-27 21:08   ` Lennart Borgman (gmail)
  1 sibling, 1 reply; 4+ messages in thread
From: Stefan Monnier @ 2008-08-27 21:06 UTC (permalink / raw)
  To: Lennart Borgman (gmail); +Cc: Emacs Devel

> I can't find a good way to get the last directory name from a directory
> path using the current functions for file name handling. There must be
> some way ...?

> file-name-nondirectory does not work for a directory path (or, rather it
> returns "" which is not what I want). Maybe there should be a

Not sure what "the last directory name from a directory path" means.
Do you mean

  (file-name-nondirectory (directory-file-name DIR))


-- Stefan




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

* Re: Get directory name?
  2008-08-27 21:06 ` Stefan Monnier
@ 2008-08-27 21:08   ` Lennart Borgman (gmail)
  0 siblings, 0 replies; 4+ messages in thread
From: Lennart Borgman (gmail) @ 2008-08-27 21:08 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Emacs Devel

Stefan Monnier wrote:
>> I can't find a good way to get the last directory name from a directory
>> path using the current functions for file name handling. There must be
>> some way ...?
> 
>> file-name-nondirectory does not work for a directory path (or, rather it
>> returns "" which is not what I want). Maybe there should be a
> 
> Not sure what "the last directory name from a directory path" means.
> Do you mean
> 
>   (file-name-nondirectory (directory-file-name DIR))


Ah, yes, thanks.




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

end of thread, other threads:[~2008-08-27 21:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-27 20:38 Get directory name? Lennart Borgman (gmail)
2008-08-27 20:44 ` Lennart Borgman (gmail)
2008-08-27 21:06 ` Stefan Monnier
2008-08-27 21:08   ` Lennart Borgman (gmail)

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).