From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Thierry Volpiatto Newsgroups: gmane.emacs.devel Subject: Re: how having the basename of a file or directory Date: Mon, 31 Jan 2011 09:59:01 +0100 Message-ID: <87y661h2ju.fsf@gmail.com> References: <8739o9ilfs.fsf@gmail.com> <877hdl4grd.fsf@uwakimon.sk.tsukuba.ac.jp> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1296464367 17603 80.91.229.12 (31 Jan 2011 08:59:27 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 31 Jan 2011 08:59:27 +0000 (UTC) Cc: emacs-devel@gnu.org To: "Stephen J. Turnbull" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Jan 31 09:59:20 2011 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PjpbU-0005es-MN for ged-emacs-devel@m.gmane.org; Mon, 31 Jan 2011 09:59:20 +0100 Original-Received: from localhost ([127.0.0.1]:41672 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PjpbT-0004Xj-K3 for ged-emacs-devel@m.gmane.org; Mon, 31 Jan 2011 03:59:19 -0500 Original-Received: from [140.186.70.92] (port=39890 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PjpbK-0004Ws-AI for emacs-devel@gnu.org; Mon, 31 Jan 2011 03:59:16 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PjpbG-0005Te-Sv for emacs-devel@gnu.org; Mon, 31 Jan 2011 03:59:10 -0500 Original-Received: from mail-ww0-f49.google.com ([74.125.82.49]:35015) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PjpbG-0005Sl-Oh for emacs-devel@gnu.org; Mon, 31 Jan 2011 03:59:06 -0500 Original-Received: by wwb17 with SMTP id 17so5692086wwb.30 for ; Mon, 31 Jan 2011 00:59:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-type; bh=AHmmj7W3+ZbgdPJT+ppyi8UzY0fvXUqJTbuXO/3Sxlo=; b=U+2PVb4Xf6Rk4CRzgBZm9kF28eL5KAg5BycvPsL7+6yiiZfeRFP4ZDGKBNSZfbd355 vdS8SycuXg9yr0s9DdBD1YoNkj2Ge2b7kXu/my+R7LBERZ/vO/QY28AQ8L6UkvLqFX7J 8xqyxIPJtHRnbBShj8K8Vtsttj7OYIgDJiGkk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type; b=HjlYHdyLkKyNoYcBhAowMFftJFSRRuTglxRw4grskzb6hmhOH2ngG2AQ8GyjuwEiHG 5wGKeMPEWBGLmphZvrhIuvjKO5Y3eJh/Eoz8fUHa3RD9dL7A+TgeF8xXA/fLndJkqheG ZPqkFY6YYJS7dbcrSYS9OwqHptEIOOAf+jLHk= Original-Received: by 10.227.2.198 with SMTP id 6mr5793633wbk.74.1296464344866; Mon, 31 Jan 2011 00:59:04 -0800 (PST) Original-Received: from thierry-MM061 (63.211.85-79.rev.gaoland.net [79.85.211.63]) by mx.google.com with ESMTPS id u9sm4882924wbg.6.2011.01.31.00.59.02 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 31 Jan 2011 00:59:03 -0800 (PST) In-Reply-To: <877hdl4grd.fsf@uwakimon.sk.tsukuba.ac.jp> (Stephen J. Turnbull's message of "Mon, 31 Jan 2011 17:30:30 +0900") User-Agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.2.92 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 74.125.82.49 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:135281 Archived-At: Hi Stephen, "Stephen J. Turnbull" writes: > Thierry Volpiatto writes: > > > (defun basename (fname) > > (if (file-directory-p fname) > > (let ((dirname (directory-file-name fname))) > > (file-relative-name > > dirname (file-name-directory dirname))) > > (file-name-nondirectory fname))) > > (file-name-nondirectory (directory-file-name PATH)) > > should work (modulo I'm testing in XEmacs, but I can't imagine that we > differ in this respect). Yes thanks, that's work too, but it would be nice to do not have to take care of that: (file-name-nondirectory "path/to/a/directory") should return ==> directory (file-name-nondirectory "path/to/a/file") should return ==> file So modifying `file-name-nondirectory' or creating a basename function or macro like: (defun basename (fname) (if (file-directory-p fname) (let ((dirname (directory-file-name fname))) (file-name-nondirectory dirname)) (file-name-nondirectory fname))) would be nice. -- A+ Thierry Get my Gnupg key: gpg --keyserver pgp.mit.edu --recv-keys 59F29997