From: "B. T. Raven" <nihil@nihilo.net>
To: help-gnu-emacs@gnu.org
Subject: Re: elisp function to find pwd
Date: Fri, 14 Nov 2008 17:59:14 -0600 [thread overview]
Message-ID: <h_CdnXYkaOtNjYPUnZ2dnUVZ_tninZ2d@sysmatrix.net> (raw)
In-Reply-To: <51385a0b-b487-4681-9fec-3f6e78a94783@i20g2000prf.googlegroups.com>
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
next prev parent reply other threads:[~2008-11-14 23:59 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-13 9:13 elisp function to find pwd Vijay Lakshminarayanan
2008-11-13 10:06 ` Shaun Johnson
2008-11-13 19:38 ` Nikolaj Schumacher
2008-11-14 23:59 ` B. T. Raven [this message]
2008-11-17 5:14 ` Vijay Lakshminarayanan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=h_CdnXYkaOtNjYPUnZ2dnUVZ_tninZ2d@sysmatrix.net \
--to=nihil@nihilo.net \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).