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 21:39:49 +0100 Message-ID: <87wrlkbyei.fsf@gmail.com> 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 1296506411 23022 80.91.229.12 (31 Jan 2011 20:40:11 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 31 Jan 2011 20:40:11 +0000 (UTC) Cc: "Stephen J. Turnbull" , emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Jan 31 21:40:05 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 1Pk0XX-0001OK-UJ for ged-emacs-devel@m.gmane.org; Mon, 31 Jan 2011 21:40:00 +0100 Original-Received: from localhost ([127.0.0.1]:59235 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pk0XX-0003Fd-Al for ged-emacs-devel@m.gmane.org; Mon, 31 Jan 2011 15:39:59 -0500 Original-Received: from [140.186.70.92] (port=43543 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pk0XS-0003F7-T8 for emacs-devel@gnu.org; Mon, 31 Jan 2011 15:39:55 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Pk0XQ-00061a-Vq for emacs-devel@gnu.org; Mon, 31 Jan 2011 15:39:54 -0500 Original-Received: from mail-ww0-f49.google.com ([74.125.82.49]:58077) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Pk0XQ-00061M-Rj for emacs-devel@gnu.org; Mon, 31 Jan 2011 15:39:52 -0500 Original-Received: by wwb17 with SMTP id 17so6377525wwb.30 for ; Mon, 31 Jan 2011 12:39:52 -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=c/jBO84Up5J0vJLXOg04p+m/o/iceo/3HRjoOVLo0I4=; b=xGpNXp/pNgl/rdD5uWBSgcIHVjvK5d9cWKwyTEkcSt//UMJCyq7q7MNI03c3GL9znp 9bS8UCxYu+v5R1MOluTMNwhlmIRtTn5/27bx4czpDINiaMN7cPlNp/HzZdUCmP8u+KqS y5tUVlJ6lFa3c4RC1ixly3h03giGu6chU0Cdo= 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=ZfDQzzwvGRX+f4fRXWd/0kqkWM8HdQxkOSWmAoaMSaIWQoMm3xpHnJJFMEHf8vxzLX uzXK+DmrooehcmAVIM/X5nt+38V0ARyBilTyV72leu7KOTm9zkxeGKxh/tHt6irBIwIu iARE3MloWAuWG3SEfVGTG2rdFs6Vgf94ZSMcY= Original-Received: by 10.216.51.208 with SMTP id b58mr11202290wec.8.1296506391923; Mon, 31 Jan 2011 12:39:51 -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 n78sm11006550weq.27.2011.01.31.12.39.50 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 31 Jan 2011 12:39:51 -0800 (PST) In-Reply-To: (Stefan Monnier's message of "Mon, 31 Jan 2011 14:53:53 -0500") 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:135352 Archived-At: Stefan Monnier 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