[Top][All Lists]

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

Re: Inserting a timestamp in a file

From: Harry Putnam
Subject: Re: Inserting a timestamp in a file
Date: Sat, 31 Jan 2009 10:30:47 -0600
User-agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.0.60 (gnu/linux)

Fred Picher <address@hidden> writes:

> Hello,
>   Is there a way to insert a timestamp at a precise place in a file,
>   eg. is there a function that does this ?

Sounds like the kind of thing skeletons are good for.  If you want
something more customized than the existing timestamp functions. (Like
I did) take a look at skeletons here:

     (info "(autotype)Top")

This example may help you get it the way you want:

I wanted something for adding timestamped comments to files in a
certain format... like this:

# [HP 01/31/09_10:24:55 <MY COMMENT GOES HERE> ]

You can get just about any style time format you want by messing with

This code inserts the above timestamp comment 
(minus the stuff above between `<>')

(define-skeleton hp-comdate
        "Insert #[HP] comment and 
        date string with no newline."
        "# [HP "
        (format-time-string "%m/%d/%y_%T ") _ " ] ")

So then you can say `M-x hp-comdate <RET>' to insert the skeleton

reply via email to

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