From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Newsgroups: gmane.emacs.help Subject: Re: How to prevent Emacs from translating beginning of file path into "~"? Date: Fri, 10 Apr 2015 10:49:46 +0200 Message-ID: <20150410084946.GA32197@tuxteam.de> References: <55277571.4060106@arlsoft.com> <83bniwv2bv.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; x-action=pgp-signed Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1428655813 3486 80.91.229.3 (10 Apr 2015 08:50:13 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 10 Apr 2015 08:50:13 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Apr 10 10:50:13 2015 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1YgUdf-0007O8-SD for geh-help-gnu-emacs@m.gmane.org; Fri, 10 Apr 2015 10:50:12 +0200 Original-Received: from localhost ([::1]:38118 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YgUdf-0001aE-3W for geh-help-gnu-emacs@m.gmane.org; Fri, 10 Apr 2015 04:50:11 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:36182) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YgUdS-0001a9-Bg for help-gnu-emacs@gnu.org; Fri, 10 Apr 2015 04:49:59 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YgUdP-0002l7-5b for help-gnu-emacs@gnu.org; Fri, 10 Apr 2015 04:49:58 -0400 Original-Received: from mail.tuxteam.de ([5.199.139.25]:56542 helo=tomasium.tuxteam.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YgUdO-0002ju-Vj for help-gnu-emacs@gnu.org; Fri, 10 Apr 2015 04:49:55 -0400 Original-Received: from tomas by tomasium.tuxteam.de with local (Exim 4.80) (envelope-from ) id 1YgUdG-0000Dp-M4 for help-gnu-emacs@gnu.org; Fri, 10 Apr 2015 10:49:46 +0200 In-Reply-To: <83bniwv2bv.fsf@gnu.org> User-Agent: Mutt/1.5.21 (2010-09-15) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 5.199.139.25 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:103623 Archived-At: -----BEGIN PGP SIGNED MESSAGE----- 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 > > > > 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 () (interactive) (kill-new (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). HTH - -- tomás -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iEYEARECAAYFAlUnjqoACgkQBcgs9XrR2kboKgCfdjbP3S6BOwB4JJyx+2cPxIc9 pBgAn0O6L0BId4zY1NmrpJiThglp+bV5 =K+cL -----END PGP SIGNATURE-----