From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.help Subject: Re: How to get current filename and absolute path of the file in emacs? Date: Mon, 16 Apr 2007 22:36:01 +0300 Message-ID: References: <87abx93pr8.fsf@offby1.atm01.sea.blarg.net> Reply-To: Eli Zaretskii NNTP-Posting-Host: lo.gmane.org X-Trace: sea.gmane.org 1176752241 14927 80.91.229.12 (16 Apr 2007 19:37:21 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 16 Apr 2007 19:37:21 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Apr 16 21:37:13 2007 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1HdX0h-00059N-Nu for geh-help-gnu-emacs@m.gmane.org; Mon, 16 Apr 2007 21:37:11 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HdX5L-00022G-54 for geh-help-gnu-emacs@m.gmane.org; Mon, 16 Apr 2007 15:41:59 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HdX4Q-0001lM-PJ for help-gnu-emacs@gnu.org; Mon, 16 Apr 2007 15:41:02 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HdX4P-0001kY-2L for help-gnu-emacs@gnu.org; Mon, 16 Apr 2007 15:41:02 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HdX4O-0001kS-Ts for help-gnu-emacs@gnu.org; Mon, 16 Apr 2007 15:41:01 -0400 Original-Received: from heller.inter.net.il ([213.8.233.23]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1HdWzk-0004sS-GM for help-gnu-emacs@gnu.org; Mon, 16 Apr 2007 15:36:12 -0400 Original-Received: from HOME-C4E4A596F7 (IGLD-83-130-249-125.inter.net.il [83.130.249.125]) by heller.inter.net.il (MOS 3.7.3a-GA) with ESMTP id CJD59560 (AUTH halo1); Mon, 16 Apr 2007 22:36:00 +0300 (IDT) In-reply-to: <87abx93pr8.fsf@offby1.atm01.sea.blarg.net> (message from Eric Hanchrow on Sun, 15 Apr 2007 21:30:19 -0700) X-detected-kernel: FreeBSD 4.7-5.2 (or MacOS X 10.2-10.4) (2) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:42734 Archived-At: > From: Eric Hanchrow > Date: Sun, 15 Apr 2007 21:30:19 -0700 > > (defun copy-buffer-file-name (use-backslashes) > "Puts the file name of the current buffer (or the current directory, > if the buffer isn't visiting a file) onto the kill ring, so that it > can be retrieved with \\[yank], or by another program. With argument, > uses backslashes instead of forward slashes." > (interactive "P") > (let ((fn (subst-char-in-string > ?/ > (if use-backslashes ?\\ ?/) It's easier to use convert-standard-filename to mirror slashes into backslashes. The nice side effect is that the code that calls copy-buffer-file-name will now become 100% portable, because you no longer need the use-backslashes flag to DTRT.