From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tim X Newsgroups: gmane.emacs.help Subject: Re: insert name of current file Date: Wed, 26 Jan 2011 10:15:13 +1100 Organization: Unlimited download news at news.astraweb.com Message-ID: <87y6684ltq.fsf@rapttech.com.au> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: dough.gmane.org 1295998831 9647 80.91.229.12 (25 Jan 2011 23:40:31 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 25 Jan 2011 23:40:31 +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 00:40:27 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 1PhsUs-0003na-I3 for geh-help-gnu-emacs@m.gmane.org; Wed, 26 Jan 2011 00:40:26 +0100 Original-Received: from localhost ([127.0.0.1]:38229 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PhsUs-0000wj-4L for geh-help-gnu-emacs@m.gmane.org; Tue, 25 Jan 2011 18:40:26 -0500 Original-Path: usenet.stanford.edu!news.kjsl.com!news-xfer.nntp.sonic.net!news.astraweb.com!border6.newsrouter.astraweb.com!not-for-mail Original-Newsgroups: gnu.emacs.help User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) Cancel-Lock: sha1:z3rW8YnlFpoiELfYsLTvwSMeh+o= Original-Lines: 54 Original-NNTP-Posting-Host: 63958fed.news.astraweb.com Original-X-Trace: DXC=59VM; 8m63F5YCNS1UYSjA1L?0kYOcDh@:N7:H2`MmAU3Ug6[@V^?kW3CAkl5c@Xgk>W1OfD0c=b59VYeIlJn^Q57 Original-Xref: usenet.stanford.edu gnu.emacs.help:184586 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:78746 Archived-At: Gradivus writes: > 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.  > I use tempo templates, which I bind to a key. When opening a new file, hitting the template key inserts the template, which includes the filename of the current file (along with other information). I also use the timestamp package so that when I save the file, the last modified date is updated. The template uses the comment-start variable so that the inserted text is prefixed with the appropriate comment character for the mode being used. The code is attached below. Tim ;;; ;;; Filename: 55tempo.el ;;; Creation Date: Wednesday, 30 April 2003 11:41 AM EST ;;; Last Modified: Saturday, 19 July 2008 12:44 PM EST ;;; Author: Tim Cross ;;; Description: ;;; This file contains some tempo templates for setting file headers. ;;; (require 'tempo) (tempo-define-template "generic-header" '((format "%s" comment-start) " Filename: " (file-name-nondirectory (buffer-file-name)) 'n (format "%s" comment-start) " Creation Date: " (format-time-string "%A, %d %B %Y %I:%M %p %Z") 'n (format "%s" comment-start) " Last Modified: " 'n (format "%s" comment-start) " Author: Tim Cross " 'n (format "%s" comment-start) " Description:" 'n (format "%s" comment-start) 'n 'n)) ;;; Lets setup some key bindings. (global-set-key [(f5)] 'tempo-template-generic-header) (provide 'tc-template) -- tcross (at) rapttech dot com dot au