[Top][All Lists]

[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: tomas
Subject: Re: How to prevent Emacs from translating beginning of file path into "~"?
Date: Fri, 10 Apr 2015 10:49:46 +0200
User-agent: Mutt/1.5.21 (2010-09-15)

Hash: SHA1

On Fri, Apr 10, 2015 at 11:01:56AM +0300, Eli Zaretskii wrote:
> > 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 


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

Indeed. And since I've found myself contorting my ways to achieve
that too (C-h v buffer-file-name or some such monstrosity), it seems
to be a useful thing to have. Thus a quick shot here:

  (defun copy-current-filename-as-kill ()
     (or (and buffer-file-name
              (expand-file-name buffer-file-name))

Bind that to a global key like so:

  (global-set-key (kbd "C-c f") 'copy-current-filename-as-kill)

In this case it's bound to CONTROL-c f. Note that this is one of
the keys customarily reserved to users. Modfy binding to taste.

What can be modified too is the value copied to the kill ring
(mumble mumble "clipboard" mumble) when the current buffer has
no obvious file name -- I'm doing "" here (not copying anything
would be an option too, but could have surprising results when
you yank (mumble "paste" mumble) what you think was the last
file name and get half a bufferful of text, because that was
whatever you copied before).

- -- tomás
Version: GnuPG v1.4.12 (GNU/Linux)


reply via email to

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