help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: FSF like smart header


From: Tim X
Subject: Re: FSF like smart header
Date: Wed, 08 Dec 2010 15:19:35 -0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)

Andrea Crotti <andrea.crotti.0@gmail.com> writes:

> I want to have some nice system to have finally some sort of smart
> header in front of some files.
>
> For example it would be nice something like:
> when you create a file of c-mode in such directory, add a header on top
> with those datas (author time, name of the project etc...)
>
> So I guess I have to add a hook to find-file with some conditions, or is
> there something more elaborate?
>
> I would also like to use yasnippet, can I maybe pass some parameters to
> a yasnippet snippet to expand automatically some variables (haven't seen
> anything like that).
>
> For the timestamp I can use the already nice defined time-stamp
> functions...
>
> What do you guys have as personal setup for these kind of things?
>
> Thanks!
>
I use the following, based on tempo, which puts a standard header block in my 
files. It
uses the omment character of the major mode to determine how to put the
header in as a comment. It uses timestamp.el to handle the timestamps.
Each time the file is saved, the timestamp is automatically updated. It
could also be easily updated to use environment variables to control the
author etc. 

;;;                                                                
;;;      Filename: /home/tcross/.emacs.d/55tempo.el
;;; Creation Date: Wednesday, 30 April 2003 11:41 AM EST
;;; Last Modified: Saturday, 19 July 2008 12:44 PM EST
;;;           Job: private
;;;        Author: Tim Cross <tcross@pobox.une.edu.au>
;;;   Description:
;;; This file contains some temp 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 <tcross@xxxx>" '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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]