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

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

Re: How to prevent Emacs from translating beginning of file path into "~


From: Eli Zaretskii
Subject: Re: How to prevent Emacs from translating beginning of file path into "~"?
Date: Fri, 10 Apr 2015 11:01:56 +0300

> Date: Fri, 10 Apr 2015 03:02:09 -0400
> From: MBR <address@hidden>
> 
> The Emacs command ^x-^f (find-file) fills the mini-buffer with the full 
> path to the current directory and then waits for you to type the 
> filename.  I often I find it a useful way to copy the current directory 
> to the system's clipboard so I can paste the path into some other 
> application.  For example, in Emacs I'll type:
> 
>     ^x-^f (put path to current directory into mini-buffer)
>     ^a             (go to beginning of line)
>     ^k             (kill from beginning to end of mini-buffer, with the
>     side effect of putting that string into the system clipboard)
>     ^g             (cancel out of mini-buffer)
> 
> At this point I can paste the path into any non-Emacs application by 
> typing CMD-v (in OS-X) or CTRL-v (in Windows or Linux).
> 
> But there's a problem. Current versions of Emacs (I'm currently running 
> Emacs 24.3.1 under OS-X) try to be smart and replace the beginning of 
> the path with "~" if it matches the logged in user's home directory.  
> Unfortunately, some applications don't understand paths that begin with "~".
> 
> Is it possible to configure Emacs to put the full path (beginning with 
> "/") into the mini-buffer, rather than just the path from the home 
> directory (beginning with "~")?

What you need instead of this complicated method is a simple command
that will copy the current buffer's default-directory to the
clipboard.  That command should use expand-file-name, which will
expand any "~" into its full absolute file name.



reply via email to

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