From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Drew Adams" Newsgroups: gmane.emacs.help Subject: RE: filter from find-dired Date: Mon, 14 Jan 2013 09:50:21 -0800 Message-ID: <581F4AB161744C9893141A0547AD64E4@us.oracle.com> References: <23721201.139161358184410041.JavaMail.defaultUser@defaultHost> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1358185839 17448 80.91.229.3 (14 Jan 2013 17:50:39 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 14 Jan 2013 17:50:39 +0000 (UTC) To: , Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Jan 14 18:50:57 2013 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1TuoBN-0007Hk-GO for geh-help-gnu-emacs@m.gmane.org; Mon, 14 Jan 2013 18:50:49 +0100 Original-Received: from localhost ([::1]:32849 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TuoB7-0006iH-7N for geh-help-gnu-emacs@m.gmane.org; Mon, 14 Jan 2013 12:50:33 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:40550) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TuoB1-0006hl-VP for help-gnu-emacs@gnu.org; Mon, 14 Jan 2013 12:50:28 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TuoB0-0000KL-HZ for help-gnu-emacs@gnu.org; Mon, 14 Jan 2013 12:50:27 -0500 Original-Received: from userp1040.oracle.com ([156.151.31.81]:34854) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TuoB0-0000Iz-Ar for help-gnu-emacs@gnu.org; Mon, 14 Jan 2013 12:50:26 -0500 Original-Received: from acsinet22.oracle.com (acsinet22.oracle.com [141.146.126.238]) by userp1040.oracle.com (Sentrion-MTA-4.2.2/Sentrion-MTA-4.2.2) with ESMTP id r0EHoNKe021943 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 14 Jan 2013 17:50:24 GMT Original-Received: from acsmt356.oracle.com (acsmt356.oracle.com [141.146.40.156]) by acsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r0EHoNR8025961 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 14 Jan 2013 17:50:23 GMT Original-Received: from abhmt101.oracle.com (abhmt101.oracle.com [141.146.116.53]) by acsmt356.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id r0EHoMmk019382; Mon, 14 Jan 2013 11:50:22 -0600 Original-Received: from dradamslap1 (/130.35.178.8) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 14 Jan 2013 09:50:22 -0800 X-Mailer: Microsoft Office Outlook 11 In-Reply-To: <23721201.139161358184410041.JavaMail.defaultUser@defaultHost> Thread-Index: Ac3yfGGL6st4HaXBQkmh8taMJNRuwAAAf3mA X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 X-Source-IP: acsinet22.oracle.com [141.146.126.238] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 156.151.31.81 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:88611 Archived-At: > get-directory-name is my function too. Glad to receive suggestions on > how to improve it. > > (defun get-directory-name () > "return the current directory" > (interactive) > (let (dirname components) > (if (null (buffer-file-name (current-buffer))) > (setq dirname (expand-file-name default-directory)) > (setq components (butlast (split-string (get-file-name) "/"))) > (setq dirname (mapconcat 'identity components "/"))) > (message dirname) > (kill-new dirname) > dirname)) Not sure what you are trying to do. You don't show `get-file-name', for one thing, so your code cannot be evaluated by someone trying to help. If you are trying to get the (non-)directory component of an absolute file name, consider using `file-name-(non)directory'. When you ask for improvement suggestions, I recommend that you start by saying what your code is intended to do. Sometimes a completely different implementation might be suggested, but only if someone can tell what you are really trying to do. Looking at just your doc string (which might be inaccurate), it would seem that all you need is `default-directory'. That _is_ "the current directory". If you need that added to the kill buffer, then (kill-new default-directory) should be adequate.