From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "B. T. Raven" Newsgroups: gmane.emacs.help Subject: Re: elisp function to find pwd Date: Fri, 14 Nov 2008 17:59:14 -0600 Message-ID: References: <51385a0b-b487-4681-9fec-3f6e78a94783@i20g2000prf.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1226709651 14007 80.91.229.12 (15 Nov 2008 00:40:51 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 15 Nov 2008 00:40:51 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Nov 15 01:41:52 2008 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1L19EU-0000Pz-2x for geh-help-gnu-emacs@m.gmane.org; Sat, 15 Nov 2008 01:41:50 +0100 Original-Received: from localhost ([127.0.0.1]:57027 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L19DL-0005Zu-RK for geh-help-gnu-emacs@m.gmane.org; Fri, 14 Nov 2008 19:40:39 -0500 Original-Path: news.stanford.edu!newsfeed.stanford.edu!postnews.google.com!news1.google.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local02.nntp.dca.giganews.com!nntp.sysmatrix.net!news.sysmatrix.net.POSTED!not-for-mail Original-NNTP-Posting-Date: Fri, 14 Nov 2008 17:59:12 -0600 User-Agent: Thunderbird 2.0.0.17 (Windows/20080914) Original-Newsgroups: gnu.emacs.help In-Reply-To: <51385a0b-b487-4681-9fec-3f6e78a94783@i20g2000prf.googlegroups.com> Original-Lines: 45 X-Usenet-Provider: http://www.giganews.com Original-NNTP-Posting-Host: 65.45.140.41 Original-X-Trace: sv3-isqRu4rQBJXN2NZQUTvvXRuimtp0WGdieWV1NNyrgiQOtgKagS7udQYgEZ31OYQ8VGJW8gVGEdD3uVM!QkL6DPmIAQlm7j/0CtEgXrySPieSXeScnfQ5A172Dq9Pz1oLdk44H8IFYL3u6xneSElLAx5RBGwT!XhTuNt0yHViDPqpoMbSW5w0L8ATCSQ== Original-X-Complaints-To: abuse@sysmatrix.net X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.39 Original-Xref: news.stanford.edu gnu.emacs.help:164471 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:59803 Archived-At: Vijay Lakshminarayanan wrote: > Hi > > I'd like to know if there exists a simple elisp function that I can > call and just get the present working directory. > > I tried (pwd) but it gives a prefix. For example: > > (pwd) > "Directory C:\\emacs-22.2\\bin/" > > Which prefixes "Directory" to the result. I could just strip that bit > out but I'd like to know if there's an easier way. > > Another hack I tried is: > > (defun get-pwd-hack () > (let* ((buffer-name (buffer-name)) > (buffer-file-name (buffer-file-name)) > (bnl (length buffer-name)) > (bfnl (length buffer-file-name))) > (substring buffer-file-name 0 (- bfnl (1+ bnl))))) > > Which will fail if I'm in, say, the *scratch* buffer. > > Thanks > Vijay Why not just: (substring (pwd) 10) which happens to yield "C:\\mydocu~1/" on my system (i.e. (pwd) without the prefix). Also works in *scratch*. Why is this not "easier?" Ed