help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to make Emacs paths in the minibuffer start at root (/) instead


From: Joost Kremers
Subject: Re: How to make Emacs paths in the minibuffer start at root (/) instead of $HOME (~)?
Date: 26 Mar 2014 01:23:18 GMT
User-agent: slrn/pre1.0.0-18 (Linux)

Christopher Howard wrote:
> I'm not a guru, but I would think you could get a similiar result
> writing an interactive lisp function. Just looking at the docs, I was
> thinking
>
> (expand-file-name (pwd))
>
> with a function around that to save it for pasting. Only problem is
> that, apparently, the `pwd' function includes other junk in the string
> along with the expanded file name. Any thoughts from the real
> gurus...?

Well, `pwd' really only does

(message "Directory %s" default-directory)

so 

(expand-file-name default-directory)

should do the trick.

Putting it in the kill ring (which should normally make it available for
pasting outside Emacs) is not difficult either:

(kill-new (expand-file-name default-directory))

Wrap it in an interactive function:

(defun my-copy-pwd ()
  "Copy the current directory to the kill ring."
  (interactive)
  (kill-new (expand-file-name default-directory)))

And assign it to a key:

(global-set-key "C-c p" 'my-copy-pwd)

There ya go!


-- 
Joost Kremers                                   joostkremers@fastmail.fm
Selbst in die Unterwelt dringt durch Spalten Licht
EN:SiS(9)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]