From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andy Stewart Newsgroups: gmane.emacs.help Subject: Re: Knowing the name of a file from the file itself Date: Tue, 21 Oct 2008 08:25:29 +0800 Organization: Bentium Ltd. (CN99) Message-ID: <87od1e3ibq.fsf@manatee.domain> References: <47ec3b12-d424-4b0f-8a90-d6ee3ca2add8@m73g2000hsh.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1224553254 18344 80.91.229.12 (21 Oct 2008 01:40:54 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 21 Oct 2008 01:40:54 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Oct 21 03:41:53 2008 connect(): Connection refused 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 1Ks6Fr-0002Qx-RL for geh-help-gnu-emacs@m.gmane.org; Tue, 21 Oct 2008 03:41:52 +0200 Original-Received: from localhost ([127.0.0.1]:47434 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ks6Em-00009o-GT for geh-help-gnu-emacs@m.gmane.org; Mon, 20 Oct 2008 21:40:44 -0400 Original-Path: news.stanford.edu!headwall.stanford.edu!news.glorb.com!news2!newsfeed0.kamp.net!newsfeed.kamp.net!newsfeed.freenet.de!bolzen.all.de!fu-berlin.de!news.cn99.com!manatee.domain!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 37 Original-NNTP-Posting-Host: 222.212.136.77 Original-X-Trace: news.cn99.com 1224551309 32525 222.212.136.77 (21 Oct 2008 01:08:29 GMT) Original-X-Complaints-To: usenet@news.cn99.com Original-NNTP-Posting-Date: Tue, 21 Oct 2008 01:08:29 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) Cancel-Lock: sha1:aqXAa+WPwmN8OCFebta/jXDGb5A= Original-Xref: news.stanford.edu gnu.emacs.help:163621 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:58961 Archived-At: Use this function (defun copy-buffer-file-name-as-kill(choice) "Copy the buffer-file-name to the kill-ring" (interactive "cCopy Buffer Name (F) Full, (D) Directory, (N) Name") (let ((new-kill-string) (name (if (eq major-mode 'dired-mode) (dired-get-filename) (or (buffer-file-name) "")))) (cond ((eq choice ?f) (setq new-kill-string name)) ((eq choice ?d) (setq new-kill-string (file-name-directory name))) ((eq choice ?n) (setq new-kill-string (file-name-nondirectory name))) (t (message "Quit"))) (when new-kill-string (message "%s copied" new-kill-string) (kill-new new-kill-string)))) And C-y (yank) will get information your want. abc writes: > Hi everyone, > > I'm a recent Emacs convert. I'm structuring my .emacs.d directory > which has become quite messy. > > For that purpose, I'd like to know if it's possible to know the name > of a file and the path to it from the file itself, like in many other > languages, e.g. Ruby. > > I've looked for a variable or function for this with no luck. > > > Thanks in advance.