From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: how having the basename of a file or directory Date: Mon, 31 Jan 2011 14:53:53 -0500 Message-ID: References: <8739o9ilfs.fsf@gmail.com> <877hdl4grd.fsf@uwakimon.sk.tsukuba.ac.jp> <87y661h2ju.fsf@gmail.com> <87y6613ujh.fsf@gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1296504786 14048 80.91.229.12 (31 Jan 2011 20:13:06 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 31 Jan 2011 20:13:06 +0000 (UTC) Cc: "Stephen J. Turnbull" , emacs-devel@gnu.org To: Thierry Volpiatto Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Jan 31 21:13:01 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 1Pk07M-0001h8-8D for ged-emacs-devel@m.gmane.org; Mon, 31 Jan 2011 21:12:56 +0100 Original-Received: from localhost ([127.0.0.1]:33576 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pk07J-0007vX-Vl for ged-emacs-devel@m.gmane.org; Mon, 31 Jan 2011 15:12:54 -0500 Original-Received: from [140.186.70.92] (port=54003 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PjzpO-0008KY-Es for emacs-devel@gnu.org; Mon, 31 Jan 2011 14:54:42 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Pjzox-0006hp-SG for emacs-devel@gnu.org; Mon, 31 Jan 2011 14:54:18 -0500 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.183]:45510 helo=ironport2-out.pppoe.ca) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Pjzox-0006h4-Pi for emacs-devel@gnu.org; Mon, 31 Jan 2011 14:53:55 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvsEAOuhRk1MCpTp/2dsb2JhbACkeHS9cYVOBIUTj2g X-IronPort-AV: E=Sophos;i="4.60,405,1291611600"; d="scan'208";a="89978775" Original-Received: from 76-10-148-233.dsl.teksavvy.com (HELO ceviche.home) ([76.10.148.233]) by ironport2-out.pppoe.ca with ESMTP/TLS/ADH-AES256-SHA; 31 Jan 2011 14:53:54 -0500 Original-Received: by ceviche.home (Postfix, from userid 20848) id B818A660DC; Mon, 31 Jan 2011 14:53:53 -0500 (EST) In-Reply-To: <87y6613ujh.fsf@gmail.com> (Thierry Volpiatto's message of "Mon, 31 Jan 2011 17:30:26 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 206.248.154.183 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:135344 Archived-At: > (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