From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Steven W. Orr" Newsgroups: gmane.emacs.help Subject: Re: insert name of current file Date: Tue, 25 Jan 2011 22:41:37 -0500 Organization: SysLang, Inc. Message-ID: <4D3F97F1.3050904@syslang.net> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1296013344 2366 80.91.229.12 (26 Jan 2011 03:42:24 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 26 Jan 2011 03:42:24 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Jan 26 04:42:20 2011 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.69) (envelope-from ) id 1PhwGx-0000dF-CW for geh-help-gnu-emacs@m.gmane.org; Wed, 26 Jan 2011 04:42:19 +0100 Original-Received: from localhost ([127.0.0.1]:49786 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PhwGw-0003Q2-VC for geh-help-gnu-emacs@m.gmane.org; Tue, 25 Jan 2011 22:42:19 -0500 Original-Received: from [140.186.70.92] (port=49242 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PhwGK-0003LB-Iu for help-gnu-emacs@gnu.org; Tue, 25 Jan 2011 22:41:41 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PhwGJ-00027W-DZ for help-gnu-emacs@gnu.org; Tue, 25 Jan 2011 22:41:40 -0500 Original-Received: from saturn.syslang.net ([207.172.210.41]:59335) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PhwGJ-00027L-AO for help-gnu-emacs@gnu.org; Tue, 25 Jan 2011 22:41:39 -0500 Original-Received: from [127.0.0.1] (localhost.localdomain [127.0.0.1]) by saturn.syslang.net (8.14.3/8.14.3) with ESMTP id p0Q3fZ9a004065 for ; Tue, 25 Jan 2011 22:41:37 -0500 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.13) Gecko/20101207 Lightning/1.0b2 Thunderbird/3.1.7 In-Reply-To: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 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:78748 Archived-At: On 1/25/2011 4:59 PM, Gradivus wrote: > > Hi, > > Sorry I'm a noob. > > I wonder if someone knows how I can insert the current file's name > (i.e., the name of the file I'm editing) at the cursor, and without the full path. > > Thanks, > > O > I know this isn't what you asked, but I've used this to death for years: (defun insert-filename (fn) "Use filename completion to insert a filename into current buffer." (interactive "FFilename to insert: ") (insert fn)) (define-key global-map [?\C-x ?\C-j] 'insert-filename) Why limit yourself to just one filename? One other thing: This will insert the whole pathname. Just get the filename you want and then just back up to the beginning of the name, then M-Backspace to get rid of the offending prefix. -- Time flies like the wind. Fruit flies like a banana. Stranger things have .0. happened but none stranger than this. Does your driver's license say Organ ..0 Donor?Black holes are where God divided by zero. Listen to me! We are all- 000 individuals! What if this weren't a hypothetical question? steveo at syslang.net