unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* How to make Emacs paths in the minibuffer start at root (/) instead of $HOME (~)?
@ 2014-03-25 18:15 MBR
  2014-03-26  0:11 ` Christopher Howard
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: MBR @ 2014-03-25 18:15 UTC (permalink / raw)
  To: help-gnu-emacs

There are times when I'd like to make an Emacs buffer's current 
directory available to be pasted into other applications.  I can do this 
by typing:

    C-x C-f              (this asks what file you want to open, and puts
    the current directory in the mini-buffer with the cursor at the end)
    C-a (move to the beginning of the minibuffer)
    C-k (kill the contents of the minibuffer, and as a side effect make
    the line you just killed available to be pasted)
    C-g (cancel the file open operation)

A bit of a kludge, I know, but it works.  Except that for subdirectories 
of my home directory the path starts at "~" instead of "/", and some of 
the applications I might want to paste it into don't understand "~".

Is there any way to force Emacs to always start paths in the minibuffer 
at "/" instead of starting some of them at "~"?

    Mark Rosenthal
    mbr@arlsoft.com




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: How to make Emacs paths in the minibuffer start at root (/) instead of $HOME (~)?
  2014-03-25 18:15 How to make Emacs paths in the minibuffer start at root (/) instead of $HOME (~)? MBR
@ 2014-03-26  0:11 ` Christopher Howard
       [not found] ` <mailman.18211.1395792654.10748.help-gnu-emacs@gnu.org>
  2014-03-27  0:46 ` Bob Proulx
  2 siblings, 0 replies; 4+ messages in thread
From: Christopher Howard @ 2014-03-26  0:11 UTC (permalink / raw)
  To: help-gnu-emacs

On Tue, 25 Mar 2014 14:15:55 -0400
MBR <mbr@arlsoft.com> wrote:

> There are times when I'd like to make an Emacs buffer's current 
> directory available to be pasted into other applications.  I can do
> this by typing:
> 
>     C-x C-f              (this asks what file you want to open, and
> puts the current directory in the mini-buffer with the cursor at the
> end) C-a (move to the beginning of the minibuffer)
>     C-k (kill the contents of the minibuffer, and as a side effect
> make the line you just killed available to be pasted)
>     C-g (cancel the file open operation)
> 
> A bit of a kludge, I know, but it works.  Except that for
> subdirectories of my home directory the path starts at "~" instead of
> "/", and some of the applications I might want to paste it into don't
> understand "~".
> 
> Is there any way to force Emacs to always start paths in the
> minibuffer at "/" instead of starting some of them at "~"?
> 
>     Mark Rosenthal
>     mbr@arlsoft.com
> 
> 

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...?



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: How to make Emacs paths in the minibuffer start at root (/) instead of $HOME (~)?
       [not found] ` <mailman.18211.1395792654.10748.help-gnu-emacs@gnu.org>
@ 2014-03-26  1:23   ` Joost Kremers
  0 siblings, 0 replies; 4+ messages in thread
From: Joost Kremers @ 2014-03-26  1:23 UTC (permalink / raw)
  To: help-gnu-emacs

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)


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: How to make Emacs paths in the minibuffer start at root (/) instead of $HOME (~)?
  2014-03-25 18:15 How to make Emacs paths in the minibuffer start at root (/) instead of $HOME (~)? MBR
  2014-03-26  0:11 ` Christopher Howard
       [not found] ` <mailman.18211.1395792654.10748.help-gnu-emacs@gnu.org>
@ 2014-03-27  0:46 ` Bob Proulx
  2 siblings, 0 replies; 4+ messages in thread
From: Bob Proulx @ 2014-03-27  0:46 UTC (permalink / raw)
  To: MBR; +Cc: help-gnu-emacs

MBR wrote:
> Is there any way to force Emacs to always start paths in the minibuffer at
> "/" instead of starting some of them at "~"?

Emacs starts paths at the current directory.  If you start emacs in
your home then the current directory at the start is your home and it
will be ~/.  If you start emacs elsewhere then it will be wherever you
start emacs.  This is done buffer by buffer.

So the simplest answer is to start emacs at the "/" filesystem root
and then paths will start from there.

Alternatively you can simply "cd" to the root after starting emacs.
Simply use M-x cd ENTER and then specify where you want the current
buffer to change directory.  Note again that this is buffer specific.

Bob



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-03-27  0:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-25 18:15 How to make Emacs paths in the minibuffer start at root (/) instead of $HOME (~)? MBR
2014-03-26  0:11 ` Christopher Howard
     [not found] ` <mailman.18211.1395792654.10748.help-gnu-emacs@gnu.org>
2014-03-26  1:23   ` Joost Kremers
2014-03-27  0:46 ` Bob Proulx

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).